@nocobase/client 0.7.0-alpha.80 → 0.7.0-alpha.83

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.
Files changed (95) hide show
  1. package/es/acl/ACLProvider.js +10 -15
  2. package/es/antd-config-provider/index.js +7 -4
  3. package/es/api-client/APIClient.d.ts +2 -30
  4. package/es/api-client/APIClient.js +30 -158
  5. package/es/api-client/hooks/useResource.d.ts +1 -1
  6. package/es/block-provider/hooks/index.d.ts +3 -0
  7. package/es/block-provider/hooks/index.js +233 -168
  8. package/es/collection-manager/Configuration/AddFieldAction.js +27 -9
  9. package/es/collection-manager/Configuration/EditFieldAction.js +25 -8
  10. package/es/collection-manager/hooks/useCollection.d.ts +1 -1
  11. package/es/i18n/i18n.js +3 -3
  12. package/es/locale/en_US.d.ts +10 -0
  13. package/es/locale/en_US.js +11 -1
  14. package/es/locale/index.d.ts +44 -0
  15. package/es/locale/zh_CN.d.ts +34 -0
  16. package/es/locale/zh_CN.js +35 -1
  17. package/es/schema-component/antd/action/Action.Designer.js +33 -13
  18. package/es/schema-component/antd/action/utils.d.ts +2 -0
  19. package/es/schema-component/antd/action/utils.js +60 -0
  20. package/es/schema-component/antd/date-picker/util.d.ts +2 -1
  21. package/es/schema-component/antd/date-picker/util.js +4 -2
  22. package/es/schema-initializer/buttons/FormActionInitializers.d.ts +84 -0
  23. package/es/schema-initializer/buttons/FormActionInitializers.js +63 -0
  24. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +26 -0
  25. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +21 -0
  26. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +21 -0
  27. package/es/schema-settings/SchemaSettings.js +48 -16
  28. package/es/user/CurrentUser.js +1 -1
  29. package/es/user/LanguageSettings.js +4 -3
  30. package/es/user/SigninPage.js +3 -14
  31. package/es/user/SwitchRole.js +2 -26
  32. package/es/workflow/triggers/collection.js +1 -0
  33. package/es/workflow/triggers/index.js +2 -0
  34. package/es/workflow/triggers/schedule.d.ts +25 -0
  35. package/es/workflow/triggers/schedule.js +531 -0
  36. package/lib/acl/ACLProvider.js +9 -15
  37. package/lib/antd-config-provider/index.js +6 -3
  38. package/lib/api-client/APIClient.d.ts +2 -30
  39. package/lib/api-client/APIClient.js +26 -160
  40. package/lib/api-client/hooks/useResource.d.ts +1 -1
  41. package/lib/block-provider/hooks/index.d.ts +3 -0
  42. package/lib/block-provider/hooks/index.js +238 -169
  43. package/lib/collection-manager/Configuration/AddFieldAction.js +27 -9
  44. package/lib/collection-manager/Configuration/EditFieldAction.js +25 -8
  45. package/lib/collection-manager/hooks/useCollection.d.ts +1 -1
  46. package/lib/i18n/i18n.js +3 -3
  47. package/lib/locale/en_US.d.ts +10 -0
  48. package/lib/locale/en_US.js +11 -1
  49. package/lib/locale/index.d.ts +44 -0
  50. package/lib/locale/zh_CN.d.ts +34 -0
  51. package/lib/locale/zh_CN.js +35 -1
  52. package/lib/schema-component/antd/action/Action.Designer.js +34 -13
  53. package/lib/schema-component/antd/action/utils.d.ts +2 -0
  54. package/lib/schema-component/antd/action/utils.js +67 -0
  55. package/lib/schema-component/antd/date-picker/util.d.ts +2 -1
  56. package/lib/schema-component/antd/date-picker/util.js +6 -1
  57. package/lib/schema-initializer/buttons/FormActionInitializers.d.ts +84 -0
  58. package/lib/schema-initializer/buttons/FormActionInitializers.js +63 -0
  59. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +26 -0
  60. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +21 -0
  61. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +21 -0
  62. package/lib/schema-settings/SchemaSettings.js +49 -16
  63. package/lib/user/CurrentUser.js +1 -1
  64. package/lib/user/LanguageSettings.js +4 -3
  65. package/lib/user/SigninPage.js +3 -14
  66. package/lib/user/SwitchRole.js +2 -27
  67. package/lib/workflow/triggers/collection.js +1 -0
  68. package/lib/workflow/triggers/index.js +3 -0
  69. package/lib/workflow/triggers/schedule.d.ts +25 -0
  70. package/lib/workflow/triggers/schedule.js +554 -0
  71. package/package.json +4 -3
  72. package/src/acl/ACLProvider.tsx +4 -5
  73. package/src/antd-config-provider/index.tsx +4 -2
  74. package/src/api-client/APIClient.ts +2 -120
  75. package/src/block-provider/hooks/index.ts +106 -69
  76. package/src/collection-manager/Configuration/AddFieldAction.tsx +18 -0
  77. package/src/collection-manager/Configuration/EditFieldAction.tsx +19 -0
  78. package/src/i18n/i18n.ts +3 -3
  79. package/src/locale/en_US.ts +11 -1
  80. package/src/locale/zh_CN.ts +39 -1
  81. package/src/schema-component/antd/action/Action.Designer.tsx +33 -1
  82. package/src/schema-component/antd/action/utils.ts +68 -0
  83. package/src/schema-component/antd/date-picker/util.ts +4 -3
  84. package/src/schema-initializer/SchemaInitializer.tsx +2 -2
  85. package/src/schema-initializer/buttons/FormActionInitializers.tsx +66 -0
  86. package/src/schema-initializer/buttons/ReadPrettyFormActionInitializers.tsx +22 -0
  87. package/src/schema-initializer/buttons/TableActionColumnInitializers.tsx +22 -0
  88. package/src/schema-settings/SchemaSettings.tsx +40 -29
  89. package/src/user/CurrentUser.tsx +1 -1
  90. package/src/user/LanguageSettings.tsx +1 -0
  91. package/src/user/SigninPage.tsx +2 -7
  92. package/src/user/SwitchRole.tsx +2 -6
  93. package/src/workflow/triggers/collection.tsx +1 -1
  94. package/src/workflow/triggers/index.tsx +2 -0
  95. package/src/workflow/triggers/schedule.tsx +422 -0
