Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contacts-menu): implement custom javascript hook action #49375

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 25 additions & 2 deletions core/src/components/ContactsMenu/Contact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,54 @@
:inline="contact.topAction ? 1 : 0">
<template v-for="(action, idx) in actions">
<NcActionLink v-if="action.hyperlink !== '#'"
:key="idx"
:key="`${idx}-link`"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but my LSP complained that it is illegal to have the same key on the on both nodes of v-if/v-else.

:href="action.hyperlink"
class="other-actions">
<template #icon>
<img aria-hidden="true" class="contact__action__icon" :src="action.icon">
</template>
{{ action.title }}
</NcActionLink>
<NcActionText v-else :key="idx" class="other-actions">
<NcActionText v-else :key="`${idx}-text`" class="other-actions">
<template #icon>
<img aria-hidden="true" class="contact__action__icon" :src="action.icon">
</template>
{{ action.title }}
</NcActionText>
</template>
<NcActionButton v-for="action in jsActions"
:key="action.id"
:close-after-click="true"
class="other-actions"
@click="action.callback(contact)">
<template #icon>
<NcIconSvgWrapper class="contact__action__icon-svg"
:svg="action.iconSvg(contact)" />
</template>
{{ action.displayName(contact) }}
</NcActionButton>
</NcActions>
</li>
</template>

<script>
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
import NcActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import { getEnabledContactsMenuActions } from '@nextcloud/vue/dist/Functions/contactsMenu.js'

export default {
name: 'Contact',
components: {
NcActionLink,
NcActionText,
NcActionButton,
NcActions,
NcAvatar,
NcIconSvgWrapper,
},
props: {
contact: {
Expand All @@ -69,6 +85,9 @@ export default {
}
return this.contact.actions
},
jsActions() {
return getEnabledContactsMenuActions(this.contact)
},
preloadedUserStatus() {
if (this.contact.status) {
return {
Expand Down Expand Up @@ -98,6 +117,10 @@ export default {
padding: 12px;
filter: var(--background-invert-if-dark);
}

&__icon-svg {
padding: 5px;
}
}

&__avatar {
Expand Down
Loading