Skip to content

Commit 97745e0

Browse files
luizhf42gustavosbarreto
authored andcommitted
refactor(ui): adapt MemberInvite to use RoleSelect
1 parent 6aabd27 commit 97745e0

File tree

1 file changed

+8
-57
lines changed

1 file changed

+8
-57
lines changed

ui/src/components/Team/Member/MemberInvite.vue

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,10 @@
9090
</v-card-text>
9191

9292
<v-card-text class="mt-n10">
93-
<v-select
93+
<RoleSelect
9494
v-model="selectedRole"
95-
:items="items"
96-
item-title="value"
97-
item-value="value"
98-
label="Role"
99-
:error-messages="selectedRoleError"
100-
required
10195
data-test="role-select"
102-
>
103-
<template v-slot:item="{ props, item }">
104-
<v-list-item v-bind="props">
105-
<v-list-item-subtitle class="description-text">
106-
{{ item.raw.description }}
107-
</v-list-item-subtitle>
108-
</v-list-item>
109-
</template>
110-
111-
<template v-slot:selection="{ item }">
112-
<span>{{ item.value }}</span>
113-
</template>
114-
</v-select>
115-
96+
/>
11697
<v-checkbox
11798
v-if="envVariables.isCloud"
11899
v-model="getInvitationCheckbox"
@@ -188,23 +169,8 @@ import { envVariables } from "@/envVariables";
188169
import useSnackbar from "@/helpers/snackbar";
189170
import CopyWarning from "@/components/User/CopyWarning.vue";
190171
import BaseDialog from "@/components/BaseDialog.vue";
191-
192-
const items = [
193-
{
194-
value: "Administrator",
195-
// eslint-disable-next-line vue/max-len
196-
description: "Full access to the namespace, can perform all actions except managing billing.\nThis includes user and device management, but excludes billing-related operations.",
197-
},
198-
{
199-
value: "Operator",
200-
// eslint-disable-next-line vue/max-len
201-
description: "Can manage and operate devices, but has limited administrative privileges.\nOperators cannot change billing or ownership settings.",
202-
},
203-
{
204-
value: "Observer",
205-
description: "Can view device details and sessions but cannot make any changes.\nObservers have read-only access to monitor activity.",
206-
},
207-
];
172+
import RoleSelect from "../RoleSelect.vue";
173+
import { BasicRole } from "@/interfaces/INamespace";
208174
209175
const emit = defineEmits(["update"]);
210176
const store = useStore();
@@ -213,6 +179,7 @@ const showDialog = ref(false);
213179
const getInvitationCheckbox = ref(false);
214180
const invitationLink = computed(() => store.getters["namespaces/getInvitationLink"]);
215181
const formWindow = ref("form-1");
182+
const selectedRole = ref<BasicRole>("administrator");
216183
217184
const {
218185
value: email,
@@ -223,14 +190,6 @@ const {
223190
initialValue: "",
224191
});
225192
226-
const {
227-
value: selectedRole,
228-
errorMessage: selectedRoleError,
229-
resetField: resetSelectedRole,
230-
} = useField<string>("selectedRole", yup.string().required(), {
231-
initialValue: undefined,
232-
});
233-
234193
const hasAuthorization = () => {
235194
const role = store.getters["auth/role"];
236195
return !!role && hasPermission(authorizer.role[role], actions.namespace.addMember);
@@ -240,12 +199,12 @@ const getAvatar = (index: number) => multiavatar(`${Math.floor(Math.random() * (
240199
241200
const resetFields = () => {
242201
resetIdentifier();
243-
resetSelectedRole();
202+
selectedRole.value = "administrator";
244203
};
245204
246205
const close = () => {
247-
resetFields();
248206
showDialog.value = false;
207+
resetFields();
249208
formWindow.value = "form-1";
250209
};
251210
@@ -276,7 +235,7 @@ const handleInviteError = (error: unknown) => {
276235
const getInvitePayload = () => ({
277236
email: email.value,
278237
tenant_id: store.getters["auth/tenant"],
279-
role: selectedRole.value.toLocaleLowerCase(),
238+
role: selectedRole.value,
280239
});
281240
282241
const generateLinkInvite = async () => {
@@ -319,12 +278,4 @@ defineExpose({ emailError, formWindow, invitationLink });
319278
z-index: #{$i};
320279
}
321280
}
322-
323-
.description-text {
324-
white-space: normal;
325-
word-break: break-word;
326-
max-width: 400px;
327-
display: block;
328-
}
329-
330281
</style>

0 commit comments

Comments
 (0)