@@ -101,6 +101,28 @@ export const FormActionInitializers = {
101
101
  },
102
102
  },
103
103
  },
104
+ {
105
+ type: 'item',
106
+ title: '{{t("Custom request")}}',
107
+ component: 'CustomizeActionInitializer',
108
+ schema: {
109
+ title: '{{ t("Custom request") }}',
110
+ 'x-component': 'Action',
111
+ 'x-action': 'customize:form:request',
112
+ 'x-designer': 'Action.Designer',
113
+ 'x-action-settings': {
114
+ requestSettings: {},
115
+ onSuccess: {
116
+ manualClose: false,
117
+ redirecting: false,
118
+ successMessage: '{{t("Request success")}}',
119
+ },
120
+ },
121
+ 'x-component-props': {
122
+ useProps: '{{ useCustomizeRequestActionProps }}',
123
+ },
124
+ },
125
+ },
104
126
  ],
105
127
  },
106
128
  ],
@@ -208,6 +230,28 @@ export const CreateFormActionInitializers = {
208
230
  },
209
231
  },
210
232
  },
233
+ {
234
+ type: 'item',
235
+ title: '{{t("Custom request")}}',
236
+ component: 'CustomizeActionInitializer',
237
+ schema: {
238
+ title: '{{ t("Custom request") }}',
239
+ 'x-component': 'Action',
240
+ 'x-action': 'customize:form:request',
241
+ 'x-designer': 'Action.Designer',
242
+ 'x-action-settings': {
243
+ requestSettings: {},
244
+ onSuccess: {
245
+ manualClose: false,
246
+ redirecting: false,
247
+ successMessage: '{{t("Request success")}}',
248
+ },
249
+ },
250
+ 'x-component-props': {
251
+ useProps: '{{ useCustomizeRequestActionProps }}',
252
+ },
253
+ },
254
+ },
211
255
  ],
