@abtnode/ux 1.16.26-beta-5251ab18 → 1.16.26-beta-351de484

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 (87) hide show
  1. package/es/blocklet/{oauth → authentication/federated}/federated-detail-dialog.js +2 -2
  2. package/es/blocklet/{oauth → authentication/federated}/federated-join-dialog.js +2 -2
  3. package/es/blocklet/{oauth → authentication/federated}/federated-site-list.js +3 -3
  4. package/es/blocklet/{oauth/federated.js → authentication/federated/index.js} +1 -1
  5. package/es/blocklet/{oauth → authentication}/index.js +7 -5
  6. package/es/blocklet/authentication/oauth/apple.js +198 -0
  7. package/es/blocklet/{oauth → authentication/oauth}/auth0.js +27 -7
  8. package/es/blocklet/authentication/oauth/drag-item.js +177 -0
  9. package/es/blocklet/authentication/oauth/github.js +145 -0
  10. package/es/blocklet/authentication/oauth/google.js +144 -0
  11. package/es/blocklet/authentication/oauth/index.js +122 -0
  12. package/es/blocklet/preferences/index.js +6 -6
  13. package/es/blocklet/publish/connect-store-list.js +8 -6
  14. package/es/blocklet/publish/create-release.js +16 -7
  15. package/es/blocklet/publish/project-list.js +30 -3
  16. package/es/blocklet/storage/action.js +8 -4
  17. package/es/blocklet/storage/item.js +2 -1
  18. package/es/confirm.js +5 -2
  19. package/es/contexts/blocklet-storage.js +0 -4
  20. package/es/layout/feedback.js +7 -4
  21. package/es/locales/ar.js +34 -5
  22. package/es/locales/de.js +35 -6
  23. package/es/locales/en.js +34 -5
  24. package/es/locales/es.js +35 -6
  25. package/es/locales/fr.js +35 -6
  26. package/es/locales/hi.js +35 -6
  27. package/es/locales/i18n.db +0 -0
  28. package/es/locales/id.js +35 -6
  29. package/es/locales/ja.js +34 -5
  30. package/es/locales/ko.js +35 -6
  31. package/es/locales/pt.js +35 -6
  32. package/es/locales/ru.js +34 -5
  33. package/es/locales/th.js +34 -5
  34. package/es/locales/vi.js +34 -5
  35. package/es/locales/zh-tw.js +34 -5
  36. package/es/locales/zh.js +35 -6
  37. package/es/store/connect-actions.js +14 -5
  38. package/es/store/delete.js +7 -3
  39. package/es/store/item.js +99 -20
  40. package/es/team/members/index.js +16 -13
  41. package/es/team/members/member.js +2 -7
  42. package/lib/blocklet/{oauth → authentication/federated}/federated-detail-dialog.js +2 -2
  43. package/lib/blocklet/{oauth → authentication/federated}/federated-join-dialog.js +2 -2
  44. package/lib/blocklet/{oauth → authentication/federated}/federated-site-list.js +3 -3
  45. package/lib/blocklet/{oauth/federated.js → authentication/federated/index.js} +1 -1
  46. package/lib/blocklet/{oauth → authentication}/index.js +7 -5
  47. package/lib/blocklet/authentication/oauth/apple.js +226 -0
  48. package/lib/blocklet/authentication/oauth/auth0.js +189 -0
  49. package/lib/blocklet/authentication/oauth/drag-item.js +185 -0
  50. package/lib/blocklet/{oauth/auth0.js → authentication/oauth/github.js} +26 -25
  51. package/lib/blocklet/authentication/oauth/google.js +166 -0
  52. package/lib/blocklet/authentication/oauth/index.js +136 -0
  53. package/lib/blocklet/preferences/index.js +6 -6
  54. package/lib/blocklet/publish/connect-store-list.js +9 -8
  55. package/lib/blocklet/publish/create-release.js +16 -6
  56. package/lib/blocklet/publish/project-list.js +29 -2
  57. package/lib/blocklet/storage/action.js +10 -6
  58. package/lib/blocklet/storage/item.js +2 -1
  59. package/lib/confirm.js +7 -4
  60. package/lib/contexts/blocklet-storage.js +0 -4
  61. package/lib/layout/feedback.js +6 -3
  62. package/lib/locales/ar.js +34 -5
  63. package/lib/locales/de.js +35 -6
  64. package/lib/locales/en.js +34 -5
  65. package/lib/locales/es.js +35 -6
  66. package/lib/locales/fr.js +35 -6
  67. package/lib/locales/hi.js +35 -6
  68. package/lib/locales/i18n.db +0 -0
  69. package/lib/locales/id.js +35 -6
  70. package/lib/locales/ja.js +34 -5
  71. package/lib/locales/ko.js +35 -6
  72. package/lib/locales/pt.js +35 -6
  73. package/lib/locales/ru.js +34 -5
  74. package/lib/locales/th.js +34 -5
  75. package/lib/locales/vi.js +34 -5
  76. package/lib/locales/zh-tw.js +34 -5
  77. package/lib/locales/zh.js +35 -6
  78. package/lib/store/connect-actions.js +14 -5
  79. package/lib/store/delete.js +7 -3
  80. package/lib/store/item.js +111 -19
  81. package/lib/team/members/index.js +13 -11
  82. package/lib/team/members/member.js +1 -6
  83. package/package.json +32 -22
  84. /package/es/blocklet/{oauth → authentication}/common-settings.js +0 -0
  85. /package/es/blocklet/{oauth → authentication/federated}/federated-invite-dialog.js +0 -0
  86. /package/lib/blocklet/{oauth → authentication}/common-settings.js +0 -0
  87. /package/lib/blocklet/{oauth → authentication/federated}/federated-invite-dialog.js +0 -0
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _material = require("@mui/material");
8
+ var _pick = _interopRequireDefault(require("lodash/pick"));
9
+ var _ahooks = require("ahooks");
10
+ var _reactHookForm = require("react-hook-form");
11
+ var _context = require("@arcblock/ux/lib/Locale/context");
12
+ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
13
+ var _node = require("../../../contexts/node");
14
+ var _blocklet = require("../../../contexts/blocklet");
15
+ var _switchControl = _interopRequireDefault(require("../../component/switch-control"));
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
+ function OAuthAuth0() {
24
+ var _blocklet$meta, _blocklet$settings;
25
+ const {
26
+ api
27
+ } = (0, _node.useNodeContext)();
28
+ const {
29
+ blocklet
30
+ } = (0, _blocklet.useBlockletContext)();
31
+ const {
32
+ t
33
+ } = (0, _context.useLocaleContext)();
34
+ const did = blocklet === null || blocklet === void 0 || (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did;
35
+ const auth0 = Object.assign({
36
+ enabled: false,
37
+ domain: '',
38
+ clientId: '',
39
+ clientSecret: ''
40
+ }, (blocklet === null || blocklet === void 0 || (_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 || (_blocklet$settings = _blocklet$settings.oauth) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.auth0) || {});
41
+ const {
42
+ handleSubmit,
43
+ control,
44
+ formState,
45
+ watch,
46
+ reset
47
+ } = (0, _reactHookForm.useForm)({
48
+ defaultValues: (0, _pick.default)(auth0, ['domain', 'clientId', 'clientSecret', 'enabled'])
49
+ });
50
+ const enabled = watch('enabled');
51
+ const onSubmit = (0, _ahooks.useMemoizedFn)(async data => {
52
+ try {
53
+ var _blockletChanged$sett;
54
+ const {
55
+ blocklet: blockletChanged
56
+ } = await api.configOAuth({
57
+ input: {
58
+ did,
59
+ oauth: JSON.stringify({
60
+ auth0: data
61
+ })
62
+ }
63
+ });
64
+ const defaultValues = Object.assign({
65
+ enabled: false,
66
+ domain: '',
67
+ clientId: '',
68
+ clientSecret: ''
69
+ }, (blockletChanged === null || blockletChanged === void 0 || (_blockletChanged$sett = blockletChanged.settings) === null || _blockletChanged$sett === void 0 || (_blockletChanged$sett = _blockletChanged$sett.oauth) === null || _blockletChanged$sett === void 0 ? void 0 : _blockletChanged$sett.auth0) || {});
70
+ // 将当前表单的默认值重置为新的数据,这样能够修正页面的 isDirty 数据
71
+ reset(defaultValues);
72
+ _Toast.default.success(t('oauth.saveSuccess'));
73
+ } catch (err) {
74
+ _Toast.default.error(err.message || t('oauth.saveFailed'));
75
+ }
76
+ });
77
+ const validateDomain = (0, _ahooks.useMemoizedFn)(val => {
78
+ if (!(val !== null && val !== void 0 && val.trim())) {
79
+ return t('oauth.auth0.domainDescribe');
80
+ }
81
+ return true;
82
+ });
83
+ const validateClientId = (0, _ahooks.useMemoizedFn)(val => {
84
+ if (!(val !== null && val !== void 0 && val.trim())) {
85
+ return t('oauth.auth0.clientIdDescribe');
86
+ }
87
+ return true;
88
+ });
89
+ const noop = (0, _ahooks.useMemoizedFn)(() => true);
90
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
91
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
92
+ onSubmit: handleSubmit(onSubmit),
93
+ disabled: true,
94
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
95
+ name: "enabled",
96
+ control: control,
97
+ render: _ref => {
98
+ let {
99
+ field
100
+ } = _ref;
101
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControlLabel, {
102
+ control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_switchControl.default, _objectSpread({
103
+ checked: field.value,
104
+ style: {
105
+ marginRight: '6px'
106
+ }
107
+ }, field)),
108
+ label: t('oauth.auth0.enable'),
109
+ sx: {
110
+ marginBottom: 2,
111
+ ml: 1
112
+ }
113
+ });
114
+ }
115
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
116
+ name: "domain",
117
+ control: control,
118
+ rules: {
119
+ validate: enabled ? validateDomain : noop
120
+ },
121
+ render: _ref2 => {
122
+ var _formState$errors$fie;
123
+ let {
124
+ field
125
+ } = _ref2;
126
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
127
+ fullWidth: true,
128
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
129
+ label: t('oauth.auth0.domain'),
130
+ error: !!formState.errors[field.name],
131
+ helperText: ((_formState$errors$fie = formState.errors[field.name]) === null || _formState$errors$fie === void 0 ? void 0 : _formState$errors$fie.message) || ' ',
132
+ disabled: !enabled
133
+ }))
134
+ });
135
+ }
136
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
137
+ name: "clientId",
138
+ control: control,
139
+ rules: {
140
+ validate: enabled ? validateClientId : noop
141
+ },
142
+ render: _ref3 => {
143
+ var _formState$errors$fie2;
144
+ let {
145
+ field
146
+ } = _ref3;
147
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
148
+ fullWidth: true,
149
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
150
+ error: !!formState.errors[field.name],
151
+ label: t('oauth.auth0.clientId'),
152
+ helperText: ((_formState$errors$fie2 = formState.errors[field.name]) === null || _formState$errors$fie2 === void 0 ? void 0 : _formState$errors$fie2.message) || ' ',
153
+ disabled: !enabled
154
+ }))
155
+ });
156
+ }
157
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
158
+ name: "clientSecret",
159
+ control: control,
160
+ rules: {
161
+ validate: noop
162
+ },
163
+ render: _ref4 => {
164
+ var _formState$errors$fie3;
165
+ let {
166
+ field
167
+ } = _ref4;
168
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
169
+ fullWidth: true,
170
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
171
+ type: "password",
172
+ error: !!formState.errors[field.name],
173
+ label: t('oauth.auth0.clientSecret'),
174
+ helperText: ((_formState$errors$fie3 = formState.errors[field.name]) === null || _formState$errors$fie3 === void 0 ? void 0 : _formState$errors$fie3.message) || ' ',
175
+ disabled: !enabled
176
+ }))
177
+ });
178
+ }
179
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
180
+ type: "submit",
181
+ variant: "contained",
182
+ onSubmit: handleSubmit(onSubmit),
183
+ disabled: !formState.isDirty,
184
+ children: t('oauth.save')
185
+ })]
186
+ })
187
+ });
188
+ }
189
+ var _default = exports.default = OAuthAuth0;
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = DragItem;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _material = require("@mui/material");
9
+ var _react = require("react");
10
+ var _reactDnd = require("react-dnd");
11
+ var _Colors = require("@arcblock/ux/lib/Colors");
12
+ var _react2 = require("@iconify/react");
13
+ var _dragIndicator = _interopRequireDefault(require("@iconify-icons/material-symbols/drag-indicator"));
14
+ var _keyboardArrowDownRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/keyboard-arrow-down-rounded"));
15
+ var _ahooks = require("ahooks");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ // eslint-disable-next-line no-unused-vars
19
+ function DragItem(_ref) {
20
+ let {
21
+ title,
22
+ id,
23
+ children,
24
+ index,
25
+ onMove,
26
+ defaultExpand,
27
+ onEnd
28
+ } = _ref;
29
+ const [expand, setExpand] = (0, _react.useState)(defaultExpand);
30
+ const dropRef = (0, _react.useRef)(null);
31
+ const dragRef = (0, _react.useRef)(null);
32
+ const [{
33
+ handlerId
34
+ }, drop] = (0, _reactDnd.useDrop)({
35
+ accept: 'dragItem',
36
+ collect(monitor) {
37
+ return {
38
+ handlerId: monitor.getHandlerId()
39
+ };
40
+ },
41
+ hover(item, monitor) {
42
+ var _dropRef$current, _dragRef$current;
43
+ if (!dropRef.current) {
44
+ return;
45
+ }
46
+ const dragIndex = item.index;
47
+ const hoverIndex = index;
48
+ // Don't replace items with themselves
49
+ if (dragIndex === hoverIndex) {
50
+ return;
51
+ }
52
+ // Determine rectangle on screen
53
+ const hoverBoundingRect = (_dropRef$current = dropRef.current) === null || _dropRef$current === void 0 ? void 0 : _dropRef$current.getBoundingClientRect();
54
+ const dragBoundingRect = (_dragRef$current = dragRef.current) === null || _dragRef$current === void 0 ? void 0 : _dragRef$current.getBoundingClientRect();
55
+ // 需要拖动多少距离才能触发位置变更
56
+ const dragY = (dragBoundingRect.bottom - dragBoundingRect.top) / 2;
57
+ // Determine mouse position
58
+ const clientOffset = monitor.getClientOffset();
59
+ // Get pixels to the top
60
+ const hoverClientY = clientOffset.y - hoverBoundingRect.top;
61
+ // Only perform the move when the mouse has crossed half of the items height
62
+ // When dragging downwards, only move when the cursor is below 50%
63
+ // When dragging upwards, only move when the cursor is above 50%
64
+ // Dragging downwards
65
+ if (dragIndex < hoverIndex && hoverClientY < dragY) {
66
+ return;
67
+ }
68
+ // Dragging upwards
69
+ if (dragIndex > hoverIndex && hoverClientY > dragY) {
70
+ return;
71
+ }
72
+ // Time to actually perform the action
73
+ onMove(dragIndex, hoverIndex);
74
+ // Note: we're mutating the monitor item here!
75
+ // Generally it's better to avoid mutations,
76
+ // but it's good here for the sake of performance
77
+ // to avoid expensive index searches.
78
+ item.index = hoverIndex;
79
+ }
80
+ });
81
+ const [{
82
+ isDragging
83
+ }, drag] = (0, _reactDnd.useDrag)({
84
+ item: {
85
+ index,
86
+ type: 'dragItem'
87
+ },
88
+ collect: monitor => ({
89
+ isDragging: monitor.isDragging()
90
+ }),
91
+ end: onEnd
92
+ });
93
+ drag(dragRef);
94
+ drop(dropRef);
95
+ const opacity = isDragging ? 0.5 : 1;
96
+ const toggleExpand = (0, _ahooks.useMemoizedFn)(e => {
97
+ e.preventDefault();
98
+ e.stopPropagation();
99
+ setExpand(!expand);
100
+ });
101
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
102
+ ref: dropRef,
103
+ sx: {
104
+ borderBottom: "1px solid ".concat(_Colors.temp.lineBorderStrong)
105
+ },
106
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
107
+ sx: {
108
+ cursor: 'pointer',
109
+ '&:hover': {
110
+ backgroundColor: _Colors.temp.backgroundsBgSubtileHover
111
+ },
112
+ borderRadius: 2
113
+ },
114
+ ref: dragRef,
115
+ "data-handler-id": handlerId,
116
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
117
+ sx: {
118
+ py: 1.5,
119
+ px: 1,
120
+ opacity,
121
+ display: 'flex',
122
+ alignItems: 'center',
123
+ gap: 0.5
124
+ },
125
+ draggable: false,
126
+ onClick: toggleExpand,
127
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
128
+ sx: {
129
+ pointerEvents: 'auto',
130
+ cursor: 'grab',
131
+ '&:active': {
132
+ cursor: 'grabbing'
133
+ },
134
+ fontSize: 0,
135
+ color: _Colors.temp.textMuted,
136
+ '&:hover': {
137
+ color: _Colors.temp.textSubtitle
138
+ }
139
+ },
140
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
141
+ fontSize: 20,
142
+ icon: _dragIndicator.default
143
+ })
144
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
145
+ sx: {
146
+ flex: 1
147
+ },
148
+ children: title
149
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
150
+ size: "small",
151
+ sx: {
152
+ pointerEvents: 'auto',
153
+ transform: expand ? '' : 'rotate(180deg)',
154
+ transition: 'transform 0.3s ease'
155
+ },
156
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Icon, {
157
+ icon: _keyboardArrowDownRounded.default,
158
+ style: {
159
+ transform: 'scale(1.5)'
160
+ }
161
+ })
162
+ })]
163
+ })
164
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
165
+ sx: {
166
+ pl: 4,
167
+ py: 1,
168
+ display: expand ? 'block' : 'none'
169
+ },
170
+ children: children
171
+ })]
172
+ });
173
+ }
174
+ DragItem.propTypes = {
175
+ title: _propTypes.default.string.isRequired,
176
+ id: _propTypes.default.string.isRequired,
177
+ children: _propTypes.default.node.isRequired,
178
+ index: _propTypes.default.number.isRequired,
179
+ onMove: _propTypes.default.func.isRequired,
180
+ onEnd: _propTypes.default.func.isRequired,
181
+ defaultExpand: _propTypes.default.bool
182
+ };
183
+ DragItem.defaultProps = {
184
+ defaultExpand: true
185
+ };
@@ -10,9 +10,9 @@ var _ahooks = require("ahooks");
10
10
  var _reactHookForm = require("react-hook-form");
