payload 0.14.22-beta.0 → 0.14.23-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -0
- package/components/index.js +10 -2
- package/components/styles.css +1 -1
- package/dist/admin/components/Routes.js +81 -29
- package/dist/admin/components/elements/Autosave/index.d.ts +5 -0
- package/dist/admin/components/elements/Autosave/index.js +116 -0
- package/dist/admin/components/elements/Autosave/index.scss +5 -0
- package/dist/admin/components/elements/Autosave/types.d.ts +8 -0
- package/dist/admin/components/elements/Autosave/types.js +1 -0
- package/dist/admin/components/elements/Banner/index.scss +1 -2
- package/dist/admin/components/elements/Button/index.js +2 -1
- package/dist/admin/components/elements/Button/index.scss +26 -9
- package/dist/admin/components/elements/DeleteDocument/index.js +2 -8
- package/dist/admin/components/elements/IDLabel/index.d.ts +7 -0
- package/dist/admin/components/elements/IDLabel/index.js +8 -0
- package/dist/admin/components/elements/IDLabel/index.scss +11 -0
- package/dist/admin/components/elements/PerPage/index.d.ts +1 -2
- package/dist/admin/components/elements/PerPage/index.js +3 -2
- package/dist/admin/components/elements/Pill/index.scss +36 -10
- package/dist/admin/components/elements/Pill/types.d.ts +1 -1
- package/dist/admin/components/elements/PreviewButton/index.d.ts +1 -0
- package/dist/admin/components/elements/PreviewButton/index.js +3 -2
- package/dist/admin/components/elements/PreviewButton/index.scss +1 -0
- package/dist/admin/components/elements/Publish/index.d.ts +4 -0
- package/dist/admin/components/elements/Publish/index.js +20 -0
- package/dist/admin/components/elements/Publish/types.d.ts +1 -0
- package/dist/admin/components/elements/Publish/types.js +1 -0
- package/dist/admin/components/elements/ReactSelect/index.js +2 -2
- package/dist/admin/components/elements/ReactSelect/index.scss +4 -4
- package/dist/admin/components/elements/ReactSelect/types.d.ts +1 -0
- package/dist/admin/components/elements/RenderTitle/index.d.ts +0 -1
- package/dist/admin/components/elements/RenderTitle/index.js +6 -9
- package/dist/admin/components/elements/SaveDraft/index.d.ts +4 -0
- package/dist/admin/components/elements/SaveDraft/index.js +39 -0
- package/dist/admin/components/elements/SaveDraft/index.scss +0 -0
- package/dist/admin/components/elements/Status/index.d.ts +5 -0
- package/dist/admin/components/elements/Status/index.js +107 -0
- package/dist/admin/components/elements/Status/index.scss +30 -0
- package/dist/admin/components/elements/Status/types.d.ts +1 -0
- package/dist/admin/components/elements/Status/types.js +1 -0
- package/dist/admin/components/elements/VersionsCount/index.d.ts +5 -0
- package/dist/admin/components/elements/VersionsCount/index.js +42 -0
- package/dist/admin/components/elements/VersionsCount/index.scss +9 -0
- package/dist/admin/components/elements/VersionsCount/types.d.ts +7 -0
- package/dist/admin/components/elements/VersionsCount/types.js +1 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/types.d.ts +2 -1
- package/dist/admin/components/forms/Form/getDataByPath.d.ts +1 -1
- package/dist/admin/components/forms/Form/index.js +34 -11
- package/dist/admin/components/forms/Form/initContextState.js +3 -0
- package/dist/admin/components/forms/Form/types.d.ts +13 -4
- package/dist/admin/components/forms/Submit/index.d.ts +3 -4
- package/dist/admin/components/forms/Submit/index.js +3 -2
- package/dist/admin/components/forms/field-types/Array/Array.js +1 -5
- package/dist/admin/components/forms/field-types/Array/types.d.ts +1 -25
- package/dist/admin/components/forms/field-types/Blocks/Blocks.js +1 -5
- package/dist/admin/components/forms/field-types/Blocks/types.d.ts +1 -26
- package/dist/admin/components/forms/field-types/Relationship/createRelationMap.d.ts +10 -0
- package/dist/admin/components/forms/field-types/Relationship/createRelationMap.js +29 -0
- package/dist/admin/components/forms/field-types/Relationship/index.js +67 -47
- package/dist/admin/components/forms/field-types/Relationship/optionsReducer.js +15 -6
- package/dist/admin/components/forms/field-types/Relationship/types.d.ts +10 -1
- package/dist/admin/components/forms/field-types/RichText/RichText.js +6 -2
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.d.ts +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.js +3 -2
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/SwapUploadModal/index.d.ts +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/SwapUploadModal/index.js +4 -3
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/index.js +1 -1
- package/dist/admin/components/forms/field-types/RichText/elements/upload/{modal.scss → addSwapModals.scss} +0 -0
- package/dist/admin/components/forms/field-types/Select/index.js +5 -2
- package/dist/admin/components/forms/field-types/Upload/SelectExisting/index.js +2 -1
- package/dist/admin/components/utilities/DocumentInfo/index.d.ts +2 -13
- package/dist/admin/components/utilities/DocumentInfo/index.js +128 -19
- package/dist/admin/components/utilities/DocumentInfo/types.d.ts +23 -0
- package/dist/admin/components/utilities/DocumentInfo/types.js +1 -0
- package/dist/admin/components/views/Account/Default.js +3 -3
- package/dist/admin/components/views/Account/index.js +11 -13
- package/dist/admin/components/views/Global/Default.js +27 -9
- package/dist/admin/components/views/Global/index.js +23 -28
- package/dist/admin/components/views/Global/types.d.ts +3 -1
- package/dist/admin/components/views/NotFound/index.d.ts +1 -0
- package/dist/admin/components/views/NotFound/index.js +7 -5
- package/dist/admin/components/views/NotFound/index.scss +10 -0
- package/dist/admin/components/views/Version/Compare/index.d.ts +5 -0
- package/dist/admin/components/views/Version/Compare/index.js +79 -0
- package/dist/admin/components/views/Version/Compare/index.scss +15 -0
- package/dist/admin/components/views/Version/Compare/types.d.ts +26 -0
- package/dist/admin/components/views/Version/Compare/types.js +1 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/Label/index.d.ts +4 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/Label/index.js +5 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/Label/index.scss +6 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts +8 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +57 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Iterable/index.scss +25 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Nested/index.d.ts +8 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Nested/index.js +15 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Nested/index.scss +8 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts +8 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +68 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Relationship/index.scss +10 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts +5 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/index.js +25 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/index.scss +10 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/richTextToHTML.d.ts +1 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/richTextToHTML.js +82 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/stringifyRichText.d.ts +1 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/stringifyRichText.js +52 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/diffMethods.d.ts +6 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/diffMethods.js +6 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/index.d.ts +33 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/index.js +23 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/types.d.ts +16 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/types.js +1 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/index.d.ts +5 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/index.js +39 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/index.scss +11 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/types.d.ts +11 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/types.js +1 -0
- package/dist/admin/components/views/Version/Restore/index.d.ts +5 -0
- package/dist/admin/components/views/Version/Restore/index.js +50 -0
- package/dist/admin/components/views/Version/Restore/index.scss +20 -0
- package/dist/admin/components/views/Version/Restore/types.d.ts +10 -0
- package/dist/admin/components/views/Version/Restore/types.js +1 -0
- package/dist/admin/components/views/Version/SelectLocales/index.d.ts +5 -0
- package/dist/admin/components/views/Version/SelectLocales/index.js +8 -0
- package/dist/admin/components/views/Version/SelectLocales/index.scss +9 -0
- package/dist/admin/components/views/Version/SelectLocales/types.d.ts +6 -0
- package/dist/admin/components/views/Version/SelectLocales/types.js +1 -0
- package/dist/admin/components/views/Version/Version.d.ts +5 -0
- package/dist/admin/components/views/Version/Version.js +158 -0
- package/dist/admin/components/views/Version/index.d.ts +4 -0
- package/dist/admin/components/views/Version/index.js +6 -0
- package/dist/admin/components/views/Version/index.scss +65 -0
- package/dist/admin/components/views/Version/shared.d.ts +8 -0
- package/dist/admin/components/views/Version/shared.js +8 -0
- package/dist/admin/components/views/Version/types.d.ts +16 -0
- package/dist/admin/components/views/Version/types.js +1 -0
- package/dist/admin/components/views/Versions/columns.d.ts +4 -0
- package/dist/admin/components/views/Versions/columns.js +47 -0
- package/dist/admin/components/views/Versions/index.d.ts +5 -0
- package/dist/admin/components/views/Versions/index.js +178 -0
- package/dist/admin/components/views/Versions/index.scss +79 -0
- package/dist/admin/components/views/Versions/types.d.ts +6 -0
- package/dist/admin/components/views/Versions/types.js +1 -0
- package/dist/admin/components/views/collections/Edit/Default.js +38 -24
- package/dist/admin/components/views/collections/Edit/index.js +41 -30
- package/dist/admin/components/views/collections/Edit/index.scss +15 -3
- package/dist/admin/components/views/collections/Edit/types.d.ts +1 -0
- package/dist/admin/components/views/collections/List/Default.js +2 -1
- package/dist/admin/components/views/collections/List/index.js +1 -0
- package/dist/admin/components/views/collections/List/types.d.ts +2 -1
- package/dist/admin/hooks/useDebounce.d.ts +1 -1
- package/dist/admin/scss/app.scss +1 -1
- package/dist/{fields/baseFields/baseAccountLockFields.d.ts → auth/baseFields/accountLock.d.ts} +1 -1
- package/dist/auth/baseFields/accountLock.js +16 -0
- package/dist/{fields/baseFields/baseAuthFields.d.ts → auth/baseFields/apiKey.d.ts} +1 -1
- package/dist/auth/baseFields/apiKey.js +63 -0
- package/dist/{fields/baseFields/baseVerificationFields.d.ts → auth/baseFields/auth.d.ts} +1 -1
- package/dist/auth/baseFields/auth.js +28 -0
- package/dist/{fields/baseFields/baseAPIKeyFields.d.ts → auth/baseFields/verification.d.ts} +1 -1
- package/dist/auth/baseFields/verification.js +41 -0
- package/dist/auth/operations/access.d.ts +2 -1
- package/dist/auth/operations/access.js +14 -3
- package/dist/auth/operations/local/login.d.ts +4 -1
- package/dist/auth/operations/local/login.js +1 -1
- package/dist/auth/operations/login.d.ts +2 -1
- package/dist/auth/operations/login.js +2 -2
- package/dist/auth/operations/registerFirstUser.d.ts +6 -0
- package/dist/auth/operations/registerFirstUser.js +11 -8
- package/dist/collections/bindCollection.d.ts +3 -2
- package/dist/collections/bindCollection.js +1 -1
- package/dist/collections/config/defaults.d.ts +1 -0
- package/dist/collections/config/defaults.js +2 -1
- package/dist/collections/config/sanitize.js +39 -45
- package/dist/collections/config/schema.js +12 -1
- package/dist/collections/config/types.d.ts +16 -16
- package/dist/collections/graphql/init.js +63 -3
- package/dist/collections/graphql/resolvers/create.js +2 -1
- package/dist/collections/graphql/resolvers/find.js +2 -1
- package/dist/collections/graphql/resolvers/findByID.js +2 -1
- package/dist/collections/graphql/resolvers/findVersionByID.d.ts +11 -0
- package/dist/collections/graphql/resolvers/findVersionByID.js +22 -0
- package/dist/collections/graphql/resolvers/findVersions.d.ts +16 -0
- package/dist/collections/graphql/resolvers/findVersions.js +25 -0
- package/dist/collections/graphql/resolvers/restoreVersion.d.ts +8 -0
- package/dist/collections/graphql/resolvers/restoreVersion.js +17 -0
- package/dist/collections/graphql/resolvers/update.js +3 -1
- package/dist/collections/init.js +26 -2
- package/dist/collections/operations/create.d.ts +1 -0
- package/dist/collections/operations/create.js +13 -58
- package/dist/collections/operations/find.d.ts +3 -1
- package/dist/collections/operations/find.js +44 -46
- package/dist/collections/operations/findByID.d.ts +3 -1
- package/dist/collections/operations/findByID.js +21 -11
- package/dist/collections/operations/findVersionByID.d.ts +16 -0
- package/dist/collections/operations/findVersionByID.js +102 -0
- package/dist/collections/operations/findVersions.d.ts +19 -0
- package/dist/collections/operations/findVersions.js +125 -0
- package/dist/collections/operations/local/create.d.ts +5 -2
- package/dist/collections/operations/local/create.js +4 -2
- package/dist/collections/operations/local/find.d.ts +3 -1
- package/dist/collections/operations/local/find.js +3 -2
- package/dist/collections/operations/local/findByID.d.ts +2 -0
- package/dist/collections/operations/local/findByID.js +5 -2
- package/dist/collections/operations/local/findVersionByID.d.ts +16 -0
- package/dist/collections/operations/local/findVersionByID.js +24 -0
- package/dist/collections/operations/local/findVersions.d.ts +17 -0
- package/dist/collections/operations/local/findVersions.js +26 -0
- package/dist/collections/operations/local/index.d.ts +6 -0
- package/dist/collections/operations/local/index.js +7 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +14 -0
- package/dist/collections/operations/local/restoreVersion.js +25 -0
- package/dist/collections/operations/local/update.d.ts +6 -5
- package/dist/collections/operations/local/update.js +4 -2
- package/dist/collections/operations/restoreVersion.d.ts +15 -0
- package/dist/collections/operations/restoreVersion.js +118 -0
- package/dist/collections/operations/update.d.ts +5 -2
- package/dist/collections/operations/update.js +72 -79
- package/dist/collections/requestHandlers/create.js +2 -1
- package/dist/collections/requestHandlers/find.d.ts +2 -1
- package/dist/collections/requestHandlers/find.js +2 -1
- package/dist/collections/requestHandlers/findByID.js +2 -1
- package/dist/collections/requestHandlers/findVersionByID.d.ts +8 -0
- package/dist/collections/requestHandlers/findVersionByID.js +19 -0
- package/dist/collections/requestHandlers/findVersions.d.ts +5 -0
- package/dist/collections/requestHandlers/findVersions.js +33 -0
- package/dist/collections/requestHandlers/restoreVersion.d.ts +8 -0
- package/dist/collections/requestHandlers/restoreVersion.js +27 -0
- package/dist/collections/requestHandlers/update.js +11 -2
- package/dist/config/defaults.d.ts +1 -0
- package/dist/config/defaults.js +2 -1
- package/dist/config/schema.js +1 -2
- package/dist/config/types.d.ts +1 -1
- package/dist/errors/TimestampsRequired.d.ts +6 -0
- package/dist/errors/TimestampsRequired.js +13 -0
- package/dist/express/middleware/index.js +2 -2
- package/dist/fields/accessPromise.d.ts +1 -1
- package/dist/fields/hookPromise.d.ts +3 -1
- package/dist/fields/hookPromise.js +41 -14
- package/dist/fields/mergeBaseFields.d.ts +2 -0
- package/dist/fields/mergeBaseFields.js +40 -0
- package/dist/fields/performFieldOperations.d.ts +4 -4
- package/dist/fields/performFieldOperations.js +4 -2
- package/dist/fields/relationshipPopulationPromise.js +3 -3
- package/dist/fields/richText/populate.js +4 -7
- package/dist/fields/traverseFields.d.ts +2 -1
- package/dist/fields/traverseFields.js +4 -2
- package/dist/globals/buildModel.d.ts +2 -2
- package/dist/globals/buildModel.js +3 -1
- package/dist/globals/config/sanitize.js +25 -2
- package/dist/globals/config/schema.js +11 -1
- package/dist/globals/config/types.d.ts +13 -3
- package/dist/globals/graphql/init.js +60 -2
- package/dist/globals/graphql/resolvers/findOne.js +2 -1
- package/dist/globals/graphql/resolvers/findVersionByID.d.ts +13 -0
- package/dist/globals/graphql/resolvers/findVersionByID.js +23 -0
- package/dist/globals/graphql/resolvers/findVersions.d.ts +3 -0
- package/dist/globals/graphql/resolvers/findVersions.js +35 -0
- package/dist/globals/graphql/resolvers/index.d.ts +4 -5
- package/dist/globals/graphql/resolvers/index.js +10 -5
- package/dist/globals/graphql/resolvers/restoreVersion.d.ts +3 -0
- package/dist/globals/graphql/resolvers/restoreVersion.js +18 -0
- package/dist/globals/graphql/resolvers/update.js +4 -3
- package/dist/globals/init.js +28 -1
- package/dist/globals/operations/findOne.js +39 -6
- package/dist/globals/operations/findVersionByID.d.ts +15 -0
- package/dist/globals/operations/findVersionByID.js +97 -0
- package/dist/globals/operations/findVersions.d.ts +18 -0
- package/dist/globals/operations/findVersions.js +110 -0
- package/dist/globals/operations/local/findOne.js +3 -2
- package/dist/globals/operations/local/update.js +3 -2
- package/dist/globals/operations/restoreVersion.d.ts +18 -0
- package/dist/globals/operations/restoreVersion.js +95 -0
- package/dist/globals/operations/update.d.ts +3 -1
- package/dist/globals/operations/update.js +93 -10
- package/dist/globals/requestHandlers/findOne.js +2 -1
- package/dist/globals/requestHandlers/findVersionByID.d.ts +3 -0
- package/dist/globals/requestHandlers/findVersionByID.js +23 -0
- package/dist/globals/requestHandlers/findVersions.d.ts +2 -0
- package/dist/globals/requestHandlers/findVersions.js +37 -0
- package/dist/globals/requestHandlers/restoreVersion.d.ts +2 -0
- package/dist/globals/requestHandlers/restoreVersion.js +31 -0
- package/dist/globals/requestHandlers/update.js +11 -2
- package/dist/graphql/bindResolvers.d.ts +12 -0
- package/dist/graphql/bindResolvers.js +13 -1
- package/dist/graphql/schema/buildPoliciesType.js +14 -3
- package/dist/graphql/schema/buildWhereInputType.js +7 -202
- package/dist/graphql/schema/fieldToSchemaMap.d.ts +2 -0
- package/dist/graphql/schema/fieldToSchemaMap.js +169 -0
- package/dist/graphql/schema/operators.d.ts +7 -0
- package/dist/graphql/schema/operators.js +10 -0
- package/dist/graphql/schema/recursivelyBuildNestedPaths.d.ts +3 -0
- package/dist/graphql/schema/recursivelyBuildNestedPaths.js +38 -0
- package/dist/index.d.ts +38 -8
- package/dist/index.js +33 -2
- package/dist/init/bindOperations.d.ts +64 -0
- package/dist/init/bindOperations.js +13 -1
- package/dist/init/bindRequestHandlers.d.ts +12 -0
- package/dist/init/bindRequestHandlers.js +13 -1
- package/dist/mongoose/buildSchema.d.ts +2 -2
- package/dist/mongoose/buildSchema.js +13 -13
- package/dist/mongoose/buildSortParam.d.ts +1 -0
- package/dist/mongoose/buildSortParam.js +27 -0
- package/dist/mongoose/types.d.ts +12 -0
- package/dist/mongoose/types.js +3 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +6 -1
- package/dist/{fields/baseFields/getBaseUploadFields.d.ts → uploads/getBaseFields.d.ts} +3 -3
- package/dist/{fields/baseFields/getBaseUploadFields.js → uploads/getBaseFields.js} +2 -2
- package/dist/uploads/uploadFile.d.ts +13 -0
- package/dist/uploads/uploadFile.js +70 -0
- package/dist/utilities/getUniqueListBy.d.ts +1 -0
- package/dist/utilities/getUniqueListBy.js +7 -0
- package/dist/versions/baseFields.d.ts +7 -0
- package/dist/versions/baseFields.js +29 -0
- package/dist/versions/buildCollectionFields.d.ts +3 -0
- package/dist/versions/buildCollectionFields.js +29 -0
- package/dist/versions/buildGlobalFields.d.ts +3 -0
- package/dist/versions/buildGlobalFields.js +23 -0
- package/dist/versions/cleanUpFailedVersion.d.ts +11 -0
- package/dist/versions/cleanUpFailedVersion.js +11 -0
- package/dist/versions/defaults.d.ts +3 -0
- package/dist/versions/defaults.js +19 -0
- package/dist/versions/drafts/appendVersionToQueryKey.d.ts +2 -0
- package/dist/versions/drafts/appendVersionToQueryKey.js +19 -0
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts +13 -0
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +66 -0
- package/dist/versions/drafts/saveCollectionDraft.d.ts +13 -0
- package/dist/versions/drafts/saveCollectionDraft.js +54 -0
- package/dist/versions/drafts/saveGlobalDraft.d.ts +10 -0
- package/dist/versions/drafts/saveGlobalDraft.js +49 -0
- package/dist/versions/enforceMaxVersions.d.ts +12 -0
- package/dist/versions/enforceMaxVersions.js +25 -0
- package/dist/versions/ensurePublishedCollectionVersion.d.ts +12 -0
- package/dist/versions/ensurePublishedCollectionVersion.js +62 -0
- package/dist/versions/ensurePublishedGlobalVersion.d.ts +11 -0
- package/dist/versions/ensurePublishedGlobalVersion.js +56 -0
- package/dist/versions/getVersionsModelName.d.ts +3 -0
- package/dist/versions/getVersionsModelName.js +6 -0
- package/dist/versions/saveCollectionVersion.d.ts +12 -0
- package/dist/versions/saveCollectionVersion.js +82 -0
- package/dist/versions/saveGlobalVersion.d.ts +11 -0
- package/dist/versions/saveGlobalVersion.js +76 -0
- package/dist/versions/shouldIncrementVersionCount.d.ts +14 -0
- package/dist/versions/shouldIncrementVersionCount.js +10 -0
- package/dist/versions/tests/collections-graphql.spec.d.ts +1 -0
- package/dist/versions/tests/collections-graphql.spec.js +141 -0
- package/dist/versions/tests/collections-rest.spec.d.ts +1 -0
- package/dist/versions/tests/collections-rest.spec.js +148 -0
- package/dist/versions/tests/globals-graphql.spec.d.ts +1 -0
- package/dist/versions/tests/globals-graphql.spec.js +157 -0
- package/dist/versions/tests/globals-rest.spec.d.ts +1 -0
- package/dist/versions/tests/globals-rest.spec.js +151 -0
- package/dist/versions/types.d.ts +34 -0
- package/dist/versions/types.js +3 -0
- package/dist/webpack/components.config.d.ts +2 -2
- package/dist/webpack/components.config.js +3 -3
- package/docs/access-control/globals.mdx +2 -2
- package/docs/admin/components.mdx +0 -1
- package/docs/admin/customizing-css.mdx +0 -2
- package/docs/admin/overview.mdx +0 -1
- package/docs/admin/webpack.mdx +0 -2
- package/docs/authentication/overview.mdx +0 -1
- package/docs/configuration/express.mdx +0 -2
- package/docs/configuration/localization.mdx +0 -1
- package/docs/configuration/overview.mdx +1 -2
- package/docs/getting-started/installation.mdx +2 -5
- package/docs/graphql/extending.mdx +0 -1
- package/docs/plugins/overview.mdx +0 -1
- package/docs/upload/overview.mdx +0 -1
- package/docs/versions/autosave.mdx +71 -0
- package/docs/versions/drafts.mdx +160 -0
- package/docs/versions/overview.mdx +140 -0
- package/package.json +13 -12
- package/dist/admin/components/elements/RenderTitle/index.scss +0 -12
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/SwapUploadModal/index.scss +0 -25
- package/dist/fields/baseFields/baseAPIKeyFields.js +0 -63
- package/dist/fields/baseFields/baseAccountLockFields.js +0 -16
- package/dist/fields/baseFields/baseAuthFields.js +0 -28
- package/dist/fields/baseFields/baseVerificationFields.js +0 -41
- package/docs/.DS_Store +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState, useReducer, } from 'react';
|
|
2
2
|
import { useConfig } from '@payloadcms/config-provider';
|
|
3
|
+
import qs from 'qs';
|
|
3
4
|
import withCondition from '../../withCondition';
|
|
4
5
|
import ReactSelect from '../../../elements/ReactSelect';
|
|
5
6
|
import useField from '../../useField';
|
|
@@ -10,6 +11,7 @@ import { relationship } from '../../../../../fields/validations';
|
|
|
10
11
|
import { useFormProcessing } from '../../Form/context';
|
|
11
12
|
import optionsReducer from './optionsReducer';
|
|
12
13
|
import useDebounce from '../../../../hooks/useDebounce';
|
|
14
|
+
import { createRelationMap } from './createRelationMap';
|
|
13
15
|
import './index.scss';
|
|
14
16
|
const maxResultsPerRequest = 10;
|
|
15
17
|
const baseClass = 'relationship';
|
|
@@ -29,21 +31,22 @@ const Relationship = (props) => {
|
|
|
29
31
|
const validationResult = validate(value, { required });
|
|
30
32
|
return validationResult;
|
|
31
33
|
}, [validate, required]);
|
|
32
|
-
const { value, showError, errorMessage, setValue, } = useField({
|
|
34
|
+
const { value, showError, errorMessage, setValue, initialValue, } = useField({
|
|
33
35
|
path: path || name,
|
|
34
36
|
validate: memoizedValidate,
|
|
35
37
|
condition,
|
|
36
38
|
});
|
|
37
|
-
const addOptions = useCallback((data, relation) => {
|
|
39
|
+
const addOptions = useCallback((data, relation, sort) => {
|
|
38
40
|
const collection = collections.find((coll) => coll.slug === relation);
|
|
39
|
-
dispatchOptions({ type: 'ADD', data, relation, hasMultipleRelations, collection });
|
|
41
|
+
dispatchOptions({ type: 'ADD', data, relation, hasMultipleRelations, collection, sort });
|
|
40
42
|
}, [collections, hasMultipleRelations]);
|
|
41
|
-
const getResults = useCallback(async ({ lastFullyLoadedRelation: lastFullyLoadedRelationArg, lastLoadedPage: lastLoadedPageArg, search: searchArg, }) => {
|
|
43
|
+
const getResults = useCallback(async ({ lastFullyLoadedRelation: lastFullyLoadedRelationArg, lastLoadedPage: lastLoadedPageArg, search: searchArg, value: valueArg, sort, }) => {
|
|
42
44
|
let lastLoadedPageToUse = typeof lastLoadedPageArg !== 'undefined' ? lastLoadedPageArg : 1;
|
|
43
45
|
const lastFullyLoadedRelationToUse = typeof lastFullyLoadedRelationArg !== 'undefined' ? lastFullyLoadedRelationArg : -1;
|
|
44
46
|
const relations = Array.isArray(relationTo) ? relationTo : [relationTo];
|
|
45
47
|
const relationsToFetch = lastFullyLoadedRelationToUse === -1 ? relations : relations.slice(lastFullyLoadedRelationToUse + 1);
|
|
46
48
|
let resultsFetched = 0;
|
|
49
|
+
const relationMap = createRelationMap({ hasMany, relationTo, value: valueArg });
|
|
47
50
|
if (!errorLoading) {
|
|
48
51
|
relationsToFetch.reduce(async (priorRelation, relation) => {
|
|
49
52
|
var _a;
|
|
@@ -51,13 +54,29 @@ const Relationship = (props) => {
|
|
|
51
54
|
if (resultsFetched < 10) {
|
|
52
55
|
const collection = collections.find((coll) => coll.slug === relation);
|
|
53
56
|
const fieldToSearch = ((_a = collection === null || collection === void 0 ? void 0 : collection.admin) === null || _a === void 0 ? void 0 : _a.useAsTitle) || 'id';
|
|
54
|
-
const
|
|
55
|
-
|
|
57
|
+
const query = {
|
|
58
|
+
where: {},
|
|
59
|
+
limit: maxResultsPerRequest,
|
|
60
|
+
page: lastLoadedPageToUse,
|
|
61
|
+
sort: fieldToSearch,
|
|
62
|
+
depth: 0,
|
|
63
|
+
};
|
|
64
|
+
if (searchArg) {
|
|
65
|
+
query.where[fieldToSearch] = {
|
|
66
|
+
like: searchArg,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
query.where.id = {
|
|
71
|
+
not_in: relationMap[relation],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(query)}`);
|
|
56
75
|
if (response.ok) {
|
|
57
76
|
const data = await response.json();
|
|
58
77
|
if (data.docs.length > 0) {
|
|
59
78
|
resultsFetched += data.docs.length;
|
|
60
|
-
addOptions(data, relation);
|
|
79
|
+
addOptions(data, relation, sort);
|
|
61
80
|
setLastLoadedPage(data.page);
|
|
62
81
|
if (!data.nextPage) {
|
|
63
82
|
setLastFullyLoadedRelation(relations.indexOf(relation));
|
|
@@ -75,7 +94,7 @@ const Relationship = (props) => {
|
|
|
75
94
|
}
|
|
76
95
|
}, Promise.resolve());
|
|
77
96
|
}
|
|
78
|
-
}, [addOptions, api, collections, serverURL, errorLoading, relationTo]);
|
|
97
|
+
}, [addOptions, api, collections, serverURL, errorLoading, relationTo, hasMany]);
|
|
79
98
|
const findOptionsByValue = useCallback(() => {
|
|
80
99
|
if (value) {
|
|
81
100
|
if (hasMany) {
|
|
@@ -126,18 +145,6 @@ const Relationship = (props) => {
|
|
|
126
145
|
setSearch(newSearch);
|
|
127
146
|
}
|
|
128
147
|
}, [search]);
|
|
129
|
-
const addOptionByID = useCallback(async (id, relation) => {
|
|
130
|
-
if (!errorLoading && id !== 'null' && id !== null) {
|
|
131
|
-
const response = await fetch(`${serverURL}${api}/${relation}/${id}?depth=0`);
|
|
132
|
-
if (response.ok) {
|
|
133
|
-
const data = await response.json();
|
|
134
|
-
addOptions({ docs: [data] }, relation);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
console.error(`There was a problem loading the document with ID of ${id}.`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, [addOptions, api, errorLoading, serverURL]);
|
|
141
148
|
// ///////////////////////////
|
|
142
149
|
// Get results when search input changes
|
|
143
150
|
// ///////////////////////////
|
|
@@ -146,43 +153,50 @@ const Relationship = (props) => {
|
|
|
146
153
|
type: 'CLEAR',
|
|
147
154
|
required,
|
|
148
155
|
});
|
|
149
|
-
setHasLoadedFirstOptions(true);
|
|
150
156
|
setLastLoadedPage(1);
|
|
151
157
|
setLastFullyLoadedRelation(-1);
|
|
152
|
-
getResults({ search: debouncedSearch });
|
|
153
|
-
}, [getResults, debouncedSearch, relationTo, required]);
|
|
158
|
+
getResults({ search: debouncedSearch, value: initialValue, sort: true });
|
|
159
|
+
}, [getResults, debouncedSearch, relationTo, required, initialValue]);
|
|
154
160
|
// ///////////////////////////
|
|
155
|
-
//
|
|
161
|
+
// Fetch value options when initialValue changes
|
|
156
162
|
// ///////////////////////////
|
|
157
163
|
useEffect(() => {
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
if (initialValue && !hasLoadedFirstOptions) {
|
|
165
|
+
const relationMap = createRelationMap({
|
|
166
|
+
hasMany,
|
|
167
|
+
relationTo,
|
|
168
|
+
value: initialValue,
|
|
169
|
+
});
|
|
170
|
+
Object.entries(relationMap).reduce(async (priorRelation, [relation, ids]) => {
|
|
171
|
+
await priorRelation;
|
|
172
|
+
if (ids.length > 0) {
|
|
173
|
+
const query = {
|
|
174
|
+
where: {
|
|
175
|
+
id: {
|
|
176
|
+
in: ids,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
depth: 0,
|
|
180
|
+
limit: ids.length,
|
|
181
|
+
};
|
|
182
|
+
if (!errorLoading) {
|
|
183
|
+
const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(query)}`);
|
|
184
|
+
if (response.ok) {
|
|
185
|
+
const data = await response.json();
|
|
186
|
+
addOptions({ docs: data.docs }, relation, true);
|
|
165
187
|
}
|
|
166
188
|
else {
|
|
167
|
-
|
|
189
|
+
console.error(`There was a problem loading relationships to related collection ${relation}.`);
|
|
168
190
|
}
|
|
169
191
|
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
const matchedOption = findOptionsByValue();
|
|
174
|
-
if (!matchedOption) {
|
|
175
|
-
if (hasMultipleRelations) {
|
|
176
|
-
const valueWithRelation = value;
|
|
177
|
-
addOptionByID(valueWithRelation.value, valueWithRelation.relationTo);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
addOptionByID(value, relationTo);
|
|
181
|
-
}
|
|
182
192
|
}
|
|
183
|
-
}
|
|
193
|
+
}, Promise.resolve());
|
|
194
|
+
setHasLoadedFirstOptions(true);
|
|
184
195
|
}
|
|
185
|
-
}, [
|
|
196
|
+
}, [hasMany, hasMultipleRelations, relationTo, initialValue, hasLoadedFirstOptions, errorLoading, addOptions, api, serverURL]);
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
setHasLoadedFirstOptions(false);
|
|
199
|
+
}, [initialValue]);
|
|
186
200
|
const classes = [
|
|
187
201
|
'field-type',
|
|
188
202
|
baseClass,
|
|
@@ -220,7 +234,13 @@ const Relationship = (props) => {
|
|
|
220
234
|
setValue(selected.value);
|
|
221
235
|
}
|
|
222
236
|
} : undefined, onMenuScrollToBottom: () => {
|
|
223
|
-
getResults({
|
|
237
|
+
getResults({
|
|
238
|
+
lastFullyLoadedRelation,
|
|
239
|
+
lastLoadedPage: lastLoadedPage + 1,
|
|
240
|
+
search,
|
|
241
|
+
value: initialValue,
|
|
242
|
+
sort: false,
|
|
243
|
+
});
|
|
224
244
|
}, value: valueToRender, showError: showError, disabled: formProcessing, options: options, isMulti: hasMany })),
|
|
225
245
|
errorLoading && (React.createElement("div", { className: `${baseClass}__error-loading` }, errorLoading)),
|
|
226
246
|
React.createElement(FieldDescription, { value: value, description: description })));
|
|
@@ -10,17 +10,24 @@ const reduceToIDs = (options) => options.reduce((ids, option) => {
|
|
|
10
10
|
option.value,
|
|
11
11
|
];
|
|
12
12
|
}, []);
|
|
13
|
+
const sortOptions = (options) => options.sort((a, b) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if (typeof ((_a = a === null || a === void 0 ? void 0 : a.label) === null || _a === void 0 ? void 0 : _a.localeCompare) === 'function' && typeof ((_b = b === null || b === void 0 ? void 0 : b.label) === null || _b === void 0 ? void 0 : _b.localeCompare) === 'function') {
|
|
16
|
+
return a.label.localeCompare(b.label);
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
});
|
|
13
20
|
const optionsReducer = (state, action) => {
|
|
14
21
|
switch (action.type) {
|
|
15
22
|
case 'CLEAR': {
|
|
16
23
|
return action.required ? [] : [{ value: 'null', label: 'None' }];
|
|
17
24
|
}
|
|
18
25
|
case 'ADD': {
|
|
19
|
-
const { hasMultipleRelations, collection, relation, data } = action;
|
|
26
|
+
const { hasMultipleRelations, collection, relation, data, sort } = action;
|
|
20
27
|
const labelKey = collection.admin.useAsTitle || 'id';
|
|
21
28
|
const loadedIDs = reduceToIDs(state);
|
|
22
29
|
if (!hasMultipleRelations) {
|
|
23
|
-
|
|
30
|
+
const options = [
|
|
24
31
|
...state,
|
|
25
32
|
...data.docs.reduce((docs, doc) => {
|
|
26
33
|
if (loadedIDs.indexOf(doc.id) === -1) {
|
|
@@ -28,7 +35,7 @@ const optionsReducer = (state, action) => {
|
|
|
28
35
|
return [
|
|
29
36
|
...docs,
|
|
30
37
|
{
|
|
31
|
-
label: doc[labelKey]
|
|
38
|
+
label: doc[labelKey] || `Untitled - ID: ${doc.id}`,
|
|
32
39
|
value: doc.id,
|
|
33
40
|
},
|
|
34
41
|
];
|
|
@@ -36,6 +43,7 @@ const optionsReducer = (state, action) => {
|
|
|
36
43
|
return docs;
|
|
37
44
|
}, []),
|
|
38
45
|
];
|
|
46
|
+
return sort ? sortOptions(options) : options;
|
|
39
47
|
}
|
|
40
48
|
const newOptions = [...state];
|
|
41
49
|
const optionsToAddTo = newOptions.find((optionGroup) => optionGroup.label === collection.labels.plural);
|
|
@@ -45,7 +53,7 @@ const optionsReducer = (state, action) => {
|
|
|
45
53
|
return [
|
|
46
54
|
...docs,
|
|
47
55
|
{
|
|
48
|
-
label: doc[labelKey]
|
|
56
|
+
label: doc[labelKey] || `Untitled - ID: ${doc.id}`,
|
|
49
57
|
relationTo: relation,
|
|
50
58
|
value: doc.id,
|
|
51
59
|
},
|
|
@@ -54,15 +62,16 @@ const optionsReducer = (state, action) => {
|
|
|
54
62
|
return docs;
|
|
55
63
|
}, []);
|
|
56
64
|
if (optionsToAddTo) {
|
|
57
|
-
|
|
65
|
+
const subOptions = [
|
|
58
66
|
...optionsToAddTo.options,
|
|
59
67
|
...newSubOptions,
|
|
60
68
|
];
|
|
69
|
+
optionsToAddTo.options = sort ? sortOptions(subOptions) : subOptions;
|
|
61
70
|
}
|
|
62
71
|
else {
|
|
63
72
|
newOptions.push({
|
|
64
73
|
label: collection.labels.plural,
|
|
65
|
-
options: newSubOptions,
|
|
74
|
+
options: sort ? sortOptions(newSubOptions) : newSubOptions,
|
|
66
75
|
value: undefined,
|
|
67
76
|
});
|
|
68
77
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SanitizedCollectionConfig } from '../../../../../collections/config/types';
|
|
2
|
+
import { PaginatedDocs } from '../../../../../mongoose/types';
|
|
2
3
|
import { RelationshipField } from '../../../../../fields/config/types';
|
|
3
4
|
export declare type Props = Omit<RelationshipField, 'type'> & {
|
|
4
5
|
path?: string;
|
|
@@ -19,10 +20,18 @@ declare type ADD = {
|
|
|
19
20
|
relation: string;
|
|
20
21
|
hasMultipleRelations: boolean;
|
|
21
22
|
collection: SanitizedCollectionConfig;
|
|
23
|
+
sort?: boolean;
|
|
22
24
|
};
|
|
23
25
|
export declare type Action = CLEAR | ADD;
|
|
24
26
|
export declare type ValueWithRelation = {
|
|
25
27
|
relationTo: string;
|
|
26
28
|
value: string;
|
|
27
29
|
};
|
|
30
|
+
export declare type GetResults = (args: {
|
|
31
|
+
lastFullyLoadedRelation?: number;
|
|
32
|
+
lastLoadedPage?: number;
|
|
33
|
+
search?: string;
|
|
34
|
+
value?: unknown;
|
|
35
|
+
sort?: boolean;
|
|
36
|
+
}) => Promise<void>;
|
|
28
37
|
export {};
|
|
@@ -32,6 +32,7 @@ const RichText = (props) => {
|
|
|
32
32
|
const [loaded, setLoaded] = useState(false);
|
|
33
33
|
const [enabledElements, setEnabledElements] = useState({});
|
|
34
34
|
const [enabledLeaves, setEnabledLeaves] = useState({});
|
|
35
|
+
const [initialValueKey, setInitialValueKey] = useState('');
|
|
35
36
|
const renderElement = useCallback(({ attributes, children, element }) => {
|
|
36
37
|
const matchedElement = enabledElements[element === null || element === void 0 ? void 0 : element.type];
|
|
37
38
|
const Element = matchedElement === null || matchedElement === void 0 ? void 0 : matchedElement.Element;
|
|
@@ -58,7 +59,7 @@ const RichText = (props) => {
|
|
|
58
59
|
validate: memoizedValidate,
|
|
59
60
|
condition,
|
|
60
61
|
});
|
|
61
|
-
const { value, showError, setValue, errorMessage, } = fieldType;
|
|
62
|
+
const { value, showError, setValue, errorMessage, initialValue, } = fieldType;
|
|
62
63
|
const classes = [
|
|
63
64
|
baseClass,
|
|
64
65
|
'field-type',
|
|
@@ -85,6 +86,9 @@ const RichText = (props) => {
|
|
|
85
86
|
setLoaded(true);
|
|
86
87
|
}
|
|
87
88
|
}, [loaded, elements, leaves]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
setInitialValueKey(JSON.stringify(initialValue || ''));
|
|
91
|
+
}, [initialValue]);
|
|
88
92
|
if (!loaded) {
|
|
89
93
|
return null;
|
|
90
94
|
}
|
|
@@ -100,7 +104,7 @@ const RichText = (props) => {
|
|
|
100
104
|
}
|
|
101
105
|
if (!valueToRender)
|
|
102
106
|
valueToRender = defaultValue;
|
|
103
|
-
return (React.createElement("div", { className: classes, style: {
|
|
107
|
+
return (React.createElement("div", { key: initialValueKey, className: classes, style: {
|
|
104
108
|
...style,
|
|
105
109
|
width,
|
|
106
110
|
} },
|
|
@@ -16,7 +16,7 @@ import MinimalTemplate from '../../../../../../templates/Minimal';
|
|
|
16
16
|
import Button from '../../../../../../elements/Button';
|
|
17
17
|
import PerPage from '../../../../../../elements/PerPage';
|
|
18
18
|
import './index.scss';
|
|
19
|
-
import '../
|
|
19
|
+
import '../addSwapModals.scss';
|
|
20
20
|
const baseClass = 'upload-rich-text-button';
|
|
21
21
|
const baseModalClass = 'rich-text-upload-modal';
|
|
22
22
|
const insertUpload = (editor, { value, relationTo }) => {
|
|
@@ -37,6 +37,7 @@ const insertUpload = (editor, { value, relationTo }) => {
|
|
|
37
37
|
ReactEditor.focus(editor);
|
|
38
38
|
};
|
|
39
39
|
const UploadButton = ({ path }) => {
|
|
40
|
+
var _a, _b;
|
|
40
41
|
const { open, closeAll, currentModal } = useModal();
|
|
41
42
|
const editor = useSlate();
|
|
42
43
|
const { serverURL, routes: { api }, collections } = useConfig();
|
|
@@ -132,6 +133,6 @@ const UploadButton = ({ path }) => {
|
|
|
132
133
|
"of",
|
|
133
134
|
' ',
|
|
134
135
|
data.totalDocs),
|
|
135
|
-
React.createElement(PerPage, {
|
|
136
|
+
React.createElement(PerPage, { limits: (_b = (_a = modalCollection === null || modalCollection === void 0 ? void 0 : modalCollection.admin) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.limits, limit: limit, modifySearchParams: false, handleChange: setLimit }))))))))));
|
|
136
137
|
};
|
|
137
138
|
export default UploadButton;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Element } from 'slate';
|
|
3
3
|
import { SanitizedCollectionConfig } from '../../../../../../../../../collections/config/types';
|
|
4
|
-
import '
|
|
4
|
+
import '../../addSwapModals.scss';
|
|
5
5
|
declare type Props = {
|
|
6
6
|
slug: string;
|
|
7
7
|
element: Element;
|
|
@@ -13,9 +13,10 @@ import UploadGallery from '../../../../../../../elements/UploadGallery';
|
|
|
13
13
|
import Paginator from '../../../../../../../elements/Paginator';
|
|
14
14
|
import PerPage from '../../../../../../../elements/PerPage';
|
|
15
15
|
import formatFields from '../../../../../../../views/collections/List/formatFields';
|
|
16
|
-
import '
|
|
17
|
-
const baseClass = '
|
|
16
|
+
import '../../addSwapModals.scss';
|
|
17
|
+
const baseClass = 'rich-text-upload-modal';
|
|
18
18
|
export const SwapUploadModal = ({ closeModal, element, setRelatedCollectionConfig, relatedCollectionConfig, slug }) => {
|
|
19
|
+
var _a, _b;
|
|
19
20
|
const { collections, serverURL, routes: { api } } = useConfig();
|
|
20
21
|
const editor = useSlateStatic();
|
|
21
22
|
const [modalCollection, setModalCollection] = React.useState(relatedCollectionConfig);
|
|
@@ -92,5 +93,5 @@ export const SwapUploadModal = ({ closeModal, element, setRelatedCollectionConfi
|
|
|
92
93
|
"of",
|
|
93
94
|
' ',
|
|
94
95
|
data.totalDocs),
|
|
95
|
-
React.createElement(PerPage, {
|
|
96
|
+
React.createElement(PerPage, { limits: (_b = (_a = modalCollection === null || modalCollection === void 0 ? void 0 : modalCollection.admin) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.limits, limit: limit, modifySearchParams: false, handleChange: setLimit })))))));
|
|
96
97
|
};
|
|
@@ -8,8 +8,8 @@ import FileGraphic from '../../../../../../graphics/File';
|
|
|
8
8
|
import useThumbnail from '../../../../../../../hooks/useThumbnail';
|
|
9
9
|
import Button from '../../../../../../elements/Button';
|
|
10
10
|
import { SwapUploadModal } from './SwapUploadModal';
|
|
11
|
-
import './index.scss';
|
|
12
11
|
import { EditModal } from './EditModal';
|
|
12
|
+
import './index.scss';
|
|
13
13
|
const baseClass = 'rich-text-upload';
|
|
14
14
|
const initialParams = {
|
|
15
15
|
depth: 0,
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import withCondition from '../../withCondition';
|
|
3
3
|
import useField from '../../useField';
|
|
4
4
|
import { select } from '../../../../../fields/validations';
|
|
@@ -15,7 +15,10 @@ const formatOptions = (options) => options.map((option) => {
|
|
|
15
15
|
const Select = (props) => {
|
|
16
16
|
const { path: pathFromProps, name, required, validate = select, label, options: optionsFromProps, hasMany, admin: { readOnly, style, className, width, description, condition, } = {}, } = props;
|
|
17
17
|
const path = pathFromProps || name;
|
|
18
|
-
const [options] = useState(formatOptions(optionsFromProps));
|
|
18
|
+
const [options, setOptions] = useState(formatOptions(optionsFromProps));
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setOptions(formatOptions(optionsFromProps));
|
|
21
|
+
}, [optionsFromProps]);
|
|
19
22
|
const memoizedValidate = useCallback((value) => {
|
|
20
23
|
const validationResult = validate(value, { required, options });
|
|
21
24
|
return validationResult;
|
|
@@ -12,6 +12,7 @@ import formatFields from '../../../../views/collections/List/formatFields';
|
|
|
12
12
|
import './index.scss';
|
|
13
13
|
const baseClass = 'select-existing-upload-modal';
|
|
14
14
|
const SelectExistingUploadModal = (props) => {
|
|
15
|
+
var _a, _b;
|
|
15
16
|
const { setValue, collection, collection: { slug: collectionSlug, admin: { description, pagination: { defaultLimit, }, } = {}, } = {}, slug: modalSlug, } = props;
|
|
16
17
|
const { serverURL, routes: { api } } = useConfig();
|
|
17
18
|
const { closeAll, currentModal } = useModal();
|
|
@@ -67,6 +68,6 @@ const SelectExistingUploadModal = (props) => {
|
|
|
67
68
|
"of",
|
|
68
69
|
' ',
|
|
69
70
|
data.totalDocs),
|
|
70
|
-
React.createElement(PerPage, { collection: collection, limit: limit, modifySearchParams: false, handleChange: setLimit }))))))));
|
|
71
|
+
React.createElement(PerPage, { limits: (_b = (_a = collection === null || collection === void 0 ? void 0 : collection.admin) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.limits, limit: limit, modifySearchParams: false, handleChange: setLimit }))))))));
|
|
71
72
|
};
|
|
72
73
|
export default SelectExistingUploadModal;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type: 'collection';
|
|
4
|
-
slug: string;
|
|
5
|
-
id?: string;
|
|
6
|
-
};
|
|
7
|
-
declare type GlobalDoc = {
|
|
8
|
-
type: 'global';
|
|
9
|
-
slug: string;
|
|
10
|
-
};
|
|
11
|
-
declare type ContextType = (CollectionDoc | GlobalDoc) & {
|
|
12
|
-
preferencesKey?: string;
|
|
13
|
-
};
|
|
2
|
+
import { ContextType, Props } from './types';
|
|
14
3
|
declare const Context: React.Context<ContextType>;
|
|
15
|
-
export declare const DocumentInfoProvider: React.FC<
|
|
4
|
+
export declare const DocumentInfoProvider: React.FC<Props>;
|
|
16
5
|
export declare const useDocumentInfo: () => ContextType;
|
|
17
6
|
export default Context;
|
|
@@ -1,27 +1,136 @@
|
|
|
1
|
-
import React, { createContext, useContext, } from 'react';
|
|
1
|
+
import React, { createContext, useCallback, useContext, useEffect, useState, } from 'react';
|
|
2
|
+
import { useConfig } from '@payloadcms/config-provider';
|
|
3
|
+
import qs from 'qs';
|
|
2
4
|
const Context = createContext({});
|
|
3
|
-
export const DocumentInfoProvider = (
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const DocumentInfoProvider = ({ children, global, collection, id, }) => {
|
|
6
|
+
const { serverURL, routes: { api } } = useConfig();
|
|
7
|
+
const [publishedDoc, setPublishedDoc] = useState(null);
|
|
8
|
+
const [versions, setVersions] = useState(null);
|
|
9
|
+
const [unpublishedVersions, setUnpublishedVersions] = useState(null);
|
|
10
|
+
const baseURL = `${serverURL}${api}`;
|
|
11
|
+
let slug;
|
|
12
|
+
let type;
|
|
13
|
+
let preferencesKey;
|
|
14
|
+
if (global) {
|
|
15
|
+
slug = global.slug;
|
|
16
|
+
type = 'global';
|
|
17
|
+
preferencesKey = `global-${slug}`;
|
|
11
18
|
}
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type,
|
|
16
|
-
slug,
|
|
17
|
-
};
|
|
19
|
+
if (collection) {
|
|
20
|
+
slug = collection.slug;
|
|
21
|
+
type = 'collection';
|
|
18
22
|
if (id) {
|
|
19
|
-
|
|
20
|
-
value.preferencesKey = `collection-${slug}-${id}`;
|
|
23
|
+
preferencesKey = `collection-${slug}-${id}`;
|
|
21
24
|
}
|
|
22
|
-
return (React.createElement(Context.Provider, { value: value }, children));
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
const getVersions = useCallback(async () => {
|
|
27
|
+
var _a;
|
|
28
|
+
let versionFetchURL;
|
|
29
|
+
let publishedFetchURL;
|
|
30
|
+
let shouldFetchVersions = false;
|
|
31
|
+
let unpublishedVersionJSON = null;
|
|
32
|
+
let versionJSON = null;
|
|
33
|
+
let shouldFetch = true;
|
|
34
|
+
const versionParams = {
|
|
35
|
+
where: {
|
|
36
|
+
and: [],
|
|
37
|
+
},
|
|
38
|
+
depth: 0,
|
|
39
|
+
};
|
|
40
|
+
const publishedVersionParams = {
|
|
41
|
+
where: {
|
|
42
|
+
and: [
|
|
43
|
+
{
|
|
44
|
+
or: [
|
|
45
|
+
{
|
|
46
|
+
_status: {
|
|
47
|
+
equals: 'published',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
_status: {
|
|
52
|
+
exists: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
depth: 0,
|
|
60
|
+
};
|
|
61
|
+
if (global) {
|
|
62
|
+
shouldFetchVersions = Boolean(global === null || global === void 0 ? void 0 : global.versions);
|
|
63
|
+
versionFetchURL = `${baseURL}/globals/${global.slug}/versions`;
|
|
64
|
+
publishedFetchURL = `${baseURL}/globals/${global.slug}?${qs.stringify(publishedVersionParams)}`;
|
|
65
|
+
}
|
|
66
|
+
if (collection) {
|
|
67
|
+
shouldFetchVersions = Boolean(collection === null || collection === void 0 ? void 0 : collection.versions);
|
|
68
|
+
versionFetchURL = `${baseURL}/${collection.slug}/versions`;
|
|
69
|
+
publishedVersionParams.where.and.push({
|
|
70
|
+
id: {
|
|
71
|
+
equals: id,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
publishedFetchURL = `${baseURL}/${collection.slug}?${qs.stringify(publishedVersionParams)}`;
|
|
75
|
+
if (!id) {
|
|
76
|
+
shouldFetch = false;
|
|
77
|
+
}
|
|
78
|
+
versionParams.where.and.push({
|
|
79
|
+
parent: {
|
|
80
|
+
equals: id,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (shouldFetch) {
|
|
85
|
+
let publishedJSON = await fetch(publishedFetchURL).then((res) => res.json());
|
|
86
|
+
if (collection) {
|
|
87
|
+
publishedJSON = (_a = publishedJSON === null || publishedJSON === void 0 ? void 0 : publishedJSON.docs) === null || _a === void 0 ? void 0 : _a[0];
|
|
88
|
+
}
|
|
89
|
+
if (shouldFetchVersions) {
|
|
90
|
+
versionJSON = await fetch(`${versionFetchURL}?${qs.stringify(versionParams)}`).then((res) => res.json());
|
|
91
|
+
if (publishedJSON === null || publishedJSON === void 0 ? void 0 : publishedJSON.updatedAt) {
|
|
92
|
+
const newerVersionParams = {
|
|
93
|
+
...versionParams,
|
|
94
|
+
where: {
|
|
95
|
+
...versionParams.where,
|
|
96
|
+
and: [
|
|
97
|
+
...versionParams.where.and,
|
|
98
|
+
{
|
|
99
|
+
updatedAt: {
|
|
100
|
+
greater_than: publishedJSON === null || publishedJSON === void 0 ? void 0 : publishedJSON.updatedAt,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
// Get any newer versions available
|
|
107
|
+
const newerVersionRes = await fetch(`${versionFetchURL}?${qs.stringify(newerVersionParams)}`);
|
|
108
|
+
if (newerVersionRes.status === 200) {
|
|
109
|
+
unpublishedVersionJSON = await newerVersionRes.json();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
setPublishedDoc(publishedJSON);
|
|
114
|
+
setVersions(versionJSON);
|
|
115
|
+
setUnpublishedVersions(unpublishedVersionJSON);
|
|
116
|
+
}
|
|
117
|
+
}, [global, collection, id, baseURL]);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
getVersions();
|
|
120
|
+
}, [getVersions]);
|
|
121
|
+
const value = {
|
|
122
|
+
slug,
|
|
123
|
+
type,
|
|
124
|
+
preferencesKey,
|
|
125
|
+
global,
|
|
126
|
+
collection,
|
|
127
|
+
versions,
|
|
128
|
+
unpublishedVersions,
|
|
129
|
+
getVersions,
|
|
130
|
+
publishedDoc,
|
|
131
|
+
id,
|
|
132
|
+
};
|
|
133
|
+
return (React.createElement(Context.Provider, { value: value }, children));
|
|
25
134
|
};
|
|
26
135
|
export const useDocumentInfo = () => useContext(Context);
|
|
27
136
|
export default Context;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SanitizedCollectionConfig, TypeWithID, TypeWithTimestamps } from '../../../../collections/config/types';
|
|
2
|
+
import { SanitizedGlobalConfig } from '../../../../globals/config/types';
|
|
3
|
+
import { PaginatedDocs } from '../../../../mongoose/types';
|
|
4
|
+
import { TypeWithVersion } from '../../../../versions/types';
|
|
5
|
+
export declare type Version = TypeWithVersion<any>;
|
|
6
|
+
export declare type ContextType = {
|
|
7
|
+
collection?: SanitizedCollectionConfig;
|
|
8
|
+
global?: SanitizedGlobalConfig;
|
|
9
|
+
type: 'global' | 'collection';
|
|
10
|
+
id?: string | number;
|
|
11
|
+
preferencesKey?: string;
|
|
12
|
+
versions?: PaginatedDocs<Version>;
|
|
13
|
+
unpublishedVersions?: PaginatedDocs<Version>;
|
|
14
|
+
publishedDoc?: TypeWithID & TypeWithTimestamps & {
|
|
15
|
+
_status?: string;
|
|
16
|
+
};
|
|
17
|
+
getVersions: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export declare type Props = {
|
|
20
|
+
collection?: SanitizedCollectionConfig;
|
|
21
|
+
global?: SanitizedGlobalConfig;
|
|
22
|
+
id?: string | number;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|