Skip to main content

useSuggestFeatureAction

Helper for adding a "Suggest feature" action to widgets / pages that have declared a specRef. Returns an NcActions descriptor {label, icon, action, specRef} when useSpecRef() resolves a non-empty slug, or null when no specRef is in scope so consumers can v-if cleanly.

Parameters

ParamTypeNotes
vmObject (Vue component instance)The current component (typically this). Walked by the internal useSpecRef(vm) call to resolve the active slug.
onOpenModalFunction (slug: string) => voidCallback invoked when the user clicks the action item. Receives the resolved slug; the consumer is responsible for actually mounting CnSuggestFeatureModal (typically by toggling a data flag).

Returns: {label, icon, action, specRef} | null — descriptor when a specRef is in scope, null otherwise.

Usage

import { useSuggestFeatureAction } from '@conduction/nextcloud-vue'

export default {
specRef: 'catalog-management',
data() {
return { showSuggestModal: false, suggestSlug: null }
},
computed: {
suggestAction() {
return useSuggestFeatureAction(this, (slug) => {
this.suggestSlug = slug
this.showSuggestModal = true
})
},
},
}
<template>
<NcActions>
<NcActionButton v-if="suggestAction" @click="suggestAction.action">
{{ suggestAction.label }}
</NcActionButton>
</NcActions>
</template>

Reference