2023-02-22 07:43:18 +02:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2023-04-12 05:40:08 +03:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :tabs="headerTabs"/></template>
|
2023-02-22 07:43:18 +02:00
|
|
|
|
2023-04-12 05:40:08 +03:00
|
|
|
<MkSpacer v-if="tab === 'users'" :content-max="1200">
|
2023-02-22 07:43:18 +02:00
|
|
|
<div class="_gaps_s">
|
|
|
|
<div v-if="role">{{ role.description }}</div>
|
|
|
|
<MkUserList :pagination="users" :extractor="(item) => item.user"/>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2023-04-12 05:40:08 +03:00
|
|
|
<MkSpacer v-else-if="tab === 'timeline'" :content-max="700">
|
|
|
|
<MkTimeline ref="timeline" src="role" :role="props.role"/>
|
|
|
|
</MkSpacer>
|
2023-02-22 07:43:18 +02:00
|
|
|
</MkStickyContainer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, watch } from 'vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import MkUserList from '@/components/MkUserList.vue';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2023-04-12 05:40:08 +03:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import MkTimeline from '@/components/MkTimeline.vue';
|
2023-02-22 07:43:18 +02:00
|
|
|
|
2023-04-12 05:40:08 +03:00
|
|
|
const props = withDefaults(defineProps<{
|
2023-02-22 07:43:18 +02:00
|
|
|
role: string;
|
2023-04-12 05:40:08 +03:00
|
|
|
initialTab?: string;
|
|
|
|
}>(), {
|
|
|
|
initialTab: 'users',
|
|
|
|
});
|
2023-02-22 07:43:18 +02:00
|
|
|
|
2023-04-12 05:40:08 +03:00
|
|
|
let tab = $ref(props.initialTab);
|
2023-02-22 07:43:18 +02:00
|
|
|
let role = $ref();
|
|
|
|
|
|
|
|
watch(() => props.role, () => {
|
|
|
|
os.api('roles/show', {
|
|
|
|
roleId: props.role,
|
|
|
|
}).then(res => {
|
|
|
|
role = res;
|
|
|
|
});
|
|
|
|
}, { immediate: true });
|
|
|
|
|
|
|
|
const users = $computed(() => ({
|
|
|
|
endpoint: 'roles/users' as const,
|
|
|
|
limit: 30,
|
|
|
|
params: {
|
|
|
|
roleId: props.role,
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2023-04-12 05:40:08 +03:00
|
|
|
const headerTabs = $computed(() => [{
|
|
|
|
key: 'users',
|
|
|
|
icon: 'ti ti-users',
|
|
|
|
title: i18n.ts.users,
|
|
|
|
}, {
|
|
|
|
key: 'timeline',
|
|
|
|
icon: 'ti ti-pencil',
|
|
|
|
title: i18n.ts.timeline,
|
|
|
|
}]);
|
|
|
|
|
2023-02-22 07:43:18 +02:00
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: role?.name,
|
|
|
|
icon: 'ti ti-badge',
|
|
|
|
})));
|
|
|
|
</script>
|
|
|
|
|