11
11
  var _context = require("@arcblock/ux/lib/Locale/context");
12
12
  var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
13
- var _node = require("../../contexts/node");
14
- var _blocklet = require("../../contexts/blocklet");
15
- var _switchControl = _interopRequireDefault(require("../component/switch-control"));
13
+ var _node = require("../../../contexts/node");
14
+ var _blocklet = require("../../../contexts/blocklet");
15
+ var _switchControl = _interopRequireDefault(require("../../component/switch-control"));
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -20,7 +20,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
20
20
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
22
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
- function OAuthAuth0() {
23
+ function OAuthGithub() {
24
24
  var _blocklet$meta, _blocklet$settings;
25
25
  const {
26
26
  api
@@ -33,11 +33,11 @@ function OAuthAuth0() {
33
33
  } = (0, _context.useLocaleContext)();
34
34
  // TODO: @zhanghan 将来需要换成 permanent did
35
35
  const did = blocklet === null || blocklet === void 0 || (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did;
36
- const auth0 = Object.assign({
36
+ const github = Object.assign({
37
37
  enabled: false,
38
- domain: '',
39
- clientId: ''
40
- }, (blocklet === null || blocklet === void 0 || (_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 || (_blocklet$settings = _blocklet$settings.oauth) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.auth0) || {});
38
+ clientId: '',
39
+ clientSecret: ''
40
+ }, (blocklet === null || blocklet === void 0 || (_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 || (_blocklet$settings = _blocklet$settings.oauth) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.github) || {});
41
41
  const {
42
42
  handleSubmit,
43
43
  control,
@@ -45,7 +45,7 @@ function OAuthAuth0() {
45
45
  watch,
46
46
  reset
47
47
  } = (0, _reactHookForm.useForm)({
48
- defaultValues: (0, _pick.default)(auth0, ['domain', 'clientId', 'enabled'])
48
+ defaultValues: (0, _pick.default)(github, ['clientSecret', 'clientId', 'enabled'])
49
49
  });
50
50
  const enabled = watch('enabled');
51
51
  const onSubmit = (0, _ahooks.useMemoizedFn)(async data => {
@@ -57,15 +57,15 @@ function OAuthAuth0() {
57
57
  input: {
58
58
  did,
59
59
  oauth: JSON.stringify({
60
- auth0: data
60
+ github: data
61
61
  })
62
62
  }
63
63
  });
64
64
  const defaultValues = Object.assign({
65
65
  enabled: false,
66
- domain: '',
67
- clientId: ''
68
- }, (blockletChanged === null || blockletChanged === void 0 || (_blockletChanged$sett = blockletChanged.settings) === null || _blockletChanged$sett === void 0 || (_blockletChanged$sett = _blockletChanged$sett.oauth) === null || _blockletChanged$sett === void 0 ? void 0 : _blockletChanged$sett.auth0) || {});
66
+ clientId: '',
67
+ clientSecret: ''
68
+ }, (blockletChanged === null || blockletChanged === void 0 || (_blockletChanged$sett = blockletChanged.settings) === null || _blockletChanged$sett === void 0 || (_blockletChanged$sett = _blockletChanged$sett.oauth) === null || _blockletChanged$sett === void 0 ? void 0 : _blockletChanged$sett.github) || {});
69
69
  // 将当前表单的默认值重置为新的数据,这样能够修正页面的 isDirty 数据
70
70
  reset(defaultValues);
71
71
  _Toast.default.success(t('oauth.saveSuccess'));
@@ -73,15 +73,15 @@ function OAuthAuth0() {
73
73
  _Toast.default.error(err.message || t('oauth.saveFailed'));
74
74
  }
75
75
  });
76
- const validateDomain = (0, _ahooks.useMemoizedFn)(val => {
76
+ const validateClientId = (0, _ahooks.useMemoizedFn)(val => {
77
77
  if (!(val !== null && val !== void 0 && val.trim())) {
78
- return t('oauth.auth0.domainDescribe');
78
+ return t('oauth.github.clientIdDescribe');
79
79
  }
80
80
  return true;
81
81
  });
82
- const validateClientId = (0, _ahooks.useMemoizedFn)(val => {
82
+ const validateClientSecret = (0, _ahooks.useMemoizedFn)(val => {
83
83
  if (!(val !== null && val !== void 0 && val.trim())) {
84
- return t('oauth.auth0.clientIdDescribe');
84
+ return t('oauth.github.clientSecretDescribe');
85
85
  }
86
86
  return true;
87
87
  });
@@ -104,7 +104,7 @@ function OAuthAuth0() {
104
104
  marginRight: '6px'
105
105
  }
106
106
  }, field)),
107
- label: t('oauth.auth0.enable'),
107
+ label: t('oauth.github.enable'),
108
108
  sx: {
109
109
  marginBottom: 2,
110
110
  ml: 1
@@ -112,10 +112,10 @@ function OAuthAuth0() {
112
112
  });
113
113
  }
114
114
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
115
- name: "domain",
115
+ name: "clientId",
116
116
  control: control,
117
117
  rules: {
118
- validate: enabled ? validateDomain : noop
118
+ validate: enabled ? validateClientId : noop
119
119
  },
120
120
  render: _ref2 => {
121
121
  var _formState$errors$fie;
@@ -125,18 +125,18 @@ function OAuthAuth0() {
125
125
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
126
126
  fullWidth: true,
127
127
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
128
- label: t('oauth.auth0.domain'),
129
128
  error: !!formState.errors[field.name],
129
+ label: t('oauth.github.clientId'),
130
130
  helperText: ((_formState$errors$fie = formState.errors[field.name]) === null || _formState$errors$fie === void 0 ? void 0 : _formState$errors$fie.message) || ' ',
131
131
  disabled: !enabled
132
132
  }))
133
133
  });
134
134
  }
135
135
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
136
- name: "clientId",
136
+ name: "clientSecret",
137
137
  control: control,
138
138
  rules: {
139
- validate: enabled ? validateClientId : noop
139
+ validate: enabled ? validateClientSecret : noop
140
140
  },
141
141
  render: _ref3 => {
142
142
  var _formState$errors$fie2;
@@ -146,8 +146,9 @@ function OAuthAuth0() {
146
146
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, {
147
147
  fullWidth: true,
148
148
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, field), {}, {
149
+ type: "password",
150
+ label: t('oauth.github.clientSecret'),
149
151
  error: !!formState.errors[field.name],
150
- label: t('oauth.auth0.clientId'),
151
152
  helperText: ((_formState$errors$fie2 = formState.errors[field.name]) === null || _formState$errors$fie2 === void 0 ? void 0 : _formState$errors$fie2.message) || ' ',
152
153
  disabled: !enabled
153
154
  }))
@@ -163,4 +164,4 @@ function OAuthAuth0() {
163
164
  })
164
165
  });
165
166
  }
166
- var _default = exports.default = OAuthAuth0;
167
+ var _default = exports.default = OAuthGithub;