26
26
fill-color =" var(--color-text-lighter)"
27
27
/>
28
28
</template >
29
+ <template v-if =" isShared " #indicator >
30
+ <ShareVariantIcon :size =" 16" fill-color =" #0082c9" />
31
+ </template >
29
32
<template #actions >
30
33
<NcActionButton :icon =" actionFavoriteIcon" @click =" onToggleFavorite" >
31
34
{{ actionFavoriteText }}
32
35
</NcActionButton >
33
36
37
+ <NcActionButton @click =" onToggleSharing" >
38
+ <template #icon >
39
+ <ShareVariantIcon :size =" 20" />
40
+ </template >
41
+ {{ t('notes', 'Share') }}
42
+ </NcActionButton >
43
+
34
44
<NcActionButton v-if =" !showCategorySelect" @click =" showCategorySelect = true" >
35
45
<template #icon >
36
46
<FolderIcon :size =" 20" />
@@ -90,6 +100,8 @@ import StarIcon from 'vue-material-design-icons/Star.vue'
90
100
import { categoryLabel , routeIsNewNote } from ' ../Util.js'
91
101
import { showError } from ' @nextcloud/dialogs'
92
102
import { setFavorite , setTitle , fetchNote , deleteNote , setCategory } from ' ../NotesService.js'
103
+ import ShareVariantIcon from ' vue-material-design-icons/ShareVariant.vue'
104
+ import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
93
105
94
106
export default {
95
107
name: ' NoteItem' ,
@@ -104,6 +116,7 @@ export default {
104
116
NcActionSeparator,
105
117
NcActionInput,
106
118
PencilIcon,
119
+ ShareVariantIcon,
107
120
},
108
121
109
122
props: {
@@ -122,13 +135,17 @@ export default {
122
135
newTitle: ' ' ,
123
136
renaming: false ,
124
137
showCategorySelect: false ,
138
+ isShareCreated: false ,
125
139
}
126
140
},
127
141
128
142
computed: {
129
143
isSelected () {
130
144
return this .$store .getters .getSelectedNote () === this .note .id
131
145
},
146
+ isShared () {
147
+ return this .note .isShared || this .isShareCreated
148
+ },
132
149
133
150
title () {
134
151
return this .note .title + (this .note .unsaved ? ' *' : ' ' )
@@ -167,6 +184,15 @@ export default {
167
184
]
168
185
},
169
186
},
187
+
188
+ mounted () {
189
+ subscribe (' files_sharing:share:created' , this .onShareCreated )
190
+ },
191
+
192
+ destroyed () {
193
+ unsubscribe (' files_sharing:share:created' , this .onShareCreated )
194
+ },
195
+
170
196
methods: {
171
197
onMenuChange (state ) {
172
198
this .actionsOpen = state
@@ -251,6 +277,23 @@ export default {
251
277
this .actionsOpen = false
252
278
}
253
279
},
280
+ onToggleSharing () {
281
+ if (window ? .OCA ? .Files ? .Sidebar ? .setActiveTab ) {
282
+ emit (' toggle-navigation' , { open: false })
283
+ setTimeout (() => {
284
+ window .dispatchEvent (new Event (' resize' ))
285
+ }, 200 )
286
+ window .OCA .Files .Sidebar .setActiveTab (' sharing' )
287
+ window .OCA .Files .Sidebar .open (this .note .internalPath )
288
+ }
289
+ },
290
+ async onShareCreated (event ) {
291
+ const { share } = event
292
+
293
+ if (share .fileSource === this .note .id ) {
294
+ this .isShareCreated = true
295
+ }
296
+ },
254
297
},
255
298
}
256
299
< / script>
0 commit comments