Skip to content

Commit 2a23307

Browse files
committed
refactor(ui): new settings interface
- New appearance for the Settings inputs. - New Unitary Tests to insure the correct behavior on the refactored components
1 parent f7667b5 commit 2a23307

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2496
-2482
lines changed

ui/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@fortawesome/free-brands-svg-icons": "^6.4.0",
2222
"@fortawesome/free-regular-svg-icons": "^6.4.0",
2323
"@fortawesome/free-solid-svg-icons": "^6.4.0",
24-
"@mdi/font": "7.2.96",
24+
"@mdi/font": "^7.4.47",
2525
"@productdevbook/chatwoot": "github:shellhub-io/chatwoot#build",
2626
"@rollup/plugin-inject": "^5.0.3",
2727
"@rushstack/eslint-patch": "^1.2.0",

ui/src/authorizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const {
5050
publicKeyRemove,
5151
// Namespace
5252
namespaceCreate,
53-
NamespaceEdit,
53+
namespaceEdit,
5454
namespaceAddMember,
5555
namespaceEditMember,
5656
namespaceRemoveMember,
@@ -106,7 +106,7 @@ export const actions: { [key: string]: any } = {
106106
},
107107
namespace: {
108108
create: namespaceCreate,
109-
rename: NamespaceEdit,
109+
rename: namespaceEdit,
110110
addMember: namespaceAddMember,
111111
editMember: namespaceEditMember,
112112
removeMember: namespaceRemoveMember,

ui/src/components/AppBar/AppBar.vue

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050
class="pl-2 pr-2 mr-4"
5151
data-test="user-menu-btn"
5252
>
53-
<v-avatar size="x-small" color="primary" class="border">
54-
<v-img v-if="!avatarLoadingFailed" :src="avatar" v-on:error="avatarLoadingFailed = true" data-test="user-avatar" />
55-
<v-icon color="surface" v-if="avatarLoadingFailed" data-test="user-not-found-avatar">mdi-account</v-icon>
56-
</v-avatar>
53+
<UserIcon size="1.5rem" :email="userEmail" data-test="user-icon" />
5754
</v-btn>
5855
</template>
5956
<v-list class="bg-v-theme-surface">
@@ -101,11 +98,12 @@ import {
10198
ref,
10299
} from "vue";
103100
import { useRouter, useRoute, RouteLocationRaw, RouteLocation } from "vue-router";
104-
import { computedAsync, useEventListener } from "@vueuse/core";
101+
import { useEventListener } from "@vueuse/core";
105102
import { useChatWoot } from "@productdevbook/chatwoot/vue";
106103
import { useStore } from "../../store";
107104
import { createNewClient } from "../../api/http";
108105
import handleError from "../../utils/handleError";
106+
import UserIcon from "../User/UserIcon.vue";
109107
import Notification from "./Notifications/Notification.vue";
110108
import { envVariables } from "@/envVariables";
111109
@@ -137,17 +135,6 @@ const identifier = computed(() => store.getters["support/getIdentifier"]);
137135
const currentUser = computed(() => store.getters["auth/currentUser"]);
138136
const isDarkMode = ref(getStatusDarkMode.value === "dark");
139137
140-
const avatarLoadingFailed = ref(false);
141-
const avatar = computedAsync(
142-
async () => {
143-
const encoder = new TextEncoder();
144-
const data = encoder.encode(store.getters["auth/email"]);
145-
const hash = await crypto.subtle.digest("SHA-256", data);
146-
const digest = Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join("");
147-
return `https://gravatar.com/avatar/${digest}?d=404`;
148-
},
149-
"",
150-
);
151138
const showNavigationDrawer = defineModel<boolean>();
152139
153140
const triggerClick = (item: MenuItem): void => {

ui/src/components/AuthMFA/MfaDisable.vue

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<template>
2-
<v-btn
3-
@click="openDialog"
4-
color="primary"
5-
tabindex="0"
6-
variant="elevated"
7-
data-test="disable-dialog-btn"
8-
>Disable MFA</v-btn>
92
<v-dialog
103
max-width="400px"
114
scrollable
@@ -52,22 +45,6 @@
5245
@keyup.enter="verificationCode ? mfaValidate() : false"
5346
label="Verification Code"
5447
variant="underlined" />
55-
<v-card-actions class="justify-center pa-0">
56-
<v-row class="ml-4 mr-4">
57-
<v-col>
58-
<v-btn
59-
:disabled="!verificationCode"
60-
data-test="verify-btn"
61-
color="primary"
62-
variant="tonal"
63-
block
64-
@click="mfaValidate()"
65-
>
66-
Verify
67-
</v-btn>
68-
</v-col>
69-
</v-row>
70-
</v-card-actions>
7148
<v-row>
7249
<v-col class="text-subtitle-2 mt-2">
7350
If you lost your MFA TOPT Provider, and want to use your recovery code,
@@ -83,6 +60,22 @@
8360
</v-btn>
8461
</v-col>
8562
</v-row>
63+
<v-card-actions class="justify-center pa-0">
64+
<v-row class="ml-4 mr-4 mt-2">
65+
<v-col>
66+
<v-btn
67+
:disabled="!verificationCode"
68+
data-test="verify-btn"
69+
color="primary"
70+
variant="tonal"
71+
block
72+
@click="mfaValidate()"
73+
>
74+
Verify
75+
</v-btn>
76+
</v-col>
77+
</v-row>
78+
</v-card-actions>
8679
</v-window-item>
8780
<v-window-item :value="2">
8881
<v-slide-y-reverse-transition v-if="showAlert">
@@ -174,15 +167,13 @@ import handleError from "@/utils/handleError";
174167
import Logo from "@/assets/logo-inverted.png";
175168
import { INotificationsSuccess } from "@/interfaces/INotifications";
176169
177-
const emits = defineEmits(["success"]);
178-
179170
const store = useStore();
180171
const verificationCode = ref("");
181172
const recoveryCode = ref("");
182173
const el = ref<number>(1);
183174
const showAlert = ref(false);
184175
const alertMessage = ref("");
185-
const showDialog = ref(false);
176+
const showDialog = defineModel({ default: false });
186177
const userMail = computed(() => localStorage.getItem("email"));
187178
188179
const mfaValidate = async () => {
@@ -201,7 +192,7 @@ const mfaValidate = async () => {
201192
"snackbar/showSnackbarSuccessAction",
202193
INotificationsSuccess.cancelMfa,
203194
);
204-
emits("success");
195+
showDialog.value = false;
205196
} catch (error) {
206197
if (axios.isAxiosError(error)) {
207198
const axiosError = error as AxiosError;
@@ -248,9 +239,5 @@ const close = () => {
248239
el.value = 1;
249240
};
250241
251-
const openDialog = () => {
252-
showDialog.value = true;
253-
};
254-
255-
defineExpose({ el });
242+
defineExpose({ el, showDialog });
256243
</script>

0 commit comments

Comments
 (0)