From cff70b6648355e8ebfb7106e3a934647694f70ba Mon Sep 17 00:00:00 2001 From: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com> Date: Wed, 15 Apr 2020 16:49:20 +0200 Subject: [PATCH] Forms migration: Org users page (#23372) * Migrate UsersActionBar * Invites table * Migrate Users page * Select version of OrgPicker * OrgRolePicker to use Select only * Fix modal issue * Move legacy Switch * Move from Forms folder * Fix failing test * Merge and fix issues * Update OrgRole issues * OrgUser type * Remove unused import * Update Snapshot --- .../ConfirmButton/ConfirmButton.story.tsx | 7 +- .../ConfirmButton/ConfirmButton.tsx | 12 +- packages/grafana-ui/src/components/index.ts | 1 + public/app/features/admin/OrgRolePicker.tsx | 13 +- public/app/features/users/InviteeRow.tsx | 29 +- public/app/features/users/UsersActionBar.tsx | 35 +- .../app/features/users/UsersListPage.test.tsx | 14 +- public/app/features/users/UsersListPage.tsx | 19 +- public/app/features/users/UsersTable.test.tsx | 10 + public/app/features/users/UsersTable.tsx | 44 +-- .../app/features/users/__mocks__/userMocks.ts | 8 +- .../UsersActionBar.test.tsx.snap | 44 +-- .../__snapshots__/UsersTable.test.tsx.snap | 366 ++++++------------ public/app/types/user.ts | 2 +- 14 files changed, 222 insertions(+), 382 deletions(-) diff --git a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.story.tsx b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.story.tsx index 920f6103486..74fb8ca5a64 100644 --- a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.story.tsx +++ b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.story.tsx @@ -23,18 +23,20 @@ const getKnobs = () => { 'primary' ), disabled: boolean('Disabled', false), + closeOnConfirm: boolean('Close on confirm', true), }; }; storiesOf('General/ConfirmButton', module) .addDecorator(withCenteredStory) .add('default', () => { - const { size, buttonText, confirmText, confirmVariant, disabled } = getKnobs(); + const { size, buttonText, confirmText, confirmVariant, disabled, closeOnConfirm } = getKnobs(); return ( <>
| {user.login} | +{user.email} | {user.name} | {user.lastSeenAtAge} | -
-
-
-
+
+ |
+ |
+
- onRemoveUser(user)} className="btn btn-danger btn-small">
-
+ |
);
diff --git a/public/app/features/users/__mocks__/userMocks.ts b/public/app/features/users/__mocks__/userMocks.ts
index 7ca8ea71bd8..e040e2c750c 100644
--- a/public/app/features/users/__mocks__/userMocks.ts
+++ b/public/app/features/users/__mocks__/userMocks.ts
@@ -1,3 +1,5 @@
+import { OrgRole, OrgUser } from 'app/types';
+
export const getMockUsers = (amount: number) => {
const users = [];
@@ -15,7 +17,7 @@ export const getMockUsers = (amount: number) => {
});
}
- return users;
+ return users as OrgUser[];
};
export const getMockUser = () => {
@@ -27,9 +29,9 @@ export const getMockUser = () => {
lastSeenAtAge: '',
login: `user`,
orgId: 1,
- role: 'Admin',
+ role: 'Admin' as OrgRole,
userId: 2,
- };
+ } as OrgUser;
};
export const getMockInvitees = (amount: number) => {
diff --git a/public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap b/public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap
index 4c34060034f..e3499bf6785 100644
--- a/public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap
+++ b/public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap
@@ -42,22 +42,22 @@ exports[`Render should render pending invites button 1`] = `
}
}
>
- - |
-
-
-
+ |
+ |
-
-
+ size="sm"
+ variant="destructive"
+ />
+ |
| - |
-
-
-
+ |
+ |
-
-
+ size="sm"
+ variant="destructive"
+ />
+ |
| - |
-
-
-
+ |
+ |
-
-
+ size="sm"
+ variant="destructive"
+ />
+ |
| - |
-
-
-
+ |
+ |
-
-
+ size="sm"
+ variant="destructive"
+ />
+ |
| - |
-
-
-
+ |
+ |
-
-
+ size="sm"
+ variant="destructive"
+ />
+ |
| - |
-
-
-
+ |
+ |
-
-
+ size="sm"
+ variant="destructive"
+ />
+ |