Skip to content

Commit 28954d2

Browse files
luizhf42gustavosbarreto
authored andcommitted
fix(ui): add Vue and Stylistic ESLint rules and update components
1 parent bf5847a commit 28954d2

File tree

282 files changed

+5131
-2305
lines changed

Some content is hidden

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

282 files changed

+5131
-2305
lines changed

ui/admin/src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<v-app :theme>
33
<component
44
:is="layout"
5-
:data-test="`${layout}-component`" />
5+
:data-test="`${layout}-component`"
6+
/>
67
</v-app>
78
</template>
89

ui/admin/src/components/Announcement/AnnouncementDelete.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<template>
2-
<v-tooltip bottom anchor="bottom">
3-
<template v-slot:activator="{ props }">
2+
<v-tooltip
3+
bottom
4+
anchor="bottom"
5+
>
6+
<template #activator="{ props }">
47
<v-icon
58
tag="button"
69
v-bind="props"
710
data-test="delete-button"
8-
@click="showDialog = true"
911
icon="mdi-delete"
12+
@click="showDialog = true"
1013
/>
1114
</template>
1215
<span>Remove</span>

ui/admin/src/components/Announcement/AnnouncementEdit.vue

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<template>
2-
<v-tooltip bottom anchor="bottom">
3-
<template v-slot:activator="{ props }">
2+
<v-tooltip
3+
bottom
4+
anchor="bottom"
5+
>
6+
<template #activator="{ props }">
47
<v-icon
5-
@click="open"
68
tag="button"
79
v-bind="props"
810
tabindex="0"
911
data-test="edit-button"
1012
icon="mdi-pencil"
13+
@click="open"
1114
/>
1215
</template>
1316
<span>Edit</span>
@@ -33,8 +36,8 @@
3336
color="primary"
3437
/>
3538
<Editor
36-
:api-key="tinyMceKey"
3739
v-model="contentInHtml"
40+
:api-key="tinyMceKey"
3841
:init="{
3942
plugins: 'lists link image code help wordcount',
4043
menubar: 'file edit insert view tools help',
@@ -82,23 +85,27 @@ const announcementStore = useAnnouncementStore();
8285
const snackbar = useSnackbar();
8386
const showDialog = ref(false);
8487
const md = new MarkdownIt();
85-
const turndownService = new TurndownService();
88+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
89+
const { turndown } = new TurndownService() as {
90+
turndown: (input: string) => string;
91+
};
8692
const tinyMceKey = computed(() => envVariables.tinyMceKey);
8793
const isTinyMceKeyEmpty = computed(() => tinyMceKey.value === "");
8894
const announcement = computed(() => announcementStore.announcement);
8995
const contentInHtml = ref("");
9096
const contentError = ref(false);
9197
92-
const {
93-
value: title,
94-
errorMessage: titleError,
95-
} = useField<string | undefined>("title", yup.string().required(), {
96-
initialValue: props.announcementItem.title,
97-
});
98+
const { value: title, errorMessage: titleError } = useField<string | undefined>(
99+
"title",
100+
yup.string().required(),
101+
{
102+
initialValue: props.announcementItem.title,
103+
},
104+
);
98105
99106
const getAnnouncement = async () => {
100107
await announcementStore.fetchAnnouncement(props.announcementItem.uuid);
101-
contentInHtml.value = md.render(announcement.value.content as string);
108+
contentInHtml.value = md.render(announcement.value.content);
102109
};
103110
104111
const open = async () => {
@@ -120,8 +127,11 @@ const onSubmit = async () => {
120127
}
121128
122129
try {
123-
const contentInMarkdown = turndownService.turndown(contentInHtml.value);
124-
await announcementStore.updateAnnouncement(announcement.value.uuid as string, { title: title.value ?? "", content: contentInMarkdown });
130+
const contentInMarkdown = turndown(contentInHtml.value);
131+
await announcementStore.updateAnnouncement(announcement.value.uuid, {
132+
title: title.value ?? "",
133+
content: contentInMarkdown,
134+
});
125135
snackbar.showSuccess("Announcement updated successfully.");
126136
showDialog.value = false;
127137
emit("update");
@@ -135,7 +145,8 @@ defineExpose({ showDialog, announcement, contentInHtml, contentError, title });
135145
</script>
136146

137147
<style lang="scss">
138-
.tox .tox-notification--warn, .tox .tox-notification--warning {
148+
.tox .tox-notification--warn,
149+
.tox .tox-notification--warning {
139150
display: none !important;
140151
}
141152
</style>

ui/admin/src/components/Announcement/AnnouncementList.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<template>
22
<DataTable
3+
v-model:items-per-page="itemsPerPage"
4+
v-model:page="page"
35
:headers
46
:items="announcements"
5-
v-model:itemsPerPage="itemsPerPage"
6-
v-model:page="page"
7-
:totalCount="announcementCount"
7+
:total-count="announcementCount"
88
:loading
9-
:itemsPerPageOptions="[10, 20, 50, 100]"
9+
:items-per-page-options="[10, 20, 50, 100]"
1010
data-test="announcement-list"
1111
>
12-
<template v-slot:rows>
13-
<tr v-for="(announcement, index) in announcements" :key="index">
12+
<template #rows>
13+
<tr
14+
v-for="(announcement, index) in announcements"
15+
:key="index"
16+
>
1417
<td data-test="announcement-uuid">
1518
<v-chip>
1619
{{ announcement.uuid }}
@@ -23,23 +26,26 @@
2326
{{ formatDate(announcement.date) }}
2427
</td>
2528
<td data-test="announcement-actions">
26-
<v-tooltip bottom anchor="bottom">
27-
<template v-slot:activator="{ props }">
29+
<v-tooltip
30+
bottom
31+
anchor="bottom"
32+
>
33+
<template #activator="{ props }">
2834
<v-icon
2935
tag="a"
3036
dark
3137
v-bind="props"
32-
@click="redirectToAnnouncement(announcement)"
33-
@keyup.enter="redirectToAnnouncement(announcement)"
3438
tabindex="0"
3539
icon="mdi-information"
40+
@click="redirectToAnnouncement(announcement)"
41+
@keyup.enter="redirectToAnnouncement(announcement)"
3642
/>
3743
</template>
3844
<span>Info</span>
3945
</v-tooltip>
4046

4147
<AnnouncementEdit
42-
:announcementItem="announcement"
48+
:announcement-item="announcement"
4349
@update="refreshAnnouncements"
4450
/>
4551

@@ -109,11 +115,8 @@ const refreshAnnouncements = async () => {
109115
110116
const formatDate = (date: string) => moment(date).format("LL");
111117
112-
const redirectToAnnouncement = (announcement: IAdminAnnouncementShort) => {
113-
router.push({
114-
name: "announcementDetails",
115-
params: { uuid: announcement.uuid },
116-
});
118+
const redirectToAnnouncement = async (announcement: IAdminAnnouncementShort) => {
119+
await router.push({ name: "announcementDetails", params: { uuid: announcement.uuid } });
117120
};
118121
119122
watch([itemsPerPage, page], async () => {

ui/admin/src/components/Device/DeviceIcon.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<i :class="iconName" style="font-size: 20px" />
2+
<i
3+
:class="iconName"
4+
style="font-size: 20px"
5+
/>
36
</template>
47

58
<script setup lang="ts">

ui/admin/src/components/Device/DeviceList.vue

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
<template>
22
<div>
33
<DataTable
4+
v-model:items-per-page="itemsPerPage"
5+
v-model:page="page"
46
:headers
57
:items="devices"
6-
v-model:itemsPerPage="itemsPerPage"
78
:loading
8-
:totalCount="devicesCount"
9-
v-model:page="page"
10-
:itemsPerPageOptions="[10, 20, 50, 100]"
11-
@update:sort="sortByItem"
9+
:total-count="devicesCount"
10+
:items-per-page-options="[10, 20, 50, 100]"
1211
data-test="devices-list"
12+
@update:sort="sortByItem"
1313
>
14-
<template v-slot:rows>
15-
<tr v-for="(item, i) in devices" :key="i">
14+
<template #rows>
15+
<tr
16+
v-for="(item, i) in devices"
17+
:key="i"
18+
>
1619
<td>
17-
<v-icon v-if="item.online" color="success" data-test="success-icon" icon="mdi-check-circle" />
18-
<v-icon v-else color="#E53935" data-test="error-icon" icon="mdi-close-circle" />
20+
<v-icon
21+
v-if="item.online"
22+
color="success"
23+
data-test="success-icon"
24+
icon="mdi-check-circle"
25+
/>
26+
<v-icon
27+
v-else
28+
color="#E53935"
29+
data-test="error-icon"
30+
icon="mdi-close-circle"
31+
/>
1932
</td>
2033
<td>{{ item.name }}</td>
2134
<td>
@@ -26,10 +39,10 @@
2639
</td>
2740
<td>
2841
<span
29-
@click="goToNamespace(item.tenant_id)"
30-
@keypress.enter="goToNamespace(item.tenant_id)"
3142
tabindex="0"
3243
class="hover"
44+
@click="goToNamespace(item.tenant_id)"
45+
@keypress.enter="goToNamespace(item.tenant_id)"
3346
>
3447
{{ item.namespace }}
3548
</span>
@@ -43,7 +56,10 @@
4356
:disabled="!showTag(tag.name)"
4457
>
4558
<template #activator="{ props }">
46-
<v-chip size="small" v-bind="props">
59+
<v-chip
60+
size="small"
61+
v-bind="props"
62+
>
4763
{{ displayOnlyTenCharacters(tag.name) }}
4864
</v-chip>
4965
</template>
@@ -63,16 +79,19 @@
6379
</v-chip>
6480
</td>
6581
<td>
66-
<v-tooltip bottom anchor="bottom">
67-
<template v-slot:activator="{ props }">
82+
<v-tooltip
83+
bottom
84+
anchor="bottom"
85+
>
86+
<template #activator="{ props }">
6887
<v-icon
6988
tag="a"
7089
dark
7190
v-bind="props"
72-
@click="redirectToDevice(item.uid)"
73-
@keypress.enter="redirectToDevice(item.uid)"
7491
tabindex="0"
7592
icon="mdi-information"
93+
@click="redirectToDevice(item.uid)"
94+
@keypress.enter="redirectToDevice(item.uid)"
7695
/>
7796
</template>
7897
<span>Info</span>
@@ -104,7 +123,7 @@ const itemsPerPage = ref(10);
104123
const loading = ref(false);
105124
const devices = computed(() => devicesStore.devices);
106125
const devicesCount = computed(() => devicesStore.deviceCount);
107-
const sortField = ref();
126+
const sortField = ref<string>();
108127
const sortOrder = ref<"asc" | "desc" | undefined>(undefined);
109128
110129
const headers = ref([
@@ -173,12 +192,12 @@ const sortByItem = async (field: string) => {
173192
await fetchDevices();
174193
};
175194
176-
const goToNamespace = (namespace: string) => {
177-
router.push({ name: "namespaceDetails", params: { id: namespace } });
195+
const goToNamespace = async (namespace: string) => {
196+
await router.push({ name: "namespaceDetails", params: { id: namespace } });
178197
};
179198
180-
const redirectToDevice = (deviceId: string) => {
181-
router.push({ name: "deviceDetails", params: { id: deviceId } });
199+
const redirectToDevice = async (deviceId: string) => {
200+
await router.push({ name: "deviceDetails", params: { id: deviceId } });
182201
};
183202
184203
watch([itemsPerPage, page], async () => {

ui/admin/src/components/FirewallRules/FirewallRulesList.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<template>
22
<DataTable
3+
v-model:items-per-page="itemsPerPage"
4+
v-model:page="page"
35
:headers
46
:items="firewallRules"
5-
v-model:itemsPerPage="itemsPerPage"
6-
v-model:page="page"
77
:loading
8-
:totalCount="firewallRulesCount"
9-
:itemsPerPageOptions="[10, 20, 50, 100]"
8+
:total-count="firewallRulesCount"
9+
:items-per-page-options="[10, 20, 50, 100]"
1010
data-test="firewall-rules-list"
1111
>
12-
<template v-slot:rows>
13-
<tr v-for="(firewallRule, index) in firewallRules" :key="index">
12+
<template #rows>
13+
<tr
14+
v-for="firewallRule in firewallRules"
15+
:key="firewallRule.id"
16+
>
1417
<td>
1518
{{ firewallRule.tenant_id }}
1619
</td>
@@ -55,16 +58,19 @@
5558
</div>
5659
</td>
5760
<td>
58-
<v-tooltip bottom anchor="bottom">
59-
<template v-slot:activator="{ props }">
61+
<v-tooltip
62+
bottom
63+
anchor="bottom"
64+
>
65+
<template #activator="{ props }">
6066
<v-icon
6167
tag="a"
6268
dark
6369
v-bind="props"
64-
@click="goToFirewallRule(firewallRule.id)"
65-
@keypress.enter="goToFirewallRule(firewallRule.id)"
6670
tabindex="0"
6771
icon="mdi-information"
72+
@click="goToFirewallRule(firewallRule.id)"
73+
@keypress.enter="goToFirewallRule(firewallRule.id)"
6874
/>
6975
</template>
7076
<span>Details</span>

0 commit comments

Comments
 (0)