Skip to content

Commit 538f2f4

Browse files
luizhf42otavio
authored andcommitted
fix(ui): adapt admin's UI to new Get User response schema
1 parent f3f9645 commit 538f2f4

File tree

11 files changed

+21
-31
lines changed

11 files changed

+21
-31
lines changed

ui/admin/src/components/User/UserList.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
<td :username-test="item.username">
2121
{{ item.username }}
2222
</td>
23-
<td :namespaces-test="item.namespaces">
24-
{{ item.namespaces }}
25-
</td>
2623
<td>
2724
<UserStatusChip :status="item.status" />
2825
</td>
@@ -109,10 +106,6 @@ const headers = [
109106
text: "Username",
110107
value: "username",
111108
},
112-
{
113-
text: "Namespaces",
114-
value: "namespaces",
115-
},
116109
{
117110
text: "Status",
118111
value: "status",

ui/admin/src/interfaces/IUser.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ export type UserAuthMethods = Array<"saml" | "local">;
44

55
export interface IAdminUser {
66
id: string;
7-
namespaces: number;
7+
namespacesOwned: number;
88
max_namespaces: number;
99
status: UserStatus;
1010
created_at: string;
1111
last_login: string;
1212
name: string;
13-
email: string;
1413
username: string;
15-
password: string;
14+
email: string;
15+
recovery_email: string;
16+
mfa: {
17+
enabled: boolean;
18+
}
1619
preferences: {
1720
auth_methods: UserAuthMethods;
1821
}

ui/admin/src/store/modules/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const useUsersStore = defineStore("users", () => {
3232

3333
const fetchUserById = async (id: string) => {
3434
const { data } = await usersApi.getUser(id);
35-
return data.user as IAdminUser;
35+
return data as IAdminUser;
3636
};
3737

3838
const updateUser = async (data: IAdminUserFormData) => {

ui/admin/src/views/UserDetails.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
</div>
3535

3636
<div>
37-
<h3 class="text-overline mt-3">Namespaces:</h3>
38-
<p :data-test="currentUser.namespaces">{{ currentUser.namespaces }}</p>
37+
<h3 class="text-overline mt-3">Owned namespaces:</h3>
38+
<p :data-test="currentUser.namespacesOwned">{{ currentUser.namespacesOwned }}</p>
3939
</div>
4040
</v-card-text>
4141
<p v-else class="text-center">Something is wrong, try again !</p>

ui/admin/tests/unit/components/User/UserFormDialog/index.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ const user: IAdminUser = {
1111
id: "5f1996c84d2190a22d5857bb",
1212
name: "Antony",
1313
14+
recovery_email: "[email protected]",
15+
mfa: { enabled: false },
1416
username: "antony",
15-
password: "123456789",
1617
status: "confirmed",
17-
namespaces: 1,
18+
namespacesOwned: 1,
1819
max_namespaces: 10,
1920
created_at: "2023-10-01T12:00:00Z",
2021
last_login: "2023-10-01T12:00:00Z",

ui/admin/tests/unit/components/User/UserList/__snapshots__/index.spec.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ exports[`UserList > Renders the component 1`] = `
1111
<th class="text-center" data-test="th-name"><span data-test="th-label">Name</span></th>
1212
<th class="text-center" data-test="th-email"><span data-test="th-label">Email</span></th>
1313
<th class="text-center" data-test="th-username"><span data-test="th-label">Username</span></th>
14-
<th class="text-center" data-test="th-namespaces"><span data-test="th-label">Namespaces</span></th>
1514
<th class="text-center" data-test="th-status"><span data-test="th-label">Status</span></th>
1615
<th class="text-center" data-test="th-actions"><span data-test="th-label">Actions</span></th>
1716
</tr>
@@ -21,7 +20,6 @@ exports[`UserList > Renders the component 1`] = `
2120
<td name-test="antony">antony</td>
2221
<td email-test="[email protected]">[email protected]</td>
2322
<td username-test="antony">antony</td>
24-
<td namespaces-test="2">2</td>
2523
<td><span class="v-chip v-theme--light text-success v-chip--density-default v-chip--size-default v-chip--variant-text ma-2" draggable="false"><!----><span class="v-chip__underlay"></span>
2624
<!---->
2725
<div class="v-chip__prepend"><i class="mdi-checkbox-marked-circle mdi v-icon notranslate v-theme--light v-icon--size-default v-icon--start" aria-hidden="true"></i>

ui/admin/tests/unit/components/User/UserList/index.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ import useUsersStore from "@admin/store/modules/users";
66
import UserList from "@admin/components/User/UserList.vue";
77
import routes from "@admin/router";
88
import { SnackbarPlugin } from "@/plugins/snackbar";
9+
import { IAdminUser } from "@admin/interfaces/IUser";
910

10-
const mockUsers = [
11+
const mockUsers: IAdminUser[] = [
1112
{
1213
status: "confirmed" as const,
1314
created_at: "2022-04-13T11:42:49.578Z",
1415
16+
recovery_email: "[email protected]",
17+
mfa: { enabled: false },
1518
id: "6256b739302b50b6cc5eafcc",
1619
last_login: "0001-01-01T00:00:00Z",
1720
name: "antony",
18-
namespaces: 2,
21+
namespacesOwned: 2,
1922
max_namespaces: 5,
20-
password: "dummy",
2123
username: "antony",
2224
preferences: {
2325
auth_methods: ["saml" as const],
@@ -59,6 +61,5 @@ describe("UserList", async () => {
5961
expect(wrapper.find("[name-test]").text()).toContain(mockUsers[0].name);
6062
expect(wrapper.find("[email-test]").text()).toContain(mockUsers[0].email);
6163
expect(wrapper.find("[username-test]").text()).toContain(mockUsers[0].username);
62-
expect(wrapper.find("[namespaces-test]").text()).toContain(String(mockUsers[0].namespaces));
6364
});
6465
});

ui/admin/tests/unit/store/modules/users.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@ const users = [
99
name: "user",
1010
1111
username: "username",
12-
password: "hash_password",
1312
},
1413
{
1514
id: "xxxxxxx2",
1615
name: "user2",
1716
1817
username: "username2",
19-
password: "hash_password2",
2018
},
2119
{
2220
id: "xxxxxxx3",
2321
name: "user3",
2422
2523
username: "username3",
26-
password: "hash_password3",
2724
},
2825
];
2926

ui/admin/tests/unit/views/UserDetails/__snapshots__/index.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ exports[`User Details > Renders the component 1`] = `
5353
<p data-test="antony">antony</p>
5454
</div>
5555
<div>
56-
<h3 class="text-overline mt-3">Namespaces:</h3>
57-
<p data-test="0">0</p>
56+
<h3 class="text-overline mt-3">Owned namespaces:</h3>
57+
<p data-test="2">2</p>
5858
</div>
5959
</div>
6060
<!---->

ui/admin/tests/unit/views/UserDetails/index.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ const user = {
1515
id: "6256b739302b50b6cc5eafcc",
1616
last_login: "0001-01-01T00:00:00Z",
1717
name: "antony",
18-
namespaces: 0,
19-
password: "somepassword",
2018
username: "antony",
19+
namespacesOwned: 2,
2120
};
2221

2322
describe("User Details", async () => {
@@ -72,7 +71,6 @@ describe("User Details", async () => {
7271
expect(wrapper.find(`[data-test='${user.id}']`).text()).toContain(user.id);
7372
expect(wrapper.find(`[data-test='${user.email}']`).text()).toContain(user.email);
7473
expect(wrapper.find(`[data-test='${user.username}']`).text()).toContain(user.username);
75-
expect(wrapper.find(`[data-test='${user.namespaces}']`).text()).toContain(`${user.namespaces}`);
7674
});
7775

7876
it("Should render the correct buttons", () => {

0 commit comments

Comments
 (0)