Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]: remove guidance segmented node and clearUserInfo when logout #18

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/base/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ describe.skip('App', () => {
project_name: 'default'
}
]
},
home: { userType: 'admin' }
}
});
});
(useDispatch as jest.Mock).mockImplementation(() => scopeDispatch);
Expand Down
31 changes: 1 addition & 30 deletions packages/base/src/page/Home/DefaultScene/DefaultScene.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
import StepBox from './StepBox';
import useUserTypeHooks from './hooks/useUserTypeHooks';
import { UserTypeDictionary } from '.';
import { BasicSegmented } from '@actiontech/shared';
import { DefaultSceneSegmentedWrapper } from '../style';

const DefaultScene: React.FC = () => {
const { userType, onUserTypeChange } = useUserTypeHooks();

return (
<section>
<DefaultSceneSegmentedWrapper>
<BasicSegmented
value={userType}
onChange={(e) => {
onUserTypeChange(e as typeof userType);
}}
options={[
{
label: UserTypeDictionary.admin,
value: 'admin'
},
{
label: UserTypeDictionary.normal,
value: 'normal'
}
]}
/>
</DefaultSceneSegmentedWrapper>

<StepBox />
</section>
);
return <StepBox />;
};

export default DefaultScene;
4 changes: 2 additions & 2 deletions packages/base/src/page/Home/DefaultScene/StepBox.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Row, Col, Space } from 'antd5';
import { useNavigate } from 'react-router-dom';
import useUserTypeHooks from './hooks/useUserTypeHooks';
import { AdminUserDevopsSteps, NormalUserDevopsSteps } from '.';
import { DefaultSceneStepContainerWrapper } from '../style';
import GuidanceButton from '../components/GuidanceButton';
import useRecentlyOpenedProjects from '../../Nav/SideMenu/useRecentlyOpenedProjects';
import { DEFAULT_PROJECT_ID } from '@actiontech/shared/lib/data/common';
import { useCurrentUser } from '@actiontech/shared/lib/global';

const StepBox: React.FC = () => {
const { isAdmin } = useUserTypeHooks();
siriuswh0327 marked this conversation as resolved.
Show resolved Hide resolved
const { isAdmin } = useCurrentUser();
const navigate = useNavigate();
let currentProjectID = '';

Expand Down

This file was deleted.

7 changes: 3 additions & 4 deletions packages/base/src/page/Nav/SideMenu/UserNavigate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import { Popover } from 'antd5';
import { PopoverInnerStyleWrapper } from './style';
import { IconAccount } from '../../../icon/sideMenu';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { updateToken } from '../../../store/user';
import { AvatarStyleWrapper } from '@actiontech/shared/lib/components/AvatarCom/style';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useUserInfo } from '@actiontech/shared/lib/global';

const UserNavigate: React.FC<{
username: string;
setVersionModalOpen: () => void;
}> = ({ username, setVersionModalOpen }) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const { clearUserInfo } = useUserInfo();
const [open, setOpen] = useState(false);
const navigate = useNavigate();
const logout = () => {
dispatch(updateToken({ token: '' }));
clearUserInfo();
};

return (
Expand Down
18 changes: 0 additions & 18 deletions packages/base/src/store/home/index.test.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/base/src/store/home/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/base/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { configureStore } from '@reduxjs/toolkit';
import home from './home';
import user from './user';
import userCenter from './userCenter';
import member from './member';
Expand All @@ -19,7 +18,6 @@ import projectManage from 'sqle/src/store/projectManage';

const store = configureStore({
reducer: {
home,
user,
userCenter,
member,
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/lib/api/common/authInvalid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
updateManagementPermissions,
updateToken,
updateUser,
updateUserUid
updateUserUid,
updateUserInfoFetchStatus
} from '../../../../../base/src/store/user';
import { createBrowserHistory } from 'history';

Expand All @@ -14,6 +15,7 @@ const globalAuthInvalid = () => {
store.dispatch(updateUserUid({ uid: '' }));
store.dispatch(updateManagementPermissions({ managementPermissions: [] }));
store.dispatch(updateBindProjects({ bindProjects: [] }));
store.dispatch(updateUserInfoFetchStatus(false));
const history = createBrowserHistory();
history.push('/login');
};
Expand Down
1 change: 1 addition & 0 deletions packages/shared/lib/global/useUserInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const useUserInfo = () => {
managementPermissions: []
})
);
dispatch(updateUserInfoFetchStatus(false));
}, [dispatch]);

const {
Expand Down
8 changes: 0 additions & 8 deletions packages/shared/lib/testUtil/mockRedux.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import { Dictionary } from '../types/common.type';
import home from '../../../base/src/store/home';
import user from '../../../base/src/store/user';
import userCenter from '../../../base/src/store/userCenter';
import member from '../../../base/src/store/member';
import project from '../../../base/src/store/project';

const reducers = combineReducers({
home,
user,
userCenter,
member,
Expand All @@ -17,9 +15,3 @@ const reducers = combineReducers({
export const storeFactory = (initStore: Dictionary = {}) => {
return configureStore({ reducer: reducers, preloadedState: initStore });
};

export const getBaseHomeInitialState = () => ({
home: {
userType: 'admin'
}
});
Loading