@nocobase/client 0.9.3-alpha.1 → 0.9.4-alpha.2
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/es/acl/ACLProvider.js +2 -2
- package/es/acl/Configuration/RoleConfigure.js +15 -8
- package/es/api-client/APIClient.d.ts +2 -0
- package/es/api-client/APIClient.js +11 -0
- package/es/block-provider/BlockProvider.js +58 -17
- package/es/block-provider/hooks/index.js +81 -60
- package/es/collection-manager/CollectionField.js +3 -3
- package/es/collection-manager/CollectionFieldProvider.js +2 -1
- package/es/collection-manager/Configuration/AddFieldAction.js +3 -3
- package/es/collection-manager/Configuration/CollectionFields.d.ts +1 -1
- package/es/collection-manager/Configuration/CollectionFields.js +1 -3
- package/es/collection-manager/Configuration/ConfigurationTabs.js +7 -6
- package/es/collection-manager/hooks/useCollection.d.ts +1 -1
- package/es/collection-manager/hooks/useCollectionDataSource.js +4 -4
- package/es/collection-manager/interfaces/m2m.js +1 -1
- package/es/collection-manager/interfaces/m2o.js +1 -1
- package/es/collection-manager/interfaces/o2m.js +1 -1
- package/es/collection-manager/interfaces/o2o.js +2 -2
- package/es/collection-manager/templates/expression.js +1 -1
- package/es/filter-provider/utils.js +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/locale/en_US.d.ts +16 -1
- package/es/locale/en_US.js +17 -2
- package/es/locale/es_ES.d.ts +692 -0
- package/es/locale/es_ES.js +691 -0
- package/es/locale/ja_JP.d.ts +5 -1
- package/es/locale/ja_JP.js +6 -2
- package/es/locale/pt_BR.d.ts +5 -1
- package/es/locale/pt_BR.js +6 -2
- package/es/locale/ru_RU.d.ts +5 -1
- package/es/locale/ru_RU.js +6 -2
- package/es/locale/tr_TR.d.ts +5 -1
- package/es/locale/tr_TR.js +6 -2
- package/es/locale/zh_CN.d.ts +25 -2
- package/es/locale/zh_CN.js +26 -3
- package/es/pm/PluginManagerLink.js +22 -14
- package/es/record-provider/index.d.ts +4 -0
- package/es/record-provider/index.js +3 -0
- package/es/schema-component/antd/action/Action.Designer.js +6 -3
- package/es/schema-component/antd/action/Action.Drawer.js +5 -2
- package/es/schema-component/antd/action/Action.js +2 -2
- package/es/schema-component/antd/action/ActionBar.js +25 -18
- package/es/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -2
- package/es/schema-component/antd/association-field/AssociationFieldProvider.js +62 -9
- package/es/schema-component/antd/association-field/AssociationSelect.js +10 -65
- package/es/schema-component/antd/association-field/Editable.d.ts +1 -1
- package/es/schema-component/antd/association-field/Editable.js +32 -40
- package/es/schema-component/antd/association-field/InternalNester.js +4 -3
- package/es/schema-component/antd/association-field/InternalPicker.js +29 -60
- package/es/schema-component/antd/association-field/InternalViewer.js +9 -12
- package/es/schema-component/antd/association-field/Nester.js +19 -21
- package/es/schema-component/antd/association-field/ReadPretty.d.ts +1 -1
- package/es/schema-component/antd/association-field/ReadPretty.js +9 -25
- package/es/schema-component/antd/association-field/components/CreateRecordAction.d.ts +2 -0
- package/es/schema-component/antd/association-field/components/CreateRecordAction.js +61 -0
- package/es/schema-component/antd/association-field/context.d.ts +5 -2
- package/es/schema-component/antd/association-field/context.js +1 -1
- package/es/schema-component/antd/association-field/hooks.d.ts +3 -0
- package/es/schema-component/antd/association-field/hooks.js +10 -10
- package/es/schema-component/antd/association-filter/AssociationFilter.Item.js +3 -3
- package/es/schema-component/antd/association-select/AssociationSelect.js +49 -231
- package/es/schema-component/antd/association-select/useServiceOptions.js +2 -2
- package/es/schema-component/antd/collection-select/CollectionSelect.js +5 -0
- package/es/schema-component/antd/filter/FilterAction.js +2 -2
- package/es/schema-component/antd/form/Form.js +4 -4
- package/es/schema-component/antd/form-item/FormItem.js +126 -145
- package/es/schema-component/antd/form-item/SchemaSettingOptions.js +3 -3
- package/es/schema-component/antd/form-v2/Form.Designer.js +1 -0
- package/es/schema-component/antd/form-v2/Templates.d.ts +20 -0
- package/es/schema-component/antd/form-v2/Templates.js +42 -12
- package/es/schema-component/antd/grid/Grid.js +34 -24
- package/es/schema-component/antd/grid-card/GridCard.Decorator.d.ts +5 -0
- package/es/schema-component/antd/grid-card/GridCard.Decorator.js +65 -0
- package/es/schema-component/antd/grid-card/GridCard.Designer.d.ts +1 -0
- package/es/schema-component/antd/grid-card/GridCard.Designer.js +243 -0
- package/es/schema-component/antd/grid-card/GridCard.Item.d.ts +1 -0
- package/es/schema-component/antd/grid-card/GridCard.Item.js +18 -0
- package/es/schema-component/antd/grid-card/GridCard.d.ts +8 -0
- package/es/schema-component/antd/grid-card/GridCard.js +103 -0
- package/es/schema-component/antd/grid-card/hooks.d.ts +4 -0
- package/es/schema-component/antd/grid-card/hooks.js +9 -0
- package/es/schema-component/antd/grid-card/index.d.ts +1 -0
- package/es/schema-component/antd/grid-card/index.js +1 -0
- package/es/schema-component/antd/grid-card/options.d.ts +20 -0
- package/es/schema-component/antd/grid-card/options.js +20 -0
- package/es/schema-component/antd/icon-picker/IconPicker.js +2 -2
- package/es/schema-component/antd/index.d.ts +2 -0
- package/es/schema-component/antd/index.js +2 -0
- package/es/schema-component/antd/input/EllipsisWithTooltip.js +2 -2
- package/es/schema-component/antd/list/List.Decorator.d.ts +5 -0
- package/es/schema-component/antd/list/List.Decorator.js +59 -0
- package/es/schema-component/antd/list/List.Designer.d.ts +1 -0
- package/es/schema-component/antd/list/List.Designer.js +205 -0
- package/es/schema-component/antd/list/List.Item.d.ts +1 -0
- package/es/schema-component/antd/list/List.Item.js +15 -0
- package/es/schema-component/antd/list/List.d.ts +8 -0
- package/es/schema-component/antd/list/List.js +83 -0
- package/es/schema-component/antd/list/hooks.d.ts +4 -0
- package/es/schema-component/antd/list/hooks.js +9 -0
- package/es/schema-component/antd/list/index.d.ts +1 -0
- package/es/schema-component/antd/list/index.js +1 -0
- package/es/schema-component/antd/remote-select/RemoteSelect.js +12 -10
- package/es/schema-component/antd/select/Select.js +15 -4
- package/es/schema-component/antd/table/Table.Void.Designer.js +1 -0
- package/es/schema-component/antd/table-v2/TableBlockDesigner.js +2 -1
- package/es/schema-component/antd/table-v2/TableSelectorDesigner.js +1 -0
- package/es/schema-component/antd/table-v2/hooks/useUserVariable.d.ts +22 -0
- package/es/schema-component/antd/table-v2/hooks/useUserVariable.js +65 -0
- package/es/schema-component/antd/variable/Input.js +6 -3
- package/es/schema-component/common/dnd-context/index.js +2 -2
- package/es/schema-component/common/sortable-item/SortableItem.js +3 -4
- package/es/schema-component/core/SchemaComponentProvider.js +2 -2
- package/es/schema-initializer/SchemaInitializerProvider.d.ts +1 -0
- package/es/schema-initializer/SchemaInitializerProvider.js +23 -10
- package/es/schema-initializer/buttons/BlockInitializers.js +10 -0
- package/es/schema-initializer/buttons/CustomFormItemInitializers.js +4 -2
- package/es/schema-initializer/buttons/FormActionInitializers.d.ts +0 -116
- package/es/schema-initializer/buttons/FormActionInitializers.js +106 -100
- package/es/schema-initializer/buttons/GanttActionInitializers.d.ts +0 -19
- package/es/schema-initializer/buttons/GridCardActionInitializers.d.ts +195 -0
- package/es/schema-initializer/buttons/GridCardActionInitializers.js +278 -0
- package/es/schema-initializer/buttons/ListActionInitializers.d.ts +195 -0
- package/es/schema-initializer/buttons/ListActionInitializers.js +278 -0
- package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
- package/es/schema-initializer/buttons/TableActionInitializers.d.ts +0 -20
- package/es/schema-initializer/buttons/TableActionInitializers.js +29 -35
- package/es/schema-initializer/buttons/TableColumnInitializers.js +4 -1
- package/es/schema-initializer/buttons/index.d.ts +3 -0
- package/es/schema-initializer/buttons/index.js +3 -0
- package/es/schema-initializer/components/BulkEditField.js +7 -5
- package/es/schema-initializer/components/CreateRecordAction.d.ts +1 -0
- package/es/schema-initializer/components/CreateRecordAction.js +51 -30
- package/es/schema-initializer/components/DeletedField.d.ts +1 -0
- package/es/schema-initializer/components/DeletedField.js +11 -0
- package/es/schema-initializer/components/assigned-field/AssignedField.js +35 -23
- package/es/schema-initializer/items/GridCardBlockInitializer.d.ts +1 -0
- package/es/schema-initializer/items/GridCardBlockInitializer.js +47 -0
- package/es/schema-initializer/items/ListBlockInitializer.d.ts +1 -0
- package/es/schema-initializer/items/ListBlockInitializer.js +47 -0
- package/es/schema-initializer/items/index.d.ts +3 -1
- package/es/schema-initializer/items/index.js +4 -2
- package/es/schema-initializer/utils.d.ts +112 -0
- package/es/schema-initializer/utils.js +206 -32
- package/es/schema-items/GeneralSchemaItems.d.ts +4 -0
- package/es/schema-items/GeneralSchemaItems.js +148 -0
- package/es/schema-items/index.d.ts +1 -0
- package/es/schema-items/index.js +2 -1
- package/es/schema-settings/DataTemplates/FormDataTemplates.d.ts +1 -0
- package/es/schema-settings/DataTemplates/FormDataTemplates.js +117 -42
- package/es/schema-settings/DataTemplates/components/AsDefaultTemplate.js +1 -1
- package/es/schema-settings/DataTemplates/components/DataTemplateTitle.js +9 -13
- package/es/schema-settings/DataTemplates/components/Designer.d.ts +7 -0
- package/es/schema-settings/DataTemplates/components/Designer.js +179 -0
- package/es/schema-settings/DataTemplates/hooks/useCollectionState.d.ts +6 -1
- package/es/schema-settings/DataTemplates/hooks/useCollectionState.js +204 -96
- package/es/schema-settings/GeneralSchemaDesigner.js +19 -15
- package/es/schema-settings/SchemaSettings.d.ts +1 -1
- package/es/schema-settings/SchemaSettings.js +54 -30
- package/es/schema-settings/VariableInput/hooks/useUserVariable.js +1 -1
- package/es/schema-settings/hooks/useIsShowMultipleSwitch.d.ts +4 -0
- package/es/schema-settings/hooks/useIsShowMultipleSwitch.js +18 -0
- package/es/schema-templates/BlockTemplateDetails.js +1 -1
- package/es/settings-form/SettingsForm.js +2 -2
- package/es/user/CurrentUser.js +120 -12
- package/lib/acl/ACLProvider.js +2 -2
- package/lib/acl/Configuration/RoleConfigure.js +15 -8
- package/lib/api-client/APIClient.d.ts +2 -0
- package/lib/api-client/APIClient.js +11 -0
- package/lib/block-provider/BlockProvider.js +57 -16
- package/lib/block-provider/hooks/index.js +80 -59
- package/lib/collection-manager/CollectionField.js +3 -3
- package/lib/collection-manager/CollectionFieldProvider.js +2 -1
- package/lib/collection-manager/Configuration/AddFieldAction.js +2 -2
- package/lib/collection-manager/Configuration/CollectionFields.d.ts +1 -1
- package/lib/collection-manager/Configuration/CollectionFields.js +1 -3
- package/lib/collection-manager/Configuration/ConfigurationTabs.js +7 -6
- package/lib/collection-manager/hooks/useCollection.d.ts +1 -1
- package/lib/collection-manager/hooks/useCollectionDataSource.js +4 -4
- package/lib/collection-manager/interfaces/m2m.js +1 -1
- package/lib/collection-manager/interfaces/m2o.js +1 -1
- package/lib/collection-manager/interfaces/o2m.js +1 -1
- package/lib/collection-manager/interfaces/o2o.js +2 -2
- package/lib/collection-manager/templates/expression.js +1 -1
- package/lib/filter-provider/utils.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +11 -0
- package/lib/locale/en_US.d.ts +16 -1
- package/lib/locale/en_US.js +17 -2
- package/lib/locale/es_ES.d.ts +692 -0
- package/lib/locale/es_ES.js +698 -0
- package/lib/locale/ja_JP.d.ts +5 -1
- package/lib/locale/ja_JP.js +6 -2
- package/lib/locale/pt_BR.d.ts +5 -1
- package/lib/locale/pt_BR.js +6 -2
- package/lib/locale/ru_RU.d.ts +5 -1
- package/lib/locale/ru_RU.js +6 -2
- package/lib/locale/tr_TR.d.ts +5 -1
- package/lib/locale/tr_TR.js +6 -2
- package/lib/locale/zh_CN.d.ts +25 -2
- package/lib/locale/zh_CN.js +26 -3
- package/lib/pm/PluginManagerLink.js +21 -13
- package/lib/record-provider/index.d.ts +4 -0
- package/lib/record-provider/index.js +5 -1
- package/lib/schema-component/antd/action/Action.Designer.js +6 -3
- package/lib/schema-component/antd/action/Action.Drawer.js +5 -2
- package/lib/schema-component/antd/action/Action.js +2 -2
- package/lib/schema-component/antd/action/ActionBar.js +23 -16
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -2
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +62 -8
- package/lib/schema-component/antd/association-field/AssociationSelect.js +9 -66
- package/lib/schema-component/antd/association-field/Editable.d.ts +1 -1
- package/lib/schema-component/antd/association-field/Editable.js +33 -42
- package/lib/schema-component/antd/association-field/InternalNester.js +2 -2
- package/lib/schema-component/antd/association-field/InternalPicker.js +25 -56
- package/lib/schema-component/antd/association-field/InternalViewer.js +7 -10
- package/lib/schema-component/antd/association-field/Nester.js +19 -21
- package/lib/schema-component/antd/association-field/ReadPretty.d.ts +1 -1
- package/lib/schema-component/antd/association-field/ReadPretty.js +10 -27
- package/lib/schema-component/antd/association-field/components/CreateRecordAction.d.ts +2 -0
- package/lib/schema-component/antd/association-field/components/CreateRecordAction.js +71 -0
- package/lib/schema-component/antd/association-field/context.d.ts +5 -2
- package/lib/schema-component/antd/association-field/context.js +1 -1
- package/lib/schema-component/antd/association-field/hooks.d.ts +3 -0
- package/lib/schema-component/antd/association-field/hooks.js +10 -10
- package/lib/schema-component/antd/association-filter/AssociationFilter.Item.js +3 -3
- package/lib/schema-component/antd/association-select/AssociationSelect.js +49 -231
- package/lib/schema-component/antd/association-select/useServiceOptions.js +2 -2
- package/lib/schema-component/antd/collection-select/CollectionSelect.js +5 -0
- package/lib/schema-component/antd/filter/FilterAction.js +2 -2
- package/lib/schema-component/antd/form/Form.js +4 -4
- package/lib/schema-component/antd/form-item/FormItem.js +122 -141
- package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +3 -3
- package/lib/schema-component/antd/form-v2/Form.Designer.js +1 -0
- package/lib/schema-component/antd/form-v2/Templates.d.ts +20 -0
- package/lib/schema-component/antd/form-v2/Templates.js +41 -11
- package/lib/schema-component/antd/grid/Grid.js +33 -23
- package/lib/schema-component/antd/grid-card/GridCard.Decorator.d.ts +5 -0
- package/lib/schema-component/antd/grid-card/GridCard.Decorator.js +77 -0
- package/lib/schema-component/antd/grid-card/GridCard.Designer.d.ts +1 -0
- package/lib/schema-component/antd/grid-card/GridCard.Designer.js +253 -0
- package/lib/schema-component/antd/grid-card/GridCard.Item.d.ts +1 -0
- package/lib/schema-component/antd/grid-card/GridCard.Item.js +26 -0
- package/lib/schema-component/antd/grid-card/GridCard.d.ts +8 -0
- package/lib/schema-component/antd/grid-card/GridCard.js +112 -0
- package/lib/schema-component/antd/grid-card/hooks.d.ts +4 -0
- package/lib/schema-component/antd/grid-card/hooks.js +16 -0
- package/lib/schema-component/antd/grid-card/index.d.ts +1 -0
- package/lib/schema-component/antd/grid-card/index.js +16 -0
- package/lib/schema-component/antd/grid-card/options.d.ts +20 -0
- package/lib/schema-component/antd/grid-card/options.js +31 -0
- package/lib/schema-component/antd/icon-picker/IconPicker.js +2 -2
- package/lib/schema-component/antd/index.d.ts +2 -0
- package/lib/schema-component/antd/index.js +22 -0
- package/lib/schema-component/antd/input/EllipsisWithTooltip.js +2 -2
- package/lib/schema-component/antd/list/List.Decorator.d.ts +5 -0
- package/lib/schema-component/antd/list/List.Decorator.js +71 -0
- package/lib/schema-component/antd/list/List.Designer.d.ts +1 -0
- package/lib/schema-component/antd/list/List.Designer.js +213 -0
- package/lib/schema-component/antd/list/List.Item.d.ts +1 -0
- package/lib/schema-component/antd/list/List.Item.js +23 -0
- package/lib/schema-component/antd/list/List.d.ts +8 -0
- package/lib/schema-component/antd/list/List.js +92 -0
- package/lib/schema-component/antd/list/hooks.d.ts +4 -0
- package/lib/schema-component/antd/list/hooks.js +16 -0
- package/lib/schema-component/antd/list/index.d.ts +1 -0
- package/lib/schema-component/antd/list/index.js +16 -0
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +11 -9
- package/lib/schema-component/antd/select/Select.js +14 -3
- package/lib/schema-component/antd/table/Table.Void.Designer.js +1 -0
- package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +2 -1
- package/lib/schema-component/antd/table-v2/TableSelectorDesigner.js +1 -0
- package/lib/schema-component/antd/table-v2/hooks/useUserVariable.d.ts +22 -0
- package/lib/schema-component/antd/table-v2/hooks/useUserVariable.js +73 -0
- package/lib/schema-component/antd/variable/Input.js +6 -3
- package/lib/schema-component/common/dnd-context/index.js +2 -2
- package/lib/schema-component/common/sortable-item/SortableItem.js +3 -4
- package/lib/schema-component/core/SchemaComponentProvider.js +2 -2
- package/lib/schema-initializer/SchemaInitializerProvider.d.ts +1 -0
- package/lib/schema-initializer/SchemaInitializerProvider.js +22 -9
- package/lib/schema-initializer/buttons/BlockInitializers.js +10 -0
- package/lib/schema-initializer/buttons/CustomFormItemInitializers.js +4 -2
- package/lib/schema-initializer/buttons/FormActionInitializers.d.ts +0 -116
- package/lib/schema-initializer/buttons/FormActionInitializers.js +106 -100
- package/lib/schema-initializer/buttons/GanttActionInitializers.d.ts +0 -19
- package/lib/schema-initializer/buttons/GridCardActionInitializers.d.ts +195 -0
- package/lib/schema-initializer/buttons/GridCardActionInitializers.js +285 -0
- package/lib/schema-initializer/buttons/ListActionInitializers.d.ts +195 -0
- package/lib/schema-initializer/buttons/ListActionInitializers.js +285 -0
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
- package/lib/schema-initializer/buttons/TableActionInitializers.d.ts +0 -20
- package/lib/schema-initializer/buttons/TableActionInitializers.js +29 -35
- package/lib/schema-initializer/buttons/TableColumnInitializers.js +4 -1
- package/lib/schema-initializer/buttons/index.d.ts +3 -0
- package/lib/schema-initializer/buttons/index.js +22 -0
- package/lib/schema-initializer/components/BulkEditField.js +7 -5
- package/lib/schema-initializer/components/CreateRecordAction.d.ts +1 -0
- package/lib/schema-initializer/components/CreateRecordAction.js +54 -32
- package/lib/schema-initializer/components/DeletedField.d.ts +1 -0
- package/lib/schema-initializer/components/DeletedField.js +19 -0
- package/lib/schema-initializer/components/assigned-field/AssignedField.js +34 -22
- package/lib/schema-initializer/items/GridCardBlockInitializer.d.ts +1 -0
- package/lib/schema-initializer/items/GridCardBlockInitializer.js +55 -0
- package/lib/schema-initializer/items/ListBlockInitializer.d.ts +1 -0
- package/lib/schema-initializer/items/ListBlockInitializer.js +55 -0
- package/lib/schema-initializer/items/index.d.ts +3 -1
- package/lib/schema-initializer/items/index.js +33 -11
- package/lib/schema-initializer/utils.d.ts +112 -0
- package/lib/schema-initializer/utils.js +209 -33
- package/lib/schema-items/GeneralSchemaItems.d.ts +4 -0
- package/lib/schema-items/GeneralSchemaItems.js +156 -0
- package/lib/schema-items/index.d.ts +1 -0
- package/lib/schema-items/index.js +11 -0
- package/lib/schema-settings/DataTemplates/FormDataTemplates.d.ts +1 -0
- package/lib/schema-settings/DataTemplates/FormDataTemplates.js +119 -41
- package/lib/schema-settings/DataTemplates/components/AsDefaultTemplate.js +1 -1
- package/lib/schema-settings/DataTemplates/components/DataTemplateTitle.js +10 -14
- package/lib/schema-settings/DataTemplates/components/Designer.d.ts +7 -0
- package/lib/schema-settings/DataTemplates/components/Designer.js +188 -0
- package/lib/schema-settings/DataTemplates/hooks/useCollectionState.d.ts +6 -1
- package/lib/schema-settings/DataTemplates/hooks/useCollectionState.js +204 -95
- package/lib/schema-settings/GeneralSchemaDesigner.js +21 -15
- package/lib/schema-settings/SchemaSettings.d.ts +1 -1
- package/lib/schema-settings/SchemaSettings.js +53 -29
- package/lib/schema-settings/VariableInput/hooks/useUserVariable.js +1 -1
- package/lib/schema-settings/hooks/useIsShowMultipleSwitch.d.ts +4 -0
- package/lib/schema-settings/hooks/useIsShowMultipleSwitch.js +24 -0
- package/lib/settings-form/SettingsForm.js +2 -2
- package/lib/user/CurrentUser.js +118 -10
- package/package.json +5 -5
- package/tsconfig.json +8 -0
package/es/user/CurrentUser.js
CHANGED
|
@@ -11,11 +11,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import { css } from '@emotion/css';
|
|
14
|
-
import { Dropdown, Menu } from 'antd';
|
|
14
|
+
import { Dropdown, Menu, Modal } from 'antd';
|
|
15
15
|
import React, { createContext, useState } from 'react';
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
import { useHistory } from 'react-router-dom';
|
|
18
|
-
import { useAPIClient, useCurrentUserContext } from '..';
|
|
18
|
+
import { useACLRoleContext, useAPIClient, useCurrentUserContext } from '..';
|
|
19
19
|
import { useCurrentAppInfo } from '../appInfo/CurrentAppInfoProvider';
|
|
20
20
|
import { ChangePassword } from './ChangePassword';
|
|
21
21
|
import { EditProfile } from './EditProfile';
|
|
@@ -43,6 +43,43 @@ export var CurrentUser = function CurrentUser() {
|
|
|
43
43
|
setVisible = _useState2[1];
|
|
44
44
|
var _useCurrentUserContex = useCurrentUserContext(),
|
|
45
45
|
data = _useCurrentUserContex.data;
|
|
46
|
+
var _useACLRoleContext = useACLRoleContext(),
|
|
47
|
+
allowAll = _useACLRoleContext.allowAll,
|
|
48
|
+
snippets = _useACLRoleContext.snippets;
|
|
49
|
+
var appAllowed = allowAll || (snippets === null || snippets === void 0 ? void 0 : snippets.includes('app'));
|
|
50
|
+
var silenceApi = useAPIClient();
|
|
51
|
+
var check = /*#__PURE__*/function () {
|
|
52
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
53
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
|
+
while (1) switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
_context.next = 2;
|
|
57
|
+
return new Promise(function (resolve) {
|
|
58
|
+
var heartbeat = setInterval(function () {
|
|
59
|
+
silenceApi.silent().resource('app').getInfo().then(function (res) {
|
|
60
|
+
console.log(res);
|
|
61
|
+
if ((res === null || res === void 0 ? void 0 : res.status) === 200) {
|
|
62
|
+
resolve('ok');
|
|
63
|
+
clearInterval(heartbeat);
|
|
64
|
+
}
|
|
65
|
+
return res;
|
|
66
|
+
}).catch(function () {
|
|
67
|
+
// ignore
|
|
68
|
+
});
|
|
69
|
+
}, 3000);
|
|
70
|
+
});
|
|
71
|
+
case 2:
|
|
72
|
+
return _context.abrupt("return", _context.sent);
|
|
73
|
+
case 3:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context.stop();
|
|
76
|
+
}
|
|
77
|
+
}, _callee);
|
|
78
|
+
}));
|
|
79
|
+
return function check() {
|
|
80
|
+
return _ref.apply(this, arguments);
|
|
81
|
+
};
|
|
82
|
+
}();
|
|
46
83
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
84
|
style: {
|
|
48
85
|
display: 'inline-flex',
|
|
@@ -54,30 +91,101 @@ export var CurrentUser = function CurrentUser() {
|
|
|
54
91
|
setVisible: setVisible
|
|
55
92
|
}
|
|
56
93
|
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
open: visible,
|
|
95
|
+
onOpenChange: function onOpenChange(visible) {
|
|
59
96
|
setVisible(visible);
|
|
60
97
|
},
|
|
61
|
-
overlay: /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(ApplicationVersion, null), /*#__PURE__*/React.createElement(Menu.Divider, null), /*#__PURE__*/React.createElement(EditProfile, null), /*#__PURE__*/React.createElement(ChangePassword, null), /*#__PURE__*/React.createElement(SwitchRole, null), /*#__PURE__*/React.createElement(LanguageSettings, null), /*#__PURE__*/React.createElement(ThemeSettings, null), /*#__PURE__*/React.createElement(Menu.Divider, null), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
98
|
+
overlay: /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(ApplicationVersion, null), /*#__PURE__*/React.createElement(Menu.Divider, null), /*#__PURE__*/React.createElement(EditProfile, null), /*#__PURE__*/React.createElement(ChangePassword, null), /*#__PURE__*/React.createElement(Menu.Divider, null), /*#__PURE__*/React.createElement(SwitchRole, null), /*#__PURE__*/React.createElement(LanguageSettings, null), /*#__PURE__*/React.createElement(ThemeSettings, null), /*#__PURE__*/React.createElement(Menu.Divider, null), appAllowed && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
99
|
+
key: "cache",
|
|
100
|
+
onClick: function () {
|
|
101
|
+
var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
102
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
_context2.next = 2;
|
|
106
|
+
return api.resource('app').clearCache();
|
|
107
|
+
case 2:
|
|
108
|
+
window.location.reload();
|
|
109
|
+
case 3:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context2.stop();
|
|
112
|
+
}
|
|
113
|
+
}, _callee2);
|
|
114
|
+
}));
|
|
115
|
+
function onClick() {
|
|
116
|
+
return _onClick.apply(this, arguments);
|
|
117
|
+
}
|
|
118
|
+
return onClick;
|
|
119
|
+
}()
|
|
120
|
+
}, t('Clear cache')), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
121
|
+
key: "reboot",
|
|
122
|
+
onClick: function () {
|
|
123
|
+
var _onClick2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
124
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
125
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
126
|
+
case 0:
|
|
127
|
+
Modal.confirm({
|
|
128
|
+
title: t('Reboot application'),
|
|
129
|
+
content: t('The will interrupt service, it may take a few seconds to restart. Are you sure to continue?'),
|
|
130
|
+
okText: t('Reboot'),
|
|
131
|
+
okButtonProps: {
|
|
132
|
+
danger: true
|
|
133
|
+
},
|
|
134
|
+
onOk: function () {
|
|
135
|
+
var _onOk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
136
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
137
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
_context3.next = 2;
|
|
140
|
+
return api.resource('app').reboot();
|
|
141
|
+
case 2:
|
|
142
|
+
_context3.next = 4;
|
|
143
|
+
return check();
|
|
144
|
+
case 4:
|
|
145
|
+
window.location.reload();
|
|
146
|
+
case 5:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context3.stop();
|
|
149
|
+
}
|
|
150
|
+
}, _callee3);
|
|
151
|
+
}));
|
|
152
|
+
function onOk() {
|
|
153
|
+
return _onOk.apply(this, arguments);
|
|
154
|
+
}
|
|
155
|
+
return onOk;
|
|
156
|
+
}()
|
|
157
|
+
});
|
|
158
|
+
case 1:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context4.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee4);
|
|
163
|
+
}));
|
|
164
|
+
function onClick() {
|
|
165
|
+
return _onClick2.apply(this, arguments);
|
|
166
|
+
}
|
|
167
|
+
return onClick;
|
|
168
|
+
}()
|
|
169
|
+
}, t('Reboot application')), /*#__PURE__*/React.createElement(Menu.Divider, null)), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
62
170
|
key: "signout",
|
|
63
171
|
onClick: function () {
|
|
64
|
-
var
|
|
65
|
-
return _regeneratorRuntime().wrap(function
|
|
66
|
-
while (1) switch (
|
|
172
|
+
var _onClick3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
173
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
174
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
67
175
|
case 0:
|
|
68
|
-
|
|
176
|
+
_context5.next = 2;
|
|
69
177
|
return api.resource('users').signout();
|
|
70
178
|
case 2:
|
|
71
179
|
api.auth.setToken(null);
|
|
72
180
|
history.push('/signin');
|
|
73
181
|
case 4:
|
|
74
182
|
case "end":
|
|
75
|
-
return
|
|
183
|
+
return _context5.stop();
|
|
76
184
|
}
|
|
77
|
-
},
|
|
185
|
+
}, _callee5);
|
|
78
186
|
}));
|
|
79
187
|
function onClick() {
|
|
80
|
-
return
|
|
188
|
+
return _onClick3.apply(this, arguments);
|
|
81
189
|
}
|
|
82
190
|
return onClick;
|
|
83
191
|
}()
|
package/lib/acl/ACLProvider.js
CHANGED
|
@@ -175,11 +175,11 @@ var getIgnoreScope = function getIgnoreScope() {
|
|
|
175
175
|
return ignoreScope;
|
|
176
176
|
};
|
|
177
177
|
var useAllowedActions = function useAllowedActions() {
|
|
178
|
-
var _result$service, _result$service$data, _result$service$data$;
|
|
178
|
+
var _result$allowedAction, _result$service, _result$service$data, _result$service$data$;
|
|
179
179
|
var result = (0, _BlockProvider.useBlockRequestContext)() || {
|
|
180
180
|
service: (0, _ResourceActionProvider.useResourceActionContext)()
|
|
181
181
|
};
|
|
182
|
-
return result === null || result === void 0 ? void 0 : (_result$service = result.service) === null || _result$service === void 0 ? void 0 : (_result$service$data = _result$service.data) === null || _result$service$data === void 0 ? void 0 : (_result$service$data$ = _result$service$data.meta) === null || _result$service$data$ === void 0 ? void 0 : _result$service$data$.allowedActions;
|
|
182
|
+
return (_result$allowedAction = result === null || result === void 0 ? void 0 : result.allowedActions) !== null && _result$allowedAction !== void 0 ? _result$allowedAction : result === null || result === void 0 ? void 0 : (_result$service = result.service) === null || _result$service === void 0 ? void 0 : (_result$service$data = _result$service.data) === null || _result$service$data === void 0 ? void 0 : (_result$service$data$ = _result$service$data.meta) === null || _result$service$data$ === void 0 ? void 0 : _result$service$data$.allowedActions;
|
|
183
183
|
};
|
|
184
184
|
var useResourceName = function useResourceName() {
|
|
185
185
|
var _result$props, _result$service2, _result$service2$defa;
|
|
@@ -35,19 +35,20 @@ var SnippetCheckboxGroup = (0, _react.connect)(function (props) {
|
|
|
35
35
|
},
|
|
36
36
|
value: props.value,
|
|
37
37
|
onChange: function onChange(values) {
|
|
38
|
+
var snippets = ['ui.*', 'pm', 'pm.*', 'app'];
|
|
39
|
+
var disallowSnippets = snippets.map(function (key) {
|
|
40
|
+
return "!".concat(key);
|
|
41
|
+
});
|
|
38
42
|
var value = (0, _uniq.default)([].concat(_toConsumableArray(props.value || []), _toConsumableArray(values))).filter(function (key) {
|
|
39
|
-
return key && !
|
|
43
|
+
return key && !disallowSnippets.includes(key);
|
|
40
44
|
}).map(function (key) {
|
|
41
|
-
if (!
|
|
42
|
-
return key;
|
|
43
|
-
}
|
|
44
|
-
if (values === null || values === void 0 ? void 0 : values.includes(key)) {
|
|
45
|
+
if (!snippets.includes(key) || (values === null || values === void 0 ? void 0 : values.includes(key))) {
|
|
45
46
|
return key;
|
|
46
47
|
}
|
|
47
48
|
return "!".concat(key);
|
|
48
49
|
});
|
|
49
|
-
for (var _i = 0,
|
|
50
|
-
var key =
|
|
50
|
+
for (var _i = 0, _snippets = snippets; _i < _snippets.length; _i++) {
|
|
51
|
+
var key = _snippets[_i];
|
|
51
52
|
if (!value.includes(key) && !value.includes("!".concat(key))) {
|
|
52
53
|
value.push("!".concat(key));
|
|
53
54
|
}
|
|
@@ -72,7 +73,13 @@ var SnippetCheckboxGroup = (0, _react.connect)(function (props) {
|
|
|
72
73
|
}
|
|
73
74
|
}, /*#__PURE__*/_react2.default.createElement(_antd.Checkbox, {
|
|
74
75
|
value: "pm.*"
|
|
75
|
-
}, t('Allows to configure plugins')))
|
|
76
|
+
}, t('Allows to configure plugins'))), /*#__PURE__*/_react2.default.createElement("div", {
|
|
77
|
+
style: {
|
|
78
|
+
marginTop: 8
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/_react2.default.createElement(_antd.Checkbox, {
|
|
81
|
+
value: "app"
|
|
82
|
+
}, t('Allows to clear cache, reboot application'))));
|
|
76
83
|
});
|
|
77
84
|
var RoleConfigure = function RoleConfigure() {
|
|
78
85
|
var _useContext = (0, _react2.useContext)(_PermisionProvider.PermissionContext),
|
|
@@ -2,7 +2,9 @@ import { APIClient as APIClientSDK } from '@nocobase/sdk';
|
|
|
2
2
|
import { Result } from 'ahooks/lib/useRequest/src/types';
|
|
3
3
|
export declare class APIClient extends APIClientSDK {
|
|
4
4
|
services: Record<string, Result<any, any>>;
|
|
5
|
+
silence: boolean;
|
|
5
6
|
service(uid: string): Result<any, any>;
|
|
6
7
|
interceptors(): void;
|
|
7
8
|
notification(): void;
|
|
9
|
+
silent(): this;
|
|
8
10
|
}
|
|
@@ -49,6 +49,7 @@ var APIClient = /*#__PURE__*/function (_APIClientSDK) {
|
|
|
49
49
|
}
|
|
50
50
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
51
51
|
_this.services = {};
|
|
52
|
+
_this.silence = false;
|
|
52
53
|
return _this;
|
|
53
54
|
}
|
|
54
55
|
_createClass(APIClient, [{
|
|
@@ -73,10 +74,14 @@ var APIClient = /*#__PURE__*/function (_APIClientSDK) {
|
|
|
73
74
|
}, {
|
|
74
75
|
key: "notification",
|
|
75
76
|
value: function notification() {
|
|
77
|
+
var _this2 = this;
|
|
76
78
|
this.axios.interceptors.response.use(function (response) {
|
|
77
79
|
return response;
|
|
78
80
|
}, function (error) {
|
|
79
81
|
var _error$response2, _error$response2$data, _error$response3, _error$response3$data;
|
|
82
|
+
if (_this2.silence) {
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
80
85
|
var redirectTo = error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.redirectTo;
|
|
81
86
|
if (redirectTo) {
|
|
82
87
|
return window.location.href = redirectTo;
|
|
@@ -96,6 +101,12 @@ var APIClient = /*#__PURE__*/function (_APIClientSDK) {
|
|
|
96
101
|
throw error;
|
|
97
102
|
});
|
|
98
103
|
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "silent",
|
|
106
|
+
value: function silent() {
|
|
107
|
+
this.silence = true;
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
99
110
|
}]);
|
|
100
111
|
return APIClient;
|
|
101
112
|
}(_sdk.APIClient);
|
|
@@ -7,6 +7,7 @@ exports.useSourceIdFromRecord = exports.useSourceIdFromParentRecord = exports.us
|
|
|
7
7
|
var _css = require("@emotion/css");
|
|
8
8
|
var _react = require("@formily/react");
|
|
9
9
|
var _ahooks = require("ahooks");
|
|
10
|
+
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
10
11
|
var _antd = require("antd");
|
|
11
12
|
var _template = _interopRequireDefault(require("lodash/template"));
|
|
12
13
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
@@ -25,6 +26,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
25
26
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
26
27
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
28
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
29
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
30
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
32
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
33
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
34
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
35
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
29
36
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
30
37
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -60,15 +67,19 @@ var useResource = function useResource(props) {
|
|
|
60
67
|
useSourceId = props.useSourceId;
|
|
61
68
|
var record = (0, _.useRecord)();
|
|
62
69
|
var api = (0, _.useAPIClient)();
|
|
70
|
+
var _useActionContext = (0, _.useActionContext)(),
|
|
71
|
+
fieldSchema = _useActionContext.fieldSchema;
|
|
72
|
+
var isCreateAction = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-action']) === 'create';
|
|
63
73
|
var association = useAssociation(props);
|
|
64
74
|
var sourceId = useSourceId === null || useSourceId === void 0 ? void 0 : useSourceId();
|
|
65
75
|
var field = (0, _react.useField)();
|
|
66
76
|
if (block === 'TableField') {
|
|
77
|
+
var _record$__parent;
|
|
67
78
|
var options = {
|
|
68
79
|
field: field,
|
|
69
80
|
api: api,
|
|
70
81
|
resource: resource,
|
|
71
|
-
sourceId: sourceId || record[(association === null || association === void 0 ? void 0 : association.sourceKey) || 'id']
|
|
82
|
+
sourceId: !isCreateAction ? sourceId || record[(association === null || association === void 0 ? void 0 : association.sourceKey) || 'id'] || (record === null || record === void 0 ? void 0 : (_record$__parent = record.__parent) === null || _record$__parent === void 0 ? void 0 : _record$__parent[(association === null || association === void 0 ? void 0 : association.sourceKey) || 'id']) : undefined
|
|
72
83
|
};
|
|
73
84
|
return new _.TableFieldResource(options);
|
|
74
85
|
}
|
|
@@ -97,22 +108,26 @@ var useResourceAction = function useResourceAction(props) {
|
|
|
97
108
|
*/
|
|
98
109
|
var resource = props.resource,
|
|
99
110
|
action = props.action,
|
|
100
|
-
tableFieldName = props.fieldName
|
|
111
|
+
tableFieldName = props.fieldName,
|
|
112
|
+
_props$runWhenParamsC = props.runWhenParamsChanged,
|
|
113
|
+
runWhenParamsChanged = _props$runWhenParamsC === void 0 ? false : _props$runWhenParamsC;
|
|
101
114
|
var _useCollection = (0, _collectionManager.useCollection)(),
|
|
102
115
|
fields = _useCollection.fields;
|
|
103
|
-
var appends = fields === null || fields === void 0 ? void 0 : fields.filter(function (field) {
|
|
104
|
-
return field.target;
|
|
105
|
-
}).map(function (field) {
|
|
106
|
-
return field.name;
|
|
107
|
-
});
|
|
108
116
|
var params = useActionParams(props);
|
|
109
117
|
var api = (0, _.useAPIClient)();
|
|
110
118
|
var fieldSchema = (0, _react.useFieldSchema)();
|
|
111
|
-
var
|
|
112
|
-
snapshot =
|
|
119
|
+
var _useActionContext2 = (0, _.useActionContext)(),
|
|
120
|
+
snapshot = _useActionContext2.snapshot;
|
|
113
121
|
var record = (0, _.useRecord)();
|
|
114
|
-
if (!
|
|
115
|
-
|
|
122
|
+
if (!Reflect.has(params, 'appends')) {
|
|
123
|
+
var appends = fields === null || fields === void 0 ? void 0 : fields.filter(function (field) {
|
|
124
|
+
return field.target;
|
|
125
|
+
}).map(function (field) {
|
|
126
|
+
return field.name;
|
|
127
|
+
});
|
|
128
|
+
if (appends === null || appends === void 0 ? void 0 : appends.length) {
|
|
129
|
+
params['appends'] = appends;
|
|
130
|
+
}
|
|
116
131
|
}
|
|
117
132
|
var result = (0, _ahooks.useRequest)(snapshot ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
118
133
|
var _record$tableFieldNam;
|
|
@@ -131,8 +146,8 @@ var useResourceAction = function useResourceAction(props) {
|
|
|
131
146
|
if (!action) {
|
|
132
147
|
return Promise.resolve({});
|
|
133
148
|
}
|
|
134
|
-
var actionParams = _objectSpread({}, opts);
|
|
135
|
-
if (params.appends) {
|
|
149
|
+
var actionParams = _objectSpread(_objectSpread({}, params), opts);
|
|
150
|
+
if (params === null || params === void 0 ? void 0 : params.appends) {
|
|
136
151
|
actionParams.appends = params.appends;
|
|
137
152
|
}
|
|
138
153
|
return resource[action](actionParams).then(function (res) {
|
|
@@ -147,8 +162,20 @@ var useResourceAction = function useResourceAction(props) {
|
|
|
147
162
|
}
|
|
148
163
|
},
|
|
149
164
|
defaultParams: [params],
|
|
150
|
-
refreshDeps: [JSON.stringify(params.appends)]
|
|
165
|
+
refreshDeps: [runWhenParamsChanged ? null : JSON.stringify(params.appends)]
|
|
151
166
|
}));
|
|
167
|
+
// automatic run service when params has changed
|
|
168
|
+
var firstRun = (0, _react2.useRef)(false);
|
|
169
|
+
(0, _react2.useEffect)(function () {
|
|
170
|
+
if (!runWhenParamsChanged) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (firstRun.current) {
|
|
174
|
+
var _result$params;
|
|
175
|
+
result === null || result === void 0 ? void 0 : result.run(_objectSpread(_objectSpread({}, result === null || result === void 0 ? void 0 : (_result$params = result.params) === null || _result$params === void 0 ? void 0 : _result$params[0]), params));
|
|
176
|
+
}
|
|
177
|
+
firstRun.current = true;
|
|
178
|
+
}, [JSON.stringify(params), runWhenParamsChanged]);
|
|
152
179
|
return result;
|
|
153
180
|
};
|
|
154
181
|
exports.useResourceAction = useResourceAction;
|
|
@@ -160,14 +187,28 @@ var MaybeCollectionProvider = function MaybeCollectionProvider(props) {
|
|
|
160
187
|
};
|
|
161
188
|
exports.MaybeCollectionProvider = MaybeCollectionProvider;
|
|
162
189
|
var BlockRequestProvider = function BlockRequestProvider(props) {
|
|
190
|
+
var _service$data, _service$data$meta;
|
|
163
191
|
var field = (0, _react.useField)();
|
|
164
192
|
var resource = useBlockResource();
|
|
193
|
+
var _useState = (0, _react2.useState)({}),
|
|
194
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
195
|
+
allowedActions = _useState2[0],
|
|
196
|
+
setAllowedActions = _useState2[1];
|
|
165
197
|
var service = useResourceAction(_objectSpread(_objectSpread({}, props), {}, {
|
|
166
198
|
resource: resource
|
|
167
199
|
}), _objectSpread({}, props.requestOptions));
|
|
200
|
+
// Infinite scroll support
|
|
201
|
+
var serviceAllowedActions = service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : (_service$data$meta = _service$data.meta) === null || _service$data$meta === void 0 ? void 0 : _service$data$meta.allowedActions;
|
|
202
|
+
(0, _react2.useEffect)(function () {
|
|
203
|
+
if (!serviceAllowedActions) return;
|
|
204
|
+
setAllowedActions(function (last) {
|
|
205
|
+
return (0, _deepmerge.default)(last, serviceAllowedActions !== null && serviceAllowedActions !== void 0 ? serviceAllowedActions : {});
|
|
206
|
+
});
|
|
207
|
+
}, [serviceAllowedActions]);
|
|
168
208
|
var __parent = (0, _react2.useContext)(BlockRequestContext);
|
|
169
209
|
return /*#__PURE__*/_react2.default.createElement(BlockRequestContext.Provider, {
|
|
170
210
|
value: {
|
|
211
|
+
allowedActions: allowedActions,
|
|
171
212
|
block: props.block,
|
|
172
213
|
props: props,
|
|
173
214
|
field: field,
|
|
@@ -280,9 +321,9 @@ var useSourceIdFromParentRecord = function useSourceIdFromParentRecord() {
|
|
|
280
321
|
getCollectionField = _useCollectionManager4.getCollectionField;
|
|
281
322
|
var assoc = (0, _react2.useContext)(BlockAssociationContext);
|
|
282
323
|
if (assoc) {
|
|
283
|
-
var _record$
|
|
324
|
+
var _record$__parent2;
|
|
284
325
|
var association = getCollectionField(assoc);
|
|
285
|
-
return record === null || record === void 0 ? void 0 : (_record$
|
|
326
|
+
return record === null || record === void 0 ? void 0 : (_record$__parent2 = record.__parent) === null || _record$__parent2 === void 0 ? void 0 : _record$__parent2[association.sourceKey || 'id'];
|
|
286
327
|
}
|
|
287
328
|
};
|
|
288
329
|
exports.useSourceIdFromParentRecord = useSourceIdFromParentRecord;
|