Skip to content

Commit 09c533a

Browse files
committed
fixup! feat: mail snippets
Signed-off-by: Hamza Mahjoubi <[email protected]>
1 parent 816269e commit 09c533a

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

src/components/snippets/ListItem.vue

+47-15
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,52 @@
2121
</NcActions>
2222
<NcDialog :open.sync="editModalOpen"
2323
:name="t('mail','Edit snippet')"
24+
size="large"
2425
:is-form="true"
25-
:buttons="buttons"
26-
size="normal">
26+
:buttons="buttons">
27+
<h2>{{ t('mail','Content') }}</h2>
2728
<NcInputField :value.sync="localSnippet.title" :label="t('mail','Title of the snippet')" />
2829
<TextEditor v-model="localSnippet.content"
2930
:html="true"
3031
:placeholder="t('mail','Content of the snippet')"
3132
:bus="bus" />
33+
<h2>{{ t('mail','Shares') }}</h2>
3234
<NcSelect v-if="!shared"
3335
v-model="share"
34-
:label="t('mail','Share with')"
3536
class="snippet-list-item__shares"
3637
:loading="loading"
3738
:user-select="true"
3839
:options="options"
3940
:get-option-label="option => option.displayName"
4041
@option:selecting="shareSnippet"
4142
@search="asyncFind" />
42-
<p v-for="user in shares" :key="user.shareWith">
43-
{{ user.shareWith }}
44-
<NcActionButton icon="icon-delete" @click="removeShare(user)">
45-
{{ t('mail','Remove share') }}
46-
</NcActionButton>
47-
</p>
43+
<template v-for="user in sortedShares">
44+
<NcUserBubble v-if="user.type === 'group'"
45+
:key="user.shareWith"
46+
avatar-image="icon-group"
47+
:display-name="user.shareWith">
48+
<template #name>
49+
<a href="#"
50+
title="Remove group"
51+
class="icon-close"
52+
@click="removeShare(user)" />
53+
</template>
54+
</NcUserBubble>
55+
<NcUserBubble v-else :key="user.shareWith" :user="user.shareWith">
56+
<template #name>
57+
<a href="#"
58+
title="Remove user"
59+
class="icon-close"
60+
@click="removeShare(user)" />
61+
</template>
62+
</NcUserBubble>
63+
</template>
4864
</NcDialog>
4965
</div>
5066
</template>
5167

5268
<script>
53-
import { NcActions, NcActionButton, NcSelect, NcDialog, NcInputField } from '@nextcloud/vue'
69+
import { NcActions, NcActionButton, NcSelect, NcDialog, NcInputField, NcUserBubble } from '@nextcloud/vue'
5470
import { getShares, shareSnippet, unshareSnippet } from '../../service/SnippetService.js'
5571
import TextEditor from '../TextEditor.vue'
5672
import { showError, showSuccess } from '@nextcloud/dialogs'
@@ -73,6 +89,7 @@ export default {
7389
NcDialog,
7490
TextEditor,
7591
NcInputField,
92+
NcUserBubble,
7693
},
7794
props: {
7895
snippet: {
@@ -115,6 +132,17 @@ export default {
115132
options() {
116133
return this.suggestions.filter(suggestion => !this.shares.find(share => share.name === suggestion.shareWith) && suggestion.shareWith !== getCurrentUser().uid)
117134
},
135+
sortedShares() {
136+
return [...this.shares].sort((a, b) => {
137+
if (a.type === 'user' && b.type === 'group') {
138+
return -1
139+
}
140+
if (a.type === 'group' && b.type === 'user') {
141+
return 1
142+
}
143+
return 0
144+
})
145+
},
118146
},
119147
async mounted() {
120148
if (!this.shared) {
@@ -141,7 +169,7 @@ export default {
141169
async removeShare(sharee) {
142170
await unshareSnippet(this.snippet.id, sharee.shareWith).then(() => {
143171
this.shares = this.shares.filter(share => share.shareWith !== sharee.shareWith)
144-
showSuccess(t('mail', 'Share deleted for {sharee}', { sharee }))
172+
showSuccess(t('mail', 'Share deleted for {name}', { name: sharee.shareWith }))
145173
}).catch(() => {
146174
showError(t('mail', 'Failed to delete share with {name}', { name: sharee.shareWith }))
147175
})
@@ -273,10 +301,10 @@ export default {
273301

274302
<style lang="scss" scoped>
275303
.snippet-list-item{
276-
display: flex;
277-
justify-content: space-between;
278-
align-items: center;
279-
padding: 5px;
304+
display: grid;
305+
grid-template-columns: 1fr 4fr 1fr;
306+
gap: 5px;
307+
padding: 5px;
280308
&__title{
281309
white-space: nowrap;
282310
padding-inline-end: 30px;
@@ -293,4 +321,8 @@ export default {
293321
width: 100%;
294322
}
295323
}
324+
.icon-close {
325+
display: block;
326+
height: 100%;
327+
}
296328
</style>

0 commit comments

Comments
 (0)