Skip to content

Commit 0d9d1e1

Browse files
committed
feat: create and add guests to teams
Signed-off-by: Kent Delante <kent.delante@proton.me>
1 parent 145f9af commit 0d9d1e1

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed

src/components/EntityPicker/EntityPicker.vue

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@
99
<!-- Wrapper for content & navigation -->
1010
<div class="entity-picker">
1111
<!-- Search -->
12-
<div class="entity-picker__search">
13-
<div class="entity-picker__search-icon icon-search" />
14-
<input ref="input"
15-
v-model="searchQuery"
16-
:placeholder="t('contacts', 'Search {types}', {types: searchPlaceholderTypes})"
17-
class="entity-picker__search-input"
18-
type="search"
19-
@input="onSearch">
12+
<div class="entity-picker__heading">
13+
<h2 class="entity-picker__title">
14+
{{ t('contacts', 'Invite members to team') }}
15+
</h2>
16+
</div>
17+
<div class="entity-picker__search-container">
18+
<div class="entity-picker__search">
19+
<div class="entity-picker__search-icon icon-search" />
20+
<input ref="input"
21+
v-model="searchQuery"
22+
:placeholder="t('contacts', 'Search {types}', {types: searchPlaceholderTypes})"
23+
class="entity-picker__search-input"
24+
type="search"
25+
@input="onSearch">
26+
</div>
27+
<Button v-if="canInviteGuests"
28+
type="button"
29+
variant="tertiary-no-background"
30+
:title="t('contacts', 'Add guest')"
31+
:aria-label="t('contacts', 'Add guest')"
32+
@click="onGuestButtonClick">
33+
<IconAccountPlusOutline :size="20" />
34+
</Button>
2035
</div>
2136

2237
<!-- Loading -->
@@ -83,20 +98,25 @@
8398
import debounce from 'debounce'
8499
import VirtualList from 'vue-virtual-scroll-list'
85100
import {
101+
NcButton as Button,
86102
NcEmptyContent as EmptyContent,
87103
NcLoadingIcon as IconLoading,
88104
NcModal as Modal,
89105
} from '@nextcloud/vue'
106+
import { subscribe } from '@nextcloud/event-bus'
90107
import IconSearch from 'vue-material-design-icons/Magnify.vue'
108+
import IconAccountPlusOutline from 'vue-material-design-icons/AccountPlusOutline.vue'
91109
import EntityBubble from './EntityBubble.vue'
92110
import EntitySearchResult from './EntitySearchResult.vue'
93111
94112
export default {
95113
name: 'EntityPicker',
96114
97115
components: {
116+
Button,
98117
EmptyContent,
99118
EntityBubble,
119+
IconAccountPlusOutline,
100120
IconSearch,
101121
IconLoading,
102122
Modal,
@@ -184,6 +204,7 @@ export default {
184204
185205
data() {
186206
return {
207+
canInviteGuests: !!window?.OCA?.Guests?.openGuestDialog,
187208
searchQuery: '',
188209
localSelection: {},
189210
EntitySearchResult,
@@ -294,6 +315,10 @@ export default {
294315
this.$refs.input.focus()
295316
this.$refs.input.select()
296317
})
318+
319+
if (this.canInviteGuests) {
320+
subscribe('guests:user:created', this.addGuest)
321+
}
297322
},
298323
299324
methods: {
@@ -359,6 +384,12 @@ export default {
359384
this.onPick(entity)
360385
}
361386
},
387+
388+
onGuestButtonClick() {
389+
if (this.canInviteGuests) {
390+
window?.OCA?.Guests?.openGuestDialog('contacts')
391+
}
392+
},
362393
},
363394
364395
}
@@ -393,13 +424,25 @@ $icon-margin: math.div($clickable-area - $icon-size, 2);
393424
min-height: $dialog-height;
394425
height: 100%;
395426
padding: $dialog-padding;
427+
padding-top: 10px;
396428
box-sizing: border-box;
397429
430+
&__title {
431+
margin-top: 0px;
432+
}
433+
398434
&__search {
399435
position: relative;
400436
display: flex;
401437
align-items: center;
402438
width: 95%;
439+
440+
&-container {
441+
display: flex;
442+
flex-flow: row nowrap;
443+
column-gap: 12px;
444+
}
445+
403446
&-input {
404447
width: 100%;
405448
height: $clickable-area - $entity-spacing !important;
@@ -419,7 +462,6 @@ $icon-margin: math.div($clickable-area - $icon-size, 2);
419462
display: flex;
420463
overflow-y: auto;
421464
align-content: flex-start;
422-
flex: 1 0 auto;
423465
flex-wrap: wrap;
424466
justify-content: flex-start;
425467
// half a line height to know there is more lines
@@ -438,7 +480,7 @@ $icon-margin: math.div($clickable-area - $icon-size, 2);
438480
439481
&__options {
440482
overflow-y: auto;
441-
flex: 1 1 100%;
483+
flex: 1 1 auto;
442484
margin: $entity-spacing 0;
443485
}
444486
@@ -469,7 +511,7 @@ it back */
469511
}
470512
471513
:deep(.modal-container__close) {
472-
margin-top: 19px;
514+
margin-top: 10px;
473515
}
474516
475517
</style>

src/components/MemberList/MemberList.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
<!-- member picker -->
3838
<EntityPicker v-if="showPicker"
39+
ref="entityPicker"
3940
:confirm-label="t('contacts', 'Add to {circle}', { circle: circle.displayName })"
4041
:data-types="pickerTypes"
4142
:data-set="filteredPickerData"
@@ -140,6 +141,7 @@ export default defineComponent({
140141
141142
mounted() {
142143
subscribe('contacts:circles:append', this.onShowPicker)
144+
subscribe('guests:user:created', this.onGuestCreated)
143145
},
144146
145147
methods: {
@@ -237,6 +239,11 @@ export default defineComponent({
237239
this.pickerData = []
238240
this.pickerSelection = {}
239241
},
242+
243+
async onGuestCreated(guest) {
244+
const results = await getSuggestions(guest.username)
245+
this.$refs.entityPicker.onClick(results[0])
246+
},
240247
},
241248
})
242249
</script>

0 commit comments

Comments
 (0)