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

fix: disable callouts button when all callout variants are disabled #5720

Merged
Merged
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
11 changes: 7 additions & 4 deletions .github/workflows/block-merge-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ concurrency:
jobs:
block-merges-during-freeze:
name: Block merges during freezes

if: github.event.pull_request.draft == false

if: |
github.event.pull_request.draft == false
&& (
startsWith(github.base_ref, 'stable')
|| github.base_ref == 'main'
|| github.base_ref == 'master'
)
runs-on: ubuntu-latest-low

steps:
- name: Register server reference to fallback to master branch
run: |
Expand Down
30 changes: 29 additions & 1 deletion src/components/Menu/ActionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
:force-menu="true"
:data-text-action-entry="actionEntry.key"
:data-text-action-active="activeKey"
:disabled="!isEnabled"
@update:open="onOpenChange">
<template #icon>
<component :is="icon" :key="iconKey" />
Expand All @@ -53,10 +54,11 @@
import { NcActions, NcActionSeparator } from '@nextcloud/vue'
import { BaseActionEntry } from './BaseActionEntry.js'
import ActionListItem from './ActionListItem.vue'
import { getIsActive } from './utils.js'
import { getActionState, getIsActive } from './utils.js'
import { useOutlineStateMixin } from '../Editor/Wrapper.provider.js'
import useStore from '../../mixins/store.js'
import { useMenuIDMixin } from './MenuBar.provider.js'
import debounce from 'debounce'

export default {
name: 'ActionList',
Expand All @@ -67,8 +69,15 @@ export default {
},
extends: BaseActionEntry,
mixins: [useStore, useOutlineStateMixin, useMenuIDMixin],
props: {
forceEnabled: {
type: Boolean,
default: false,
},
},
data: () => ({
visible: false,
hasEnabledChild: true,
}),
computed: {
currentChild() {
Expand Down Expand Up @@ -121,6 +130,18 @@ export default {

return this.actionEntry.label
},
isEnabled() {
return this.forceEnabled || this.hasEnabledChild
},
},
mounted() {
this.$_updateState = debounce(this.checkStateOfChildren.bind(this), 50)
this.$editor.on('update', this.$_updateState)
this.$editor.on('selectionUpdate', this.$_updateState)
},
beforeDestroy() {
this.$editor.off('update', this.$_updateState)
this.$editor.off('selectionUpdate', this.$_updateState)
},
methods: {
onOpenChange(val) {
Expand All @@ -136,6 +157,13 @@ export default {
this.$editor.chain().focus().run()
this.$emit('trigged', entry)
},
checkStateOfChildren() {
this.hasEnabledChild = this.children.some(child => this.isChildEnabled(child))
},
isChildEnabled(child) {
return !child.isSeparator
&& !getActionState(child, this.$editor).disabled
},
},
}
</script>
1 change: 1 addition & 0 deletions src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<ActionList ref="remainingEntries"
:action-entry="hiddenEntries"
:can-be-focussed="activeMenuEntry === visibleEntries.length"
:force-enabled="true"
@click="activeMenuEntry = 'remain'">
<template #lastAction="{ visible }">
<NcActionButton v-if="canTranslate" close-after-click @click="showTranslate">
Expand Down
Loading