mirror of
https://codeberg.org/yeentown/barkey
synced 2024-12-05 00:57:27 +00:00
128 lines
2.7 KiB
Vue
128 lines
2.7 KiB
Vue
<template>
|
|
<MkSpacer :content-max="800">
|
|
<div v-if="clip">
|
|
<div class="okzinsic _panel">
|
|
<div v-if="clip.description" class="description">
|
|
<Mfm :text="clip.description" :is-note="false" :i="$i"/>
|
|
</div>
|
|
<div class="user">
|
|
<MkAvatar :user="clip.user" class="avatar" :show-indicator="true"/> <MkUserName :user="clip.user" :nowrap="false"/>
|
|
</div>
|
|
</div>
|
|
|
|
<XNotes :pagination="pagination" :detail="true"/>
|
|
</div>
|
|
</MkSpacer>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, watch, provide } from 'vue';
|
|
import * as misskey from 'misskey-js';
|
|
import XNotes from '@/components/notes.vue';
|
|
import { $i } from '@/account';
|
|
import { i18n } from '@/i18n';
|
|
import * as os from '@/os';
|
|
import * as symbols from '@/symbols';
|
|
|
|
const props = defineProps<{
|
|
clipId: string,
|
|
}>();
|
|
|
|
let clip: misskey.entities.Clip = $ref<misskey.entities.Clip>();
|
|
const pagination = {
|
|
endpoint: 'clips/notes' as const,
|
|
limit: 10,
|
|
params: computed(() => ({
|
|
clipId: props.clipId,
|
|
})),
|
|
};
|
|
|
|
const isOwned: boolean | null = $computed<boolean | null>(() => $i && clip && ($i.id === clip.userId));
|
|
|
|
watch(() => props.clipId, async () => {
|
|
clip = await os.api('clips/show', {
|
|
clipId: props.clipId,
|
|
});
|
|
}, {
|
|
immediate: true,
|
|
});
|
|
|
|
provide('currentClipPage', $$(clip));
|
|
|
|
defineExpose({
|
|
[symbols.PAGE_INFO]: computed(() => clip ? {
|
|
title: clip.name,
|
|
icon: 'fas fa-paperclip',
|
|
bg: 'var(--bg)',
|
|
actions: isOwned ? [{
|
|
icon: 'fas fa-pencil-alt',
|
|
text: i18n.ts.edit,
|
|
handler: async (): Promise<void> => {
|
|
const { canceled, result } = await os.form(clip.name, {
|
|
name: {
|
|
type: 'string',
|
|
label: i18n.ts.name,
|
|
default: clip.name,
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
required: false,
|
|
multiline: true,
|
|
label: i18n.ts.description,
|
|
default: clip.description,
|
|
},
|
|
isPublic: {
|
|
type: 'boolean',
|
|
label: i18n.ts.public,
|
|
default: clip.isPublic,
|
|
},
|
|
});
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('clips/update', {
|
|
clipId: clip.id,
|
|
...result,
|
|
});
|
|
},
|
|
}, {
|
|
icon: 'fas fa-trash-alt',
|
|
text: i18n.ts.delete,
|
|
danger: true,
|
|
handler: async (): Promise<void> => {
|
|
const { canceled } = await os.confirm({
|
|
type: 'warning',
|
|
text: i18n.t('deleteAreYouSure', { x: clip.name }),
|
|
});
|
|
if (canceled) return;
|
|
|
|
await os.apiWithDialog('clips/delete', {
|
|
clipId: clip.id,
|
|
});
|
|
},
|
|
}] : [],
|
|
} : null),
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.okzinsic {
|
|
position: relative;
|
|
margin-bottom: var(--margin);
|
|
|
|
> .description {
|
|
padding: 16px;
|
|
}
|
|
|
|
> .user {
|
|
$height: 32px;
|
|
padding: 16px;
|
|
border-top: solid 0.5px var(--divider);
|
|
line-height: $height;
|
|
|
|
> .avatar {
|
|
width: $height;
|
|
height: $height;
|
|
}
|
|
}
|
|
}
|
|
</style>
|