2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-02-22 06:43:18 +01:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2023-04-12 04:40:08 +02:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :tabs="headerTabs"/></template>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MKSpacer v-if="!(typeof error === 'undefined')" :contentMax="1200">
|
2023-04-29 16:36:28 +02:00
|
|
|
<div :class="$style.root">
|
2023-06-09 07:00:53 +02:00
|
|
|
<img :class="$style.img" :src="serverErrorImageUrl" class="_ghost"/>
|
2023-04-29 16:36:28 +02:00
|
|
|
<p :class="$style.text">
|
|
|
|
<i class="ti ti-alert-triangle"></i>
|
|
|
|
{{ error }}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</MKSpacer>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkSpacer v-else-if="tab === 'users'" :contentMax="1200">
|
2023-02-22 06:43:18 +01:00
|
|
|
<div class="_gaps_s">
|
|
|
|
<div v-if="role">{{ role.description }}</div>
|
2023-11-17 05:27:33 +01:00
|
|
|
<MkUserList v-if="visible" :pagination="users" :extractor="(item) => item.user"/>
|
|
|
|
<div v-else-if="!visible" class="_fullinfo">
|
2023-11-13 05:31:18 +01:00
|
|
|
<img :src="infoImageUrl" class="_ghost"/>
|
|
|
|
<div>{{ i18n.ts.nothing }}</div>
|
|
|
|
</div>
|
2023-02-22 06:43:18 +01:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkSpacer v-else-if="tab === 'timeline'" :contentMax="700">
|
2023-11-17 05:27:33 +01:00
|
|
|
<MkTimeline v-if="visible" ref="timeline" src="role" :role="props.role"/>
|
|
|
|
<div v-else-if="!visible" class="_fullinfo">
|
2023-11-13 05:31:18 +01:00
|
|
|
<img :src="infoImageUrl" class="_ghost"/>
|
|
|
|
<div>{{ i18n.ts.nothing }}</div>
|
|
|
|
</div>
|
2023-04-12 04:40:08 +02:00
|
|
|
</MkSpacer>
|
2023-02-22 06:43:18 +01:00
|
|
|
</MkStickyContainer>
|
|
|
|
</template>
|
2023-05-19 09:20:53 +02:00
|
|
|
|
2023-02-22 06:43:18 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, watch } from 'vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
2023-02-22 06:43:18 +01:00
|
|
|
import MkUserList from '@/components/MkUserList.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2023-04-12 04:40:08 +02:00
|
|
|
import MkTimeline from '@/components/MkTimeline.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { instanceName } from '@/config.js';
|
2023-11-13 05:31:18 +01:00
|
|
|
import { serverErrorImageUrl, infoImageUrl } from '@/instance.js';
|
2023-02-22 06:43:18 +01:00
|
|
|
|
2023-04-12 04:40:08 +02:00
|
|
|
const props = withDefaults(defineProps<{
|
2023-02-22 06:43:18 +01:00
|
|
|
role: string;
|
2023-04-12 04:40:08 +02:00
|
|
|
initialTab?: string;
|
|
|
|
}>(), {
|
|
|
|
initialTab: 'users',
|
|
|
|
});
|
2023-02-22 06:43:18 +01:00
|
|
|
|
2023-04-12 04:40:08 +02:00
|
|
|
let tab = $ref(props.initialTab);
|
2023-02-22 06:43:18 +01:00
|
|
|
let role = $ref();
|
2023-04-29 16:36:28 +02:00
|
|
|
let error = $ref();
|
2023-11-17 05:26:48 +01:00
|
|
|
let visible = $ref(false);
|
2023-02-22 06:43:18 +01:00
|
|
|
|
|
|
|
watch(() => props.role, () => {
|
|
|
|
os.api('roles/show', {
|
|
|
|
roleId: props.role,
|
|
|
|
}).then(res => {
|
|
|
|
role = res;
|
2023-04-29 16:36:28 +02:00
|
|
|
document.title = `${role?.name} | ${instanceName}`;
|
2023-11-17 05:26:55 +01:00
|
|
|
visible = res.isExplorable && res.isPublic;
|
2023-04-29 16:36:28 +02:00
|
|
|
}).catch((err) => {
|
|
|
|
if (err.code === 'NO_SUCH_ROLE') {
|
|
|
|
error = i18n.ts.noRole;
|
|
|
|
} else {
|
|
|
|
error = i18n.ts.somethingHappened;
|
|
|
|
}
|
|
|
|
document.title = `${error} | ${instanceName}`;
|
2023-02-22 06:43:18 +01:00
|
|
|
});
|
|
|
|
}, { immediate: true });
|
|
|
|
|
|
|
|
const users = $computed(() => ({
|
|
|
|
endpoint: 'roles/users' as const,
|
|
|
|
limit: 30,
|
|
|
|
params: {
|
|
|
|
roleId: props.role,
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2023-04-12 04:40:08 +02: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 06:43:18 +01:00
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: role?.name,
|
|
|
|
icon: 'ti ti-badge',
|
|
|
|
})));
|
|
|
|
</script>
|
2023-05-19 09:20:53 +02:00
|
|
|
|
2023-04-29 16:36:28 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
|
|
|
padding: 32px;
|
|
|
|
text-align: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text {
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.img {
|
|
|
|
vertical-align: bottom;
|
|
|
|
width: 128px;
|
|
|
|
height: 128px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
border-radius: 16px;
|
|
|
|
}
|
|
|
|
</style>
|
2023-02-22 06:43:18 +01:00
|
|
|
|