LP-5613 #2
@ -3,6 +3,7 @@ import {AnyAction, Dispatch} from 'redux';
|
|||||||
import ActionTypes from 'action_types/';
|
import ActionTypes from 'action_types/';
|
||||||
import {BadgeDetails, BadgeID, BadgeTypeDefinition} from 'types/badges';
|
import {BadgeDetails, BadgeID, BadgeTypeDefinition} from 'types/badges';
|
||||||
import {GrantModalData, RHSState, SubscriptionModalData} from 'types/general';
|
import {GrantModalData, RHSState, SubscriptionModalData} from 'types/general';
|
||||||
|
import {id as pluginId} from '../manifest';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores`showRHSPlugin` action returned by
|
* Stores`showRHSPlugin` action returned by
|
||||||
@ -30,9 +31,16 @@ export function setRHSBadge(badgeID: BadgeID | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setRHSView(view: RHSState) {
|
export function setRHSView(view: RHSState) {
|
||||||
return {
|
return (dispatch: Dispatch<AnyAction>, getState: () => any) => {
|
||||||
|
const state = getState();
|
||||||
|
const pluginState = state['plugins-' + pluginId];
|
||||||
|
const currentView = pluginState?.rhsView;
|
||||||
|
dispatch({
|
||||||
type: ActionTypes.RECEIVED_RHS_VIEW,
|
type: ActionTypes.RECEIVED_RHS_VIEW,
|
||||||
data: view,
|
data: view,
|
||||||
|
prevView: currentView,
|
||||||
|
});
|
||||||
|
return {data: true};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import {BadgeDetails, BadgeID} from '../../types/badges';
|
|||||||
import Client from '../../client/api';
|
import Client from '../../client/api';
|
||||||
|
|
||||||
import {RHSState} from '../../types/general';
|
import {RHSState} from '../../types/general';
|
||||||
import {IMAGE_TYPE_EMOJI, RHS_STATE_ALL, RHS_STATE_MY, RHS_STATE_OTHER} from '../../constants';
|
import {IMAGE_TYPE_EMOJI, RHS_STATE_MY, RHS_STATE_OTHER} from '../../constants';
|
||||||
import BadgeImage from '../badge_image/badge_image';
|
import BadgeImage from '../badge_image/badge_image';
|
||||||
|
|
||||||
import {markdown} from 'utils/markdown';
|
import {markdown} from 'utils/markdown';
|
||||||
@ -23,6 +23,7 @@ import './badge_details.scss';
|
|||||||
type Props = {
|
type Props = {
|
||||||
badgeID: BadgeID | null;
|
badgeID: BadgeID | null;
|
||||||
currentUserID: string;
|
currentUserID: string;
|
||||||
|
prevView: RHSState;
|
||||||
actions: {
|
actions: {
|
||||||
setRHSView: (view: RHSState) => void;
|
setRHSView: (view: RHSState) => void;
|
||||||
setRHSUser: (user: string | null) => void;
|
setRHSUser: (user: string | null) => void;
|
||||||
@ -128,7 +129,7 @@ class BadgeDetailsComponent extends React.PureComponent<Props, State> {
|
|||||||
<div className='BadgeDetails'>
|
<div className='BadgeDetails'>
|
||||||
<div className='BadgeDetails__backHeader'>
|
<div className='BadgeDetails__backHeader'>
|
||||||
<BackButton
|
<BackButton
|
||||||
targetView={RHS_STATE_ALL}
|
targetView={this.props.prevView}
|
||||||
onNavigate={this.props.actions.setRHSView}
|
onNavigate={this.props.actions.setRHSView}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import {getCustomEmojiByName, getCustomEmojisByName} from 'mattermost-redux/acti
|
|||||||
|
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import {getRHSBadge, getRHSUser, getRHSView, getRHSTypeId, getRHSTypeName} from 'selectors';
|
import {getRHSBadge, getRHSUser, getRHSView, getPrevRHSView, getRHSTypeId, getRHSTypeName} from 'selectors';
|
||||||
import {RHS_STATE_ALL, RHS_STATE_DETAIL, RHS_STATE_OTHER, RHS_STATE_MY, RHS_STATE_TYPES, RHS_STATE_TYPE_BADGES} from '../../constants';
|
import {RHS_STATE_ALL, RHS_STATE_DETAIL, RHS_STATE_OTHER, RHS_STATE_MY, RHS_STATE_TYPES, RHS_STATE_TYPE_BADGES} from '../../constants';
|
||||||
import {RHSState} from 'types/general';
|
import {RHSState} from 'types/general';
|
||||||
import {openCreateBadgeModal, openCreateTypeModal, openEditBadgeModal, setRHSBadge, setRHSUser, setRHSView} from 'actions/actions';
|
import {openCreateBadgeModal, openCreateTypeModal, openEditBadgeModal, setRHSBadge, setRHSUser, setRHSView} from 'actions/actions';
|
||||||
@ -32,6 +32,7 @@ import './all_badges.scss';
|
|||||||
const RHS: React.FC = () => {
|
const RHS: React.FC = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const currentView = useSelector(getRHSView);
|
const currentView = useSelector(getRHSView);
|
||||||
|
const prevView = useSelector(getPrevRHSView);
|
||||||
const currentBadge = useSelector(getRHSBadge);
|
const currentBadge = useSelector(getRHSBadge);
|
||||||
const currentUserID = useSelector(getRHSUser);
|
const currentUserID = useSelector(getRHSUser);
|
||||||
const filterTypeId = useSelector(getRHSTypeId);
|
const filterTypeId = useSelector(getRHSTypeId);
|
||||||
@ -159,6 +160,7 @@ const RHS: React.FC = () => {
|
|||||||
<BadgeDetailsComponent
|
<BadgeDetailsComponent
|
||||||
badgeID={currentBadge}
|
badgeID={currentBadge}
|
||||||
currentUserID={myUser.id}
|
currentUserID={myUser.id}
|
||||||
|
prevView={prevView}
|
||||||
actions={{
|
actions={{
|
||||||
setRHSView: (view: RHSState) => dispatch(setRHSView(view)),
|
setRHSView: (view: RHSState) => dispatch(setRHSView(view)),
|
||||||
setRHSUser: (user: string | null) => dispatch(setRHSUser(user)),
|
setRHSUser: (user: string | null) => dispatch(setRHSUser(user)),
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export const RHS_STATE_TYPE_BADGES: RHSState = 'type_badges';
|
|||||||
export const initialState: PluginState = {
|
export const initialState: PluginState = {
|
||||||
showRHS: null,
|
showRHS: null,
|
||||||
rhsView: RHS_STATE_MY,
|
rhsView: RHS_STATE_MY,
|
||||||
|
prevRhsView: RHS_STATE_MY,
|
||||||
rhsBadge: null,
|
rhsBadge: null,
|
||||||
rhsUser: null,
|
rhsUser: null,
|
||||||
rhsTypeId: null,
|
rhsTypeId: null,
|
||||||
|
|||||||
@ -23,6 +23,15 @@ function rhsView(state = RHS_STATE_MY, action: GenericAction) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prevRhsView(state = RHS_STATE_MY, action: GenericAction) {
|
||||||
|
switch (action.type) {
|
||||||
|
case ActionTypes.RECEIVED_RHS_VIEW:
|
||||||
|
return action.prevView || state;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function rhsUser(state = null, action: GenericAction) {
|
function rhsUser(state = null, action: GenericAction) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.RECEIVED_RHS_USER:
|
case ActionTypes.RECEIVED_RHS_USER:
|
||||||
@ -128,6 +137,7 @@ function subscriptionModalData(state = null, action: GenericAction) {
|
|||||||
export default combineReducers({
|
export default combineReducers({
|
||||||
showRHS,
|
showRHS,
|
||||||
rhsView,
|
rhsView,
|
||||||
|
prevRhsView,
|
||||||
rhsUser,
|
rhsUser,
|
||||||
rhsBadge,
|
rhsBadge,
|
||||||
rhsTypeId,
|
rhsTypeId,
|
||||||
|
|||||||
@ -30,6 +30,13 @@ export const getRHSView = createSelector(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getPrevRHSView = createSelector(
|
||||||
|
|
|||||||
|
getPluginState,
|
||||||
|
(state) => {
|
||||||
|
return state.prevRhsView;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export const getRHSUser = createSelector(
|
export const getRHSUser = createSelector(
|
||||||
getPluginState,
|
getPluginState,
|
||||||
(state) => {
|
(state) => {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export type SubscriptionModalData = {
|
|||||||
export type PluginState = {
|
export type PluginState = {
|
||||||
showRHS: (() => void)| null;
|
showRHS: (() => void)| null;
|
||||||
rhsView: RHSState;
|
rhsView: RHSState;
|
||||||
|
prevRhsView: RHSState;
|
||||||
rhsUser: string | null;
|
rhsUser: string | null;
|
||||||
rhsBadge: BadgeID | null;
|
rhsBadge: BadgeID | null;
|
||||||
rhsTypeId: number | null;
|
rhsTypeId: number | null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user
разве первым аргументом не должна идти строка? типо 'getPrevRHSView' или что-то такое?