2626 fill-color =" var(--color-text-lighter)"
2727 />
2828 </template >
29+ <template v-if =" isShared " #indicator >
30+ <ShareVariantIcon :size =" 16" fill-color =" #0082c9" />
31+ </template >
2932 <template #actions >
3033 <NcActionButton :icon =" actionFavoriteIcon" @click =" onToggleFavorite" >
3134 {{ actionFavoriteText }}
3235 </NcActionButton >
3336
37+ <NcActionButton @click =" onToggleSharing" >
38+ <template #icon >
39+ <ShareVariantIcon :size =" 20" />
40+ </template >
41+ {{ t('notes', 'Share') }}
42+ </NcActionButton >
43+
3444 <NcActionButton v-if =" !showCategorySelect" @click =" showCategorySelect = true" >
3545 <template #icon >
3646 <FolderIcon :size =" 20" />
@@ -90,6 +100,8 @@ import StarIcon from 'vue-material-design-icons/Star.vue'
90100import { categoryLabel , routeIsNewNote } from ' ../Util.js'
91101import { showError } from ' @nextcloud/dialogs'
92102import { 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'
93105
94106export default {
95107 name: ' NoteItem' ,
@@ -104,6 +116,7 @@ export default {
104116 NcActionSeparator,
105117 NcActionInput,
106118 PencilIcon,
119+ ShareVariantIcon,
107120 },
108121
109122 props: {
@@ -122,13 +135,17 @@ export default {
122135 newTitle: ' ' ,
123136 renaming: false ,
124137 showCategorySelect: false ,
138+ isShareCreated: false ,
125139 }
126140 },
127141
128142 computed: {
129143 isSelected () {
130144 return this .$store .getters .getSelectedNote () === this .note .id
131145 },
146+ isShared () {
147+ return this .note .isShared || this .isShareCreated
148+ },
132149
133150 title () {
134151 return this .note .title + (this .note .unsaved ? ' *' : ' ' )
@@ -167,6 +184,15 @@ export default {
167184 ]
168185 },
169186 },
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+
170196 methods: {
171197 onMenuChange (state ) {
172198 this .actionsOpen = state
@@ -251,6 +277,23 @@ export default {
251277 this .actionsOpen = false
252278 }
253279 },
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+ },
254297 },
255298}
256299< / script>
0 commit comments