Skip to content

Commit

Permalink
allows to pass type to doc context menu to use for operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ValJed committed Dec 31, 2024
1 parent 5e978e6 commit a2eca42
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default {
type: Object,
required: true
},
type: {
type: String,
default: null
},
// If editing in a modal, pass the current value object from the editor here
// so that the visibility of options takes unsaved changes into account
current: {
Expand Down Expand Up @@ -207,7 +211,8 @@ export default {

ifProps = ifProps || {};
moduleIf = moduleIf || {};
const canSeeOperation = checkIfConditions(this.doc, ifProps) && checkIfConditions(this.moduleOptions, moduleIf);
const canSeeOperation = checkIfConditions(this.doc, ifProps) &&
checkIfConditions(this.moduleOptions, moduleIf);

if (!canSeeOperation) {
return false;
Expand All @@ -217,11 +222,13 @@ export default {
});
},
moduleName() {
if (this.type) {
return this.type;
}
if (apos.modules[this.context.type].action === apos.modules['@apostrophecms/page'].action) {
return '@apostrophecms/page';
} else {
return this.context.type;
}
return this.context.type;
},
moduleOptions() {
return apos.modules[this.moduleName];
Expand Down

0 comments on commit a2eca42

Please sign in to comment.