212
256
  },
213
257
  ],
@@ -315,6 +359,28 @@ export const UpdateFormActionInitializers = {
315
359
  },
316
360
  },
317
361
  },
362
+ {
363
+ type: 'item',
364
+ title: '{{t("Custom request")}}',
365
+ component: 'CustomizeActionInitializer',
366
+ schema: {
367
+ title: '{{ t("Custom request") }}',
368
+ 'x-component': 'Action',
369
+ 'x-action': 'customize:form:request',
370
+ 'x-designer': 'Action.Designer',
371
+ 'x-action-settings': {
372
+ requestSettings: {},
373
+ onSuccess: {
374
+ manualClose: false,
375
+ redirecting: false,
376
+ successMessage: '{{t("Request success")}}',
377
+ },
378
+ },
379
+ 'x-component-props': {
380
+ useProps: '{{ useCustomizeRequestActionProps }}',
381
+ },
382
+ },
383
+ },
318
384
  ],
319
385
  },
320
386
  ],
@@ -113,6 +113,28 @@ export const ReadPrettyFormActionInitializers = {
113
113
  },
114
114
  },
115
115
  },
116
+ {
117
+ type: 'item',
118
+ title: '{{t("Custom request")}}',
119
+ component: 'CustomizeActionInitializer',
120
+ schema: {
121
+ title: '{{ t("Custom request") }}',
122
+ 'x-component': 'Action',
123
+ 'x-action': 'customize:form:request',
124
+ 'x-designer': 'Action.Designer',
125
+ 'x-action-settings': {
126
+ requestSettings: {},
127
+ onSuccess: {
128
+ manualClose: false,
129
+ redirecting: false,
130
+ successMessage: '{{t("Request success")}}',
131
+ },
132
+ },
133
+ 'x-component-props': {
134
+ useProps: '{{ useCustomizeRequestActionProps }}',
135
+ },
136
+ },
137
+ },
116
138
  ],
117
139
  },
118
140
  ],
@@ -149,6 +149,28 @@ export const TableActionColumnInitializers = (props: any) => {
149
149
  },
150
150
  },
151
151
  },
152
+ {
153
+ type: 'item',
154
+ title: '{{t("Custom request")}}',
155
+ component: 'CustomizeActionInitializer',
156
+ schema: {
157
+ title: '{{ t("Custom request") }}',
158
+ 'x-component': 'Action.Link',
159
+ 'x-action': 'customize:table:request',
160
+ 'x-designer': 'Action.Designer',
161
+ 'x-action-settings': {
162
+ requestSettings: {},
163
+ onSuccess: {
164
+ manualClose: false,
165
+ redirecting: false,
166
+ successMessage: '{{t("Request success")}}',
167
+ },
168
+ },
169
+ 'x-component-props': {
170
+ useProps: '{{ useCustomizeRequestActionProps }}',
171
+ },
172
+ },
173
+ },
152
174
  ],
153
175
  },
154
176
  ]}
