UNPKG

@sanity/desk-tool

Version:

Tool for managing all sorts of content in a structured manner

29 lines (26 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = resolveDocumentActions; var _schema = _interopRequireDefault(require("part:@sanity/base/schema")); var _documentActionUtils = require("part:@sanity/base/util/document-action-utils"); var _PublishAction = require("../actions/PublishAction"); var _DiscardChangesAction = require("../actions/DiscardChangesAction"); var _UnpublishAction = require("../actions/UnpublishAction"); var _DuplicateAction = require("../actions/DuplicateAction"); var _DeleteAction = require("../actions/DeleteAction"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // @todo: remove the following line when part imports has been removed from this file ///<reference types="@sanity/types/parts" /> // NOTE: this is a small utility function to avoid having to _cast_ the // filtered array below to `DocumentActionComponent[]`. function isDocumentAction(value) { return value !== false; } // todo: this should be replaced with the defaultResolveDocumentActions function from ./defaultDocumentActions eventually, // it is kept here for now to preserve backwards compatibility with __experimental_actions function resolveDocumentActions(props) { var schemaType = _schema.default.get(props.type); return [(0, _documentActionUtils.isActionEnabled)(schemaType, 'publish') && _PublishAction.PublishAction, (0, _documentActionUtils.isActionEnabled)(schemaType, 'delete') && _DiscardChangesAction.DiscardChangesAction, (0, _documentActionUtils.isActionEnabled)(schemaType, 'delete') && _UnpublishAction.UnpublishAction, (0, _documentActionUtils.isActionEnabled)(schemaType, 'create') && _DuplicateAction.DuplicateAction, (0, _documentActionUtils.isActionEnabled)(schemaType, 'delete') && _DeleteAction.DeleteAction].filter(isDocumentAction); }