Skip to content

Commit

Permalink
Merge pull request #467 from actiontech/fix/create-project-permission
Browse files Browse the repository at this point in the history
[fix](Project): Button operation permission
  • Loading branch information
LZS911 authored Oct 24, 2024
2 parents 680fc09 + 218ffc1 commit 40bff6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions packages/base/src/page/Project/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,13 @@ describe('test base/page/project', () => {
jest.clearAllTimers();

mockUseCurrentUser({
isAdmin: false,
managementPermissions: [
{
uid: OpPermissionTypeUid.project_admin,
name: '项目管理'
}
]
isAdmin: false
});
superRender(<Project />);
expect(dispatchSpy).toHaveBeenCalledTimes(1);
expect(screen.getByText('创建项目')).toBeInTheDocument();
expect(screen.getByText('导 入')).toBeInTheDocument();
expect(screen.getByText('导 出')).toBeInTheDocument();
fireEvent.click(screen.getByText('创建项目'));
expect(dispatchSpy).toHaveBeenCalledTimes(2);

Expand All @@ -116,6 +113,8 @@ describe('test base/page/project', () => {
});
superRender(<Project />);
expect(screen.queryByText('创建项目')).not.toBeInTheDocument();
expect(screen.queryByText('导 入')).not.toBeInTheDocument();
expect(screen.queryByText('导 出')).not.toBeInTheDocument();
});

it('render navigate to import page', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/page/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Project: React.FC = () => {
return (
isAdmin ||
managementPermissions.some(
(v) => OpPermissionTypeUid['project_admin'] === (v?.uid ?? '')
(v) => OpPermissionTypeUid['create_project'] === (v?.uid ?? '')
)
);
}, [isAdmin, managementPermissions]);
Expand Down

0 comments on commit 40bff6a

Please sign in to comment.