センシティブなファイルを選択できないように
This commit is contained in:
parent
fafe980315
commit
16e92e6447
8 changed files with 56 additions and 15 deletions
|
|
@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
|
||||
<template>
|
||||
<div
|
||||
:class="[$style.root, { [$style.isSelected]: isSelected }]"
|
||||
:class="[$style.root, { [$style.isSelected]: isSelected, [$style.isDisabled]: isDisabled }]"
|
||||
draggable="true"
|
||||
:title="title"
|
||||
@click="onClick"
|
||||
|
|
@ -55,9 +55,11 @@ const props = withDefaults(defineProps<{
|
|||
file: Misskey.entities.DriveFile;
|
||||
folder: Misskey.entities.DriveFolder | null;
|
||||
isSelected?: boolean;
|
||||
isDisabled?: boolean;
|
||||
selectMode?: boolean;
|
||||
}>(), {
|
||||
isSelected: false,
|
||||
isDisabled: false,
|
||||
selectMode: false,
|
||||
});
|
||||
|
||||
|
|
@ -72,6 +74,8 @@ const isDragging = ref(false);
|
|||
const title = computed(() => `${props.file.name}\n${props.file.type} ${bytes(props.file.size)}`);
|
||||
|
||||
function onClick(ev: MouseEvent) {
|
||||
if (props.isDisabled) return;
|
||||
|
||||
if (props.selectMode) {
|
||||
emit('chosen', props.file);
|
||||
} else {
|
||||
|
|
@ -88,6 +92,8 @@ function onContextmenu(ev: MouseEvent) {
|
|||
}
|
||||
|
||||
function onDragstart(ev: DragEvent) {
|
||||
if (props.isDisabled) return;
|
||||
|
||||
if (ev.dataTransfer) {
|
||||
ev.dataTransfer.effectAllowed = 'move';
|
||||
ev.dataTransfer.setData(_DATA_TRANSFER_DRIVE_FILE_, JSON.stringify(props.file));
|
||||
|
|
@ -173,6 +179,12 @@ function onDragend() {
|
|||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
&.isDisabled {
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
:folder="folder"
|
||||
:selectMode="select === 'file'"
|
||||
:isSelected="selectedFiles.some(x => x.id === file.id)"
|
||||
:isDisabled="excludeSensitive && file.isSensitive"
|
||||
@chosen="chooseFile"
|
||||
@dragstart="isDragSource = true"
|
||||
@dragend="isDragSource = false"
|
||||
|
|
@ -114,9 +115,11 @@ const props = withDefaults(defineProps<{
|
|||
initialFolder?: Misskey.entities.DriveFolder;
|
||||
type?: string;
|
||||
multiple?: boolean;
|
||||
excludeSensitive?: boolean;
|
||||
select?: 'file' | 'folder' | null;
|
||||
}>(), {
|
||||
multiple: false,
|
||||
excludeSensitive: false,
|
||||
select: null,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
{{ multiple ? ((type === 'file') ? i18n.ts.selectFiles : i18n.ts.selectFolders) : ((type === 'file') ? i18n.ts.selectFile : i18n.ts.selectFolder) }}
|
||||
<span v-if="selected.length > 0" style="margin-left: 8px; opacity: 0.5;">({{ number(selected.length) }})</span>
|
||||
</template>
|
||||
<XDrive :multiple="multiple" :select="type" @changeSelection="onChangeSelection" @selected="ok()"/>
|
||||
<XDrive :multiple="multiple" :excludeSensitive="excludeSensitive" :select="type" @changeSelection="onChangeSelection" @selected="ok()"/>
|
||||
</MkModalWindow>
|
||||
</template>
|
||||
|
||||
|
|
@ -34,6 +34,7 @@ import { i18n } from '@/i18n.js';
|
|||
withDefaults(defineProps<{
|
||||
type?: 'file' | 'folder';
|
||||
multiple: boolean;
|
||||
excludeSensitive: boolean;
|
||||
}>(), {
|
||||
type: 'file',
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue