Skip to content

Commit

Permalink
Merge branch 'feature/#5710/roles-mapping' into 'develop'
Browse files Browse the repository at this point in the history
[Issue #5710] Roles mapping

See merge request canopsis/canopsis-pro!4495
  • Loading branch information
mmourcia committed Jan 14, 2025
2 parents 87ed01b + 7c4b194 commit ea13479
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:name="name"
:error-messages="errors.collect(name)"
:disabled="disabled"
:item-disabled="isDisabledItems"
:multiple="multiple"
:chips="chips"
:small-chips="chips"
Expand Down Expand Up @@ -65,6 +66,10 @@ export default {
type: String,
default: '',
},
isDisabledItems: {
type: Function,
required: false,
},
},
data() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
<c-name-field
v-field="form.name"
:label="$t('common.username')"
:disabled="onlyUserPrefs"
:disabled="onlyUserPrefs || idpFieldsMap['name']"
:autofocus="!isNew"
autocomplete="new-password"
required
/>
<v-text-field
v-field="form.firstname"
:label="$t('user.firstName')"
:disabled="onlyUserPrefs"
:disabled="onlyUserPrefs || idpFieldsMap['firstname']"
/>
<v-text-field
v-field="form.lastname"
:label="$t('user.lastName')"
:disabled="onlyUserPrefs"
:disabled="onlyUserPrefs || idpFieldsMap['lastname']"
/>
<v-text-field
v-field="form.email"
v-validate="'required|email'"
:label="$t('user.email')"
:disabled="onlyUserPrefs"
:disabled="onlyUserPrefs || idpFieldsMap['email']"
:error-messages="errors.collect('email')"
name="email"
autocomplete="new-password"
Expand All @@ -41,8 +41,9 @@
/>
<c-role-field
v-field="form.roles"
:disabled="onlyUserPrefs"
:disabled="onlyUserPrefs || idpFieldsMap['roles']"
:label="$tc('common.role', 2)"
:is-disabled-items="isDisabledRoleItem"
required
multiple
chips
Expand Down Expand Up @@ -82,8 +83,13 @@
</template>

<script>
import { computed } from 'vue';
import { AUTH_SOURCES_WITH_PASSWORD_CHANGING, GROUPS_NAVIGATION_TYPES } from '@/constants';
import { useI18n } from '@/hooks/i18n';
import { usePopups } from '@/hooks/popups';
import ViewSelector from '@/components/forms/fields/view-selector.vue';
export default {
Expand Down Expand Up @@ -113,26 +119,38 @@ export default {
default: false,
},
},
computed: {
hasPassword() {
return Object.values(AUTH_SOURCES_WITH_PASSWORD_CHANGING).includes(this.user?.source ?? '');
},
setup(props) {
const { t } = useI18n();
const popups = usePopups();
groupsNavigationItems() {
return Object.values(GROUPS_NAVIGATION_TYPES).map(type => ({
text: this.$t(`user.navigationTypes.${type}`),
value: type,
}));
},
},
methods: {
showCopyAuthKeySuccessPopup() {
this.$popups.success({ text: this.$t('success.authKeyCopied') });
},
const hasPassword = computed(() => (
Object.values(AUTH_SOURCES_WITH_PASSWORD_CHANGING).includes(props.user?.source ?? '')
));
showCopyAuthKeyErrorPopup() {
this.$popups.error({ text: this.$t('errors.default') });
},
const groupsNavigationItems = computed(() => Object.values(GROUPS_NAVIGATION_TYPES).map(type => ({
text: t(`user.navigationTypes.${type}`),
value: type,
})));
const idpFieldsMap = computed(() => (props.user?.idp_fields ?? []).reduce((acc, field) => {
acc[field] = true;
return acc;
}, {}));
const isDisabledRoleItem = item => (props.user?.idp_roles ?? []).includes(item._id);
const showCopyAuthKeySuccessPopup = () => popups.success({ text: t('success.authKeyCopied') });
const showCopyAuthKeyErrorPopup = () => popups.error({ text: t('errors.default') });
return {
hasPassword,
groupsNavigationItems,
idpFieldsMap,
isDisabledRoleItem,
showCopyAuthKeySuccessPopup,
showCopyAuthKeyErrorPopup,
};
},
};
</script>

0 comments on commit ea13479

Please sign in to comment.