Skip to content

Commit b600b11

Browse files
authored
feat: share management delete confirm (#1212)
1 parent 019ce80 commit b600b11

File tree

5 files changed

+64
-8
lines changed

5 files changed

+64
-8
lines changed

frontend/src/components/prompts/Prompts.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Replace from './Replace'
1919
import ReplaceRename from './ReplaceRename'
2020
import Share from './Share'
2121
import Upload from './Upload'
22+
import ShareDelete from './ShareDelete'
2223
import { mapState } from 'vuex'
2324
import buttons from '@/utils/buttons'
2425
@@ -37,7 +38,8 @@ export default {
3738
Help,
3839
Replace,
3940
ReplaceRename,
40-
Upload
41+
Upload,
42+
ShareDelete
4143
},
4244
data: function () {
4345
return {
@@ -91,7 +93,8 @@ export default {
9193
'replace',
9294
'replace-rename',
9395
'share',
94-
'upload'
96+
'upload',
97+
'share-delete'
9598
].indexOf(this.show) >= 0;
9699
97100
return matched && this.show || null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<div class="card floating">
3+
<div class="card-content">
4+
<p>{{ $t('prompts.deleteMessageShare', {path: hash.path}) }}</p>
5+
</div>
6+
<div class="card-action">
7+
<button @click="$store.commit('closeHovers')"
8+
class="button button--flat button--grey"
9+
:aria-label="$t('buttons.cancel')"
10+
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
11+
<button @click="submit"
12+
class="button button--flat button--red"
13+
:aria-label="$t('buttons.delete')"
14+
:title="$t('buttons.delete')">{{ $t('buttons.delete') }}</button>
15+
</div>
16+
</div>
17+
</template>
18+
19+
<script>
20+
import {mapMutations, mapState} from 'vuex'
21+
import { share as api } from '@/api'
22+
import buttons from '@/utils/buttons'
23+
24+
export default {
25+
name: 'share-delete',
26+
computed: {
27+
...mapState(['hash'])
28+
},
29+
methods: {
30+
...mapMutations(['closeHovers']),
31+
submit: async function () {
32+
buttons.loading('delete')
33+
34+
try {
35+
await api.remove(this.hash.hash)
36+
buttons.success('delete')
37+
38+
this.$root.$emit('share-deleted', this.hash.hash)
39+
this.closeHovers()
40+
} catch (e) {
41+
buttons.done('delete')
42+
this.$showError(e)
43+
}
44+
}
45+
}
46+
}
47+
</script>

frontend/src/i18n/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"currentlyNavigating": "Currently navigating on:",
116116
"deleteMessageMultiple": "Are you sure you want to delete {count} file(s)?",
117117
"deleteMessageSingle": "Are you sure you want to delete this file/folder?",
118+
"deleteMessageShare": "Are you sure you want to delete this share({path})?",
118119
"deleteTitle": "Delete files",
119120
"displayName": "Display Name:",
120121
"download": "Download files",

frontend/src/i18n/zh-cn.json

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"currentlyNavigating": "当前目录:",
116116
"deleteMessageMultiple": "你确定要删除这 {count} 个文件吗?",
117117
"deleteMessageSingle": "你确定要删除这个文件/文件夹吗?",
118+
"deleteMessageShare": "你确定要删除这个分享({path})吗?",
118119
"deleteTitle": "删除文件",
119120
"displayName": "名称:",
120121
"download": "下载文件",

frontend/src/views/settings/Shares.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,23 @@ export default {
7373
this.clip.on('success', () => {
7474
this.$showSuccess(this.$t('success.linkCopied'))
7575
})
76+
this.$root.$on('share-deleted', this.deleted)
7677
},
7778
beforeDestroy () {
7879
this.clip.destroy()
80+
this.$root.$off('share-deleted', this.deleted)
7981
},
8082
methods: {
8183
deleteLink: async function (event, link) {
8284
event.preventDefault()
83-
try {
84-
await api.remove(link.hash)
85-
this.links = this.links.filter(item => item.hash !== link.hash)
86-
} catch (e) {
87-
this.$showError(e)
88-
}
85+
this.$store.commit('setHash', {
86+
hash: link.hash,
87+
path: link.path
88+
})
89+
this.$store.commit('showHover', 'share-delete')
90+
},
91+
deleted (hash) {
92+
this.links = this.links.filter(item => item.hash !== hash)
8993
},
9094
humanTime (time) {
9195
return moment(time * 1000).fromNow()

0 commit comments

Comments
 (0)