Skip to content

Commit

Permalink
validate new type option for addContextOperation method
Browse files Browse the repository at this point in the history
  • Loading branch information
ValJed committed Dec 16, 2024
1 parent 6cd08f1 commit e9f014a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/@apostrophecms/doc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ module.exports = {
];

function validate ({
action, context, label, modal, conditions, if: ifProps
action, context, type = 'modal', label, modal, conditions, if: ifProps
}) {
const allowedConditions = [
'canPublish',
Expand All @@ -1503,8 +1503,12 @@ module.exports = {
'canShareDraft'
];

if (!action || !context || !label || !modal) {
throw self.apos.error('invalid', 'addContextOperation requires action, context, label and modal properties.');
if (![ 'event', 'modal' ].includes(type)) {
throw self.apos.error('invalid', '`type` option must be `modal` (default) or `event`');
}

if (!action || !context || !label || (type === 'modal' && !modal)) {
throw self.apos.error('invalid', 'addContextOperation requires action, context, label and modal (if type is set to `modal` or unset) properties.');
}

if (
Expand Down

0 comments on commit e9f014a

Please sign in to comment.