Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions core/src/tests/views/ContactsMenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,39 @@ describe('ContactsMenu', function() {
expect(view.text()).toContain('Adeline Snider')
expect(view.text()).toContain('Show all contacts')
})

it('hides add guest button when not capable', async () => {
const view = mount(ContactsMenu, {
data() {
return {
canInviteGuests: false,
}
},
})

await view.vm.handleOpen()

expect(view.vm.canInviteGuests).toBe(false)
expect(view.findComponent('button[title="Add guest"]').exists()).toBe(false)
})

it('shows add guest button when capable', async () => {
const view = mount(ContactsMenu, {
data() {
return {
canInviteGuests: true,
}
},
})

await view.vm.handleOpen()

const guestButton = view.findComponent('button[title="Add guest"]')

expect(view.vm.canInviteGuests).toBe(true)
expect(guestButton.exists()).toBe(true)
expect(guestButton.vm.$options.name).toBe('NcButton')
expect(guestButton.vm.$attrs.title).toBe('Add guest')
})

})
52 changes: 39 additions & 13 deletions core/src/views/ContactsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@

<template>
<NcHeaderMenu id="contactsmenu"
ref="contactsmenu"
class="contactsmenu"
:aria-label="t('core', 'Search contacts')"
@open="handleOpen">
<template #trigger>
<NcIconSvgWrapper class="contactsmenu__trigger-icon" :path="mdiContacts" />
</template>
<div class="contactsmenu__menu">
<div class="contactsmenu__menu__input-wrapper">
<NcTextField id="contactsmenu__menu__search"
ref="contactsMenuInput"
:value.sync="searchTerm"
trailing-button-icon="close"
:label="t('core', 'Search contacts')"
:trailing-button-label="t('core','Reset search')"
:show-trailing-button="searchTerm !== ''"
:placeholder="t('core', 'Search contacts …')"
class="contactsmenu__menu__search"
@input="onInputDebounced"
@trailing-button-click="onReset" />
<div class="contactsmenu__menu__search-container">
<div class="contactsmenu__menu__input-wrapper">
<NcTextField id="contactsmenu__menu__search"
ref="contactsMenuInput"
:value.sync="searchTerm"
trailing-button-icon="close"
:label="t('core', 'Search contacts')"
:trailing-button-label="t('core','Reset search')"
:show-trailing-button="searchTerm !== ''"
:placeholder="t('core', 'Search contacts …')"
class="contactsmenu__menu__search"
@input="onInputDebounced"
@trailing-button-click="onReset" />
</div>
<NcButton v-if="canInviteGuests"
variant="tertiary"
:aria-label="t('core', 'Add guest')"
:title="t('core', 'Add guest')"
@click="onGuestButtonClick">
<template #icon>
<NcIconSvgWrapper :path="mdiAccountPlusOutline" />
</template>
</NcButton>
</div>
<NcEmptyContent v-if="error" :name="t('core', 'Could not load your contacts')">
<template #icon>
Expand Down Expand Up @@ -62,7 +74,7 @@
</template>

<script>
import { mdiContacts, mdiMagnify } from '@mdi/js'
import { mdiAccountPlusOutline, mdiContacts, mdiMagnify } from '@mdi/js'
import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { t } from '@nextcloud/l10n'
Expand Down Expand Up @@ -97,6 +109,7 @@ export default {

setup() {
return {
mdiAccountPlusOutline,
mdiContacts,
mdiMagnify,
}
Expand All @@ -112,6 +125,7 @@ export default {
contacts: [],
loadingText: undefined,
error: false,
canInviteGuests: !!window?.OCA?.Guests?.openGuestDialog,
searchTerm: '',
}
},
Expand Down Expand Up @@ -170,6 +184,12 @@ export default {
})
},

onGuestButtonClick() {
if (window?.OCA?.Guests?.openGuestDialog) {
this.$refs.contactsmenu.closeMenu()
OCA.Guests.openGuestDialog('core')
}
},
},
}
</script>
Expand All @@ -195,10 +215,16 @@ export default {
margin-inline-start: 13px;
}

&__search-container {
display: flex;
flex: row nowrap;
}

&__input-wrapper {
padding: 10px;
z-index: 2;
top: 0;
flex-grow: 1;
}

&__search {
Expand Down
4 changes: 2 additions & 2 deletions dist/3580-3580.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3580-3580.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-legacy-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-legacy-unified-search.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

Loading
Loading