diff options
| author | Andreas Nedbal <github-bf215181b5140522137b3d4f6b73544a@desu.email> | 2022-05-17 18:33:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-18 01:33:21 +0900 |
| commit | a86e1221a085d7dee5ff2a9111eb6cf9c7a19ae9 (patch) | |
| tree | 13ac2afced92d86823b046115035fec93ae25d6c /packages/client/src | |
| parent | Refactor admin/index to use Composition API (#8662) (diff) | |
| download | misskey-a86e1221a085d7dee5ff2a9111eb6cf9c7a19ae9.tar.gz misskey-a86e1221a085d7dee5ff2a9111eb6cf9c7a19ae9.tar.bz2 misskey-a86e1221a085d7dee5ff2a9111eb6cf9c7a19ae9.zip | |
Refactor file-dialog to use Composition API (#8661)
* refactor(client): refactor file-dialog to use Composition API
* Apply review suggestion from @Johann150
Co-authored-by: Johann150 <johann@qwertqwefsday.eu>
Co-authored-by: Johann150 <johann@qwertqwefsday.eu>
Diffstat (limited to 'packages/client/src')
| -rw-r--r-- | packages/client/src/pages/admin/file-dialog.vue | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/packages/client/src/pages/admin/file-dialog.vue b/packages/client/src/pages/admin/file-dialog.vue index 4c33f62399..0765548aab 100644 --- a/packages/client/src/pages/admin/file-dialog.vue +++ b/packages/client/src/pages/admin/file-dialog.vue @@ -34,74 +34,52 @@ </XModalWindow> </template> -<script lang="ts"> -import { computed, defineComponent } from 'vue'; +<script lang="ts" setup> +import { } from 'vue'; import MkButton from '@/components/ui/button.vue'; import MkSwitch from '@/components/form/switch.vue'; import XModalWindow from '@/components/ui/modal-window.vue'; import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue'; import bytes from '@/filters/bytes'; import * as os from '@/os'; +import { i18n } from '@/i18n'; -export default defineComponent({ - components: { - MkButton, - MkSwitch, - XModalWindow, - MkDriveFileThumbnail, - }, +let file: any = $ref(null); +let info: any = $ref(null); +let isSensitive: boolean = $ref(false); - props: { - fileId: { - required: true, - } - }, - - emits: ['closed'], - - data() { - return { - file: null, - info: null, - isSensitive: false, - }; - }, +const props = defineProps<{ + fileId: string, +}>(); - created() { - this.fetch(); - }, - - methods: { - async fetch() { - this.file = await os.api('drive/files/show', { fileId: this.fileId }); - this.info = await os.api('admin/drive/show-file', { fileId: this.fileId }); - this.isSensitive = this.file.isSensitive; - }, +async function fetch() { + file = await os.api('drive/files/show', { fileId: props.fileId }); + info = await os.api('admin/drive/show-file', { fileId: props.fileId }); + isSensitive = file.isSensitive; +} - showUser() { - os.pageWindow(`/user-info/${this.file.userId}`); - }, +fetch(); - async del() { - const { canceled } = await os.confirm({ - type: 'warning', - text: this.$t('removeAreYouSure', { x: this.file.name }), - }); - if (canceled) return; +function showUser() { + os.pageWindow(`/user-info/${file.userId}`); +} - os.apiWithDialog('drive/files/delete', { - fileId: this.file.id - }); - }, +async function del() { + const { canceled } = await os.confirm({ + type: 'warning', + text: i18n.t('removeAreYouSure', { x: file.name }), + }); + if (canceled) return; - async toggleIsSensitive(v) { - await os.api('drive/files/update', { fileId: this.fileId, isSensitive: v }); - this.isSensitive = v; - }, + os.apiWithDialog('drive/files/delete', { + fileId: file.id + }); +} - bytes - } -}); +async function toggleIsSensitive(v) { + await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v }); + isSensitive = v; +} </script> <style lang="scss" scoped> |