@@ -7,6 +7,7 @@ import { Alert, Button, Dropdown, Menu, MenuItemProps, Modal, Select, Space, Swi
7
7
  import classNames from 'classnames';
8
8
  import { cloneDeep } from 'lodash';
9
9
  import React, { createContext, useContext, useMemo, useState } from 'react';
10
+ import { createPortal } from 'react-dom';
10
11
  import { useTranslation } from 'react-i18next';
11
12
  import {
12
13
  ActionContext,
@@ -19,7 +20,7 @@ import {
19
20
  useActionContext,
20
21
  useAPIClient,
21
22
  useCollection,
22
- useCompile
23
+ useCompile,
23
24
  } from '..';
24
25
  import { useSchemaTemplateManager } from '../schema-templates';
25
26
  import { useBlockTemplateContext } from '../schema-templates/BlockTemplate';
@@ -466,7 +467,7 @@ SchemaSettings.PopupItem = (props) => {
466
467
  };
467
468
 
468
469
  SchemaSettings.ActionModalItem = React.memo((props: any) => {
469
- const { title, onSubmit, initialValues, initialSchema, modalTip, ...others } = props;
470
+ const { title, onSubmit, initialValues, initialSchema, schema, modalTip, components, ...others } = props;
470
471
  const [visible, setVisible] = useState(false);
471
472
  const [schemaUid, setSchemaUid] = useState<string>(props.uid);
472
473
  const { t } = useTranslation();
@@ -487,13 +488,14 @@ SchemaSettings.ActionModalItem = React.memo((props: any) => {
487
488
  setVisible(false);
488
489
  };
489
490
 
490
- const submitHandler = () => {
491
+ const submitHandler = async () => {
492
+ await form.submit();
491
493
  onSubmit?.(cloneDeep(form.values));
492
494
  setVisible(false);
493
495
  };
494
496
 
495
497
  const openAssignedFieldValueHandler = async () => {
496
- if (!schemaUid && initialSchema['x-uid']) {
498
+ if (!schemaUid && initialSchema?.['x-uid']) {
497
499
  fieldSchema['x-action-settings'].schemaUid = initialSchema['x-uid'];
498
500
  dn.emit('patch', { schema: fieldSchema });
499
501
  await api.resource('uiSchemas').insert({ values: initialSchema });
@@ -509,31 +511,40 @@ SchemaSettings.ActionModalItem = React.memo((props: any) => {
509
511
  <SchemaSettings.Item {...others} onClick={openAssignedFieldValueHandler}>
510
512
  {props.children || props.title}
511
513
  </SchemaSettings.Item>
512
-
513
- <Modal
514
- width={'50%'}
515
- title={compile(title)}
516
- {...others}
517
- destroyOnClose
518
- visible={visible}
519
- onCancel={cancelHandler}
520
- footer={
521
- <Space>
522
- <Button onClick={cancelHandler}>{t('Cancel')}</Button>
523
- <Button type="primary" onClick={submitHandler}>
524
- {t('Submit')}
525
- </Button>
526
- </Space>
527
- }
528
- >
529
- <FormProvider form={form}>
530
- <FormLayout layout={'vertical'}>
531
- {modalTip && <Alert message={modalTip} />}
532
- {modalTip && <br />}
533
- {visible && <RemoteSchemaComponent noForm uid={schemaUid} />}
534
- </FormLayout>
535
- </FormProvider>
536
- </Modal>
514
+ {createPortal(
515
+ <div
516
+ onClick={(e) => {
517
+ e.stopPropagation();
518
+ }}
519
+ >
520
+ <Modal
521
+ width={'50%'}
522
+ title={compile(title)}
523
+ {...others}
524
+ destroyOnClose
525
+ visible={visible}
526
+ onCancel={cancelHandler}
527
+ footer={
528
+ <Space>
529
+ <Button onClick={cancelHandler}>{t('Cancel')}</Button>
530
+ <Button type="primary" onClick={submitHandler}>
531
+ {t('Submit')}
532
+ </Button>
533
+ </Space>
534
+ }
535
+ >
536
+ <FormProvider form={form}>
537
+ <FormLayout layout={'vertical'}>
538
+ {modalTip && <Alert message={modalTip} />}
539
+ {modalTip && <br />}
540
+ {visible && schemaUid && <RemoteSchemaComponent noForm components={components} uid={schemaUid} />}
541
+ {visible && schema && <SchemaComponent components={components} schema={schema} />}
542
+ </FormLayout>
543
+ </FormProvider>
544
+ </Modal>
545
+ </div>,
546
+ document.body,
547
+ )}
537
548
  </>
538
549
  );
539
550
  });
@@ -36,7 +36,7 @@ export const CurrentUser = () => {
36
36
  <Menu.Item
37
37
  onClick={async () => {
38
38
  await api.resource('users').signout();
39
- api.setBearerToken(null);
39
+ api.auth.setToken(null);
40
40
  history.push('/signin');
41
41
  }}
42
42
  >
@@ -34,6 +34,7 @@ export const LanguageSettings = () => {
34
34
  appLang: lang,
35
35
  },
36
36
  });
37
+ api.auth.setLocale(lang);
37
38
  await i18n.changeLanguage(lang);
38
39
  window.location.reload();
39
40
  }}
@@ -68,13 +68,8 @@ const useSignin = () => {
68
68
  return {
69
69
  async run() {
70
70
  await form.submit();
71
- const response = await api.resource('users').signin({
72
- values: form.values,
73
- });
74
- if (response?.data?.data?.token) {
75
- api.setBearerToken(response?.data?.data?.token);
76
- history.push(redirect || '/admin');
77
- }
71
+ await api.auth.signIn(form.values);
72
+ history.push(redirect || '/admin');
78
73
  },
79
74
  };
80
75
  };
@@ -1,4 +1,3 @@
1
- import { useCookieState } from 'ahooks';
2
1
  import { Menu, Select } from 'antd';
3
2
  import React from 'react';
4
3
  import { useTranslation } from 'react-i18next';
@@ -30,9 +29,6 @@ export const SwitchRole = () => {
30
29
  const api = useAPIClient();
31
30
  const roles = useCurrentRoles();
32
31
  const { t } = useTranslation();
33
- const [roleName, setRoleName] = useCookieState('currentRoleName', {
34
- defaultValue: roles?.find((role) => role.default)?.name,
35
- });
36
32
  if (roles.length <= 1) {
37
33
  return null;
38
34
  }
@@ -47,9 +43,9 @@ export const SwitchRole = () => {
47
43
  value: 'name',
48
44
  }}
49
45
  options={roles}
50
- value={roleName}
46
+ value={api.auth.role}
51
47
  onChange={async (roleName) => {
52
- setRoleName(roleName);
48
+ api.auth.setRole(roleName);
53
49
  await api.resource('users').setDefaultRole({ values: { roleName } });
54
50
  window.location.href = '/';
55
51
  }}
@@ -26,7 +26,7 @@ const FieldsSelect = observer((props) => {
26
26
  && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : true)
27
27
  ))
28
28
  .map(field => (
29
- <Select.Option value={field.name}>{compile(field.uiSchema?.title)}</Select.Option>
29
+ <Select.Option key={field.name} value={field.name}>{compile(field.uiSchema?.title)}</Select.Option>
30
30
  ))}
31
31
  </Select>
32
32
  );
@@ -8,6 +8,7 @@ import { message, Tag } from "antd";
8
8
  import { SchemaComponent, useActionContext, useAPIClient, useCompile, useRecord, useRequest, useResourceActionContext } from '../../';
9
9
  import collection from './collection';
10
10
  import { nodeCardClass, nodeMetaClass } from "../style";
11
+ import schedule from "./schedule";
11
12
 
12
13
 
13
14
  function useUpdateConfigAction() {
@@ -50,6 +51,7 @@ export interface Trigger {
50
51
  export const triggers = new Registry<Trigger>();
51
52
 
52
53
  triggers.register(collection.type, collection);
54
+ triggers.register(schedule.type, schedule);
53
55
 
54
56
  export const TriggerConfig = () => {
55
57
  const { t } = useTranslation();