@atlaskit/link-create 1.15.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/CONTRIBUTING.md +3 -0
- package/dist/cjs/controllers/callback-context/main.js +7 -14
- package/dist/cjs/ui/create-form/async-select/main.js +2 -5
- package/dist/cjs/ui/create-form/main.js +3 -4
- package/dist/cjs/ui/link-create/error-boundary/index.js +5 -14
- package/dist/cjs/ui/link-create/main.js +16 -49
- package/dist/cjs/ui/main.js +2 -4
- package/dist/es2019/controllers/callback-context/main.js +7 -14
- package/dist/es2019/ui/create-form/async-select/main.js +2 -5
- package/dist/es2019/ui/create-form/main.js +3 -4
- package/dist/es2019/ui/link-create/error-boundary/index.js +5 -14
- package/dist/es2019/ui/link-create/main.js +3 -21
- package/dist/es2019/ui/main.js +3 -5
- package/dist/esm/controllers/callback-context/main.js +7 -14
- package/dist/esm/ui/create-form/async-select/main.js +2 -5
- package/dist/esm/ui/create-form/main.js +3 -4
- package/dist/esm/ui/link-create/error-boundary/index.js +5 -14
- package/dist/esm/ui/link-create/main.js +17 -50
- package/dist/esm/ui/main.js +3 -5
- package/dist/types/common/types.d.ts +2 -2
- package/dist/types/common/ui/Button/index.d.ts +1 -1
- package/dist/types/common/ui/ModalDialog/index.d.ts +1 -1
- package/dist/types/common/utils/analytics/components.d.ts +1 -1
- package/dist/types/common/utils/analytics/context.d.ts +2 -2
- package/dist/types/common/utils/form/index.d.ts +1 -1
- package/dist/types/common/utils/locale/fetch-messages-for-locale.d.ts +1 -1
- package/dist/types/controllers/callback-context/main.d.ts +2 -2
- package/dist/types/controllers/create-field/main.d.ts +1 -1
- package/dist/types/controllers/create-field/types.d.ts +2 -2
- package/dist/types/controllers/edit-post-create-context/index.d.ts +1 -1
- package/dist/types/controllers/form-context/main.d.ts +2 -2
- package/dist/types/controllers/plugin-context/index.d.ts +1 -1
- package/dist/types/ui/create-form/async-select/main.d.ts +2 -2
- package/dist/types/ui/create-form/async-select/types.d.ts +2 -2
- package/dist/types/ui/create-form/form-loader/main.d.ts +1 -1
- package/dist/types/ui/create-form/main.d.ts +1 -1
- package/dist/types/ui/create-form/select/main.d.ts +2 -2
- package/dist/types/ui/create-form/select/types.d.ts +2 -2
- package/dist/types/ui/create-form/textfield/main.d.ts +1 -1
- package/dist/types/ui/create-form/textfield/types.d.ts +2 -2
- package/dist/types/ui/create-form/utils/index.d.ts +1 -1
- package/dist/types/ui/link-create/error-boundary/error-boundary-base/index.d.ts +1 -1
- package/dist/types/ui/link-create/error-boundary/index.d.ts +1 -1
- package/dist/types/ui/link-create/main.d.ts +1 -1
- package/dist/types/ui/main.d.ts +2 -2
- package/dist/types-ts4.5/common/types.d.ts +2 -2
- package/dist/types-ts4.5/common/ui/Button/index.d.ts +1 -1
- package/dist/types-ts4.5/common/ui/ModalDialog/index.d.ts +1 -1
- package/dist/types-ts4.5/common/utils/analytics/components.d.ts +1 -1
- package/dist/types-ts4.5/common/utils/analytics/context.d.ts +2 -2
- package/dist/types-ts4.5/common/utils/form/index.d.ts +1 -1
- package/dist/types-ts4.5/common/utils/locale/fetch-messages-for-locale.d.ts +1 -1
- package/dist/types-ts4.5/controllers/callback-context/main.d.ts +2 -2
- package/dist/types-ts4.5/controllers/create-field/main.d.ts +1 -1
- package/dist/types-ts4.5/controllers/create-field/types.d.ts +2 -2
- package/dist/types-ts4.5/controllers/edit-post-create-context/index.d.ts +1 -1
- package/dist/types-ts4.5/controllers/form-context/main.d.ts +2 -2
- package/dist/types-ts4.5/controllers/plugin-context/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/create-form/async-select/main.d.ts +2 -2
- package/dist/types-ts4.5/ui/create-form/async-select/types.d.ts +2 -2
- package/dist/types-ts4.5/ui/create-form/form-loader/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/create-form/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/create-form/select/main.d.ts +2 -2
- package/dist/types-ts4.5/ui/create-form/select/types.d.ts +2 -2
- package/dist/types-ts4.5/ui/create-form/textfield/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/create-form/textfield/types.d.ts +2 -2
- package/dist/types-ts4.5/ui/create-form/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/link-create/error-boundary/error-boundary-base/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/link-create/error-boundary/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/link-create/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/main.d.ts +2 -2
- package/example-helpers/mock-plugin-form.tsx +2 -2
- package/package.json +9 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @atlaskit/link-create
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#89064](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89064)
|
|
8
|
+
[`545c87a31801`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/545c87a31801) -
|
|
9
|
+
Cleans up the feature flag implemented in 1.11.0 which is now a breaking change for plugins (not
|
|
10
|
+
for direct consumers).
|
|
11
|
+
|
|
12
|
+
Improves observability over failure cases when plugins call `onFailure()`, or throw an error to
|
|
13
|
+
be caught by `<LinkCreate />`'s internal error boundary.
|
|
14
|
+
|
|
15
|
+
Errors provided via `onFailure()` from plugins no longer play a role in displaying an error
|
|
16
|
+
message to users in the `<CreateForm />`.
|
|
17
|
+
|
|
18
|
+
When handling form submission errors, plugin should return an object of error messages in the
|
|
19
|
+
`onSubmit()` handler provided to the `CreateForm`. To set a generic error, use the newly exposed
|
|
20
|
+
`FORM_ERROR`
|
|
21
|
+
[see react-final-form](https://final-form.org/docs/react-final-form/types/FormProps#submission-errors)
|
|
22
|
+
to define an error message on the object resolved `onSubmit`.
|
|
23
|
+
|
|
24
|
+
Example:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { FORM_ERROR } from '@atlaskit/link-create';
|
|
28
|
+
|
|
29
|
+
<CreateForm
|
|
30
|
+
onSubmit={(data) => {
|
|
31
|
+
return {
|
|
32
|
+
[FORM_ERROR]: 'Something bad happened!',
|
|
33
|
+
};
|
|
34
|
+
}}
|
|
35
|
+
/>;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- [#89064](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89064)
|
|
41
|
+
[`1a6df7c186bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1a6df7c186bf) -
|
|
42
|
+
Adds required fields instruction to start of link create form.
|
|
43
|
+
|
|
44
|
+
## 1.15.9
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies
|
|
49
|
+
|
|
3
50
|
## 1.15.8
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/CONTRIBUTING.md
ADDED
|
@@ -11,7 +11,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
14
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
14
|
var _constants = require("../../common/constants");
|
|
16
15
|
var _analytics = _interopRequireDefault(require("../../common/utils/analytics/analytics.codegen"));
|
|
17
16
|
var _errors = require("../../common/utils/errors");
|
|
@@ -28,9 +27,7 @@ var LinkCreateCallbackProvider = exports.LinkCreateCallbackProvider = function L
|
|
|
28
27
|
onCancel = _ref.onCancel;
|
|
29
28
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
30
29
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
31
|
-
var experience = (0,
|
|
32
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
33
|
-
(0, _experienceTracker.useExperience)() : null;
|
|
30
|
+
var experience = (0, _experienceTracker.useExperience)();
|
|
34
31
|
var handleCreate = (0, _react.useMemo)(function () {
|
|
35
32
|
return {
|
|
36
33
|
onCreate: function () {
|
|
@@ -39,13 +36,11 @@ var LinkCreateCallbackProvider = exports.LinkCreateCallbackProvider = function L
|
|
|
39
36
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
40
37
|
while (1) switch (_context.prev = _context.next) {
|
|
41
38
|
case 0:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
experience === null || experience === void 0 || experience.success();
|
|
48
|
-
}
|
|
39
|
+
/**
|
|
40
|
+
* We consider the experience successful once we have
|
|
41
|
+
* successfully created an object
|
|
42
|
+
*/
|
|
43
|
+
experience === null || experience === void 0 || experience.success();
|
|
49
44
|
objectId = result.objectId, objectType = result.objectType;
|
|
50
45
|
createAnalyticsEvent((0, _analytics.default)('track.object.created.linkCreate', {
|
|
51
46
|
objectId: objectId,
|
|
@@ -80,9 +75,7 @@ var LinkCreateCallbackProvider = exports.LinkCreateCallbackProvider = function L
|
|
|
80
75
|
createAnalyticsEvent((0, _analytics.default)('track.object.createFailed.linkCreate', {
|
|
81
76
|
failureType: (0, _errors.getErrorType)(error)
|
|
82
77
|
})).fire(_constants.ANALYTICS_CHANNEL);
|
|
83
|
-
|
|
84
|
-
experience === null || experience === void 0 || experience.failure(error);
|
|
85
|
-
}
|
|
78
|
+
experience === null || experience === void 0 || experience.failure(error);
|
|
86
79
|
_onFailure && _onFailure(error);
|
|
87
80
|
case 3:
|
|
88
81
|
case "end":
|
|
@@ -16,7 +16,6 @@ var _react2 = require("@emotion/react");
|
|
|
16
16
|
var _debouncePromise = _interopRequireDefault(require("debounce-promise"));
|
|
17
17
|
var _reactFinalForm = require("react-final-form");
|
|
18
18
|
var _reactIntlNext = require("react-intl-next");
|
|
19
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
19
|
var _select = require("@atlaskit/select");
|
|
21
20
|
var _messages = _interopRequireDefault(require("../../../common/messages"));
|
|
22
21
|
var _callbackContext = require("../../../controllers/callback-context");
|
|
@@ -68,9 +67,7 @@ function AsyncSelect(_ref) {
|
|
|
68
67
|
/**
|
|
69
68
|
* This binds experience to fail if async fetch ever fails to load
|
|
70
69
|
*/
|
|
71
|
-
var loadOptions = (0,
|
|
72
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
73
|
-
(0, _react.useMemo)(function () {
|
|
70
|
+
var loadOptions = (0, _react.useMemo)(function () {
|
|
74
71
|
if (loadOptionsFn) {
|
|
75
72
|
return /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
76
73
|
var _args = arguments;
|
|
@@ -95,7 +92,7 @@ function AsyncSelect(_ref) {
|
|
|
95
92
|
}, _callee, null, [[0, 6]]);
|
|
96
93
|
}));
|
|
97
94
|
}
|
|
98
|
-
}, [intl, onFailure, loadOptionsFn, setFormErrorMessage])
|
|
95
|
+
}, [intl, onFailure, loadOptionsFn, setFormErrorMessage]);
|
|
99
96
|
(0, _react.useEffect)(function () {
|
|
100
97
|
var current = true;
|
|
101
98
|
var fetch = /*#__PURE__*/function () {
|
|
@@ -16,7 +16,6 @@ var _finalForm = require("final-form");
|
|
|
16
16
|
var _reactFinalForm = require("react-final-form");
|
|
17
17
|
var _reactIntlNext = require("react-intl-next");
|
|
18
18
|
var _form = require("@atlaskit/form");
|
|
19
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
19
|
var _primitives = require("@atlaskit/primitives");
|
|
21
20
|
var _constants = require("../../common/constants");
|
|
22
21
|
var _messages = _interopRequireDefault(require("../../common/messages"));
|
|
@@ -123,7 +122,7 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
|
|
|
123
122
|
return (0, _react2.jsx)(_formLoader.CreateFormLoader, null);
|
|
124
123
|
}
|
|
125
124
|
return (0, _react2.jsx)(_reactFinalForm.Form, {
|
|
126
|
-
onSubmit:
|
|
125
|
+
onSubmit: handleSubmitWithErrorHandling,
|
|
127
126
|
initialValues: initialValues,
|
|
128
127
|
mutators: {
|
|
129
128
|
setField: function setField(args, state, tools) {
|
|
@@ -155,7 +154,7 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
|
|
|
155
154
|
});
|
|
156
155
|
setShouldShowWarning(isModified);
|
|
157
156
|
}
|
|
158
|
-
}), (0,
|
|
157
|
+
}), (0, _react2.jsx)("p", {
|
|
159
158
|
"aria-hidden": "true"
|
|
160
159
|
}, intl.formatMessage(_messages.default.requiredFieldInstruction), ' ', (0, _react2.jsx)(_form.RequiredAsterisk, null)), (0, _react2.jsx)(_primitives.Box, null, children), !hideFooter && (0, _react2.jsx)(_formFooter.CreateFormFooter
|
|
161
160
|
/**
|
|
@@ -164,7 +163,7 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
|
|
|
164
163
|
* default to the `formErrorMessage` that we sometimes use with our own
|
|
165
164
|
* "form context" (only currently used for AsyncSelect field reporting failed loading)
|
|
166
165
|
*/, {
|
|
167
|
-
formErrorMessage:
|
|
166
|
+
formErrorMessage: submitError || formErrorMessage,
|
|
168
167
|
handleCancel: handleCancel,
|
|
169
168
|
testId: testId
|
|
170
169
|
}));
|
|
@@ -8,8 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.ErrorBoundary = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
|
-
var _sentry = require("@atlaskit/linking-common/sentry");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
11
|
var _constants = require("../../../common/constants");
|
|
14
12
|
var _errorBoundaryUi = require("../../../common/ui/error-boundary-ui");
|
|
15
13
|
var _analytics = _interopRequireDefault(require("../../../common/utils/analytics/analytics.codegen"));
|
|
@@ -22,24 +20,17 @@ var ErrorBoundary = exports.ErrorBoundary = function ErrorBoundary(_ref) {
|
|
|
22
20
|
errorComponent = _ref.errorComponent;
|
|
23
21
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
24
22
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
25
|
-
var experience = (0,
|
|
26
|
-
|
|
27
|
-
(0, _experienceTracker.useExperience)() : null;
|
|
28
|
-
var handleError = (0, _react.useCallback)(function (error, info) {
|
|
23
|
+
var experience = (0, _experienceTracker.useExperience)();
|
|
24
|
+
var handleError = (0, _react.useCallback)(function (error) {
|
|
29
25
|
var _window;
|
|
30
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.better-observability')) {
|
|
31
|
-
// Capture exception to Sentry
|
|
32
|
-
(0, _sentry.captureException)(error, 'link-create');
|
|
33
|
-
}
|
|
34
26
|
createAnalyticsEvent((0, _analytics.default)('operational.linkCreate.unhandledErrorCaught', {
|
|
35
27
|
browserInfo: ((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) || 'unknown',
|
|
36
28
|
error: error.name,
|
|
37
29
|
componentStack: 'unknown'
|
|
38
30
|
})).fire(_constants.ANALYTICS_CHANNEL);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
31
|
+
|
|
32
|
+
// Track experience as failed for SLO
|
|
33
|
+
experience === null || experience === void 0 || experience.failure(error);
|
|
43
34
|
}, [createAnalyticsEvent, experience]);
|
|
44
35
|
return /*#__PURE__*/_react.default.createElement(_errorBoundaryBase.BaseErrorBoundary, {
|
|
45
36
|
onError: handleError,
|
|
@@ -7,13 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.TEST_ID = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
var _react2 = require("@emotion/react");
|
|
14
14
|
var _reactIntlNext = require("react-intl-next");
|
|
15
15
|
var _modalDialog = require("@atlaskit/modal-dialog");
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
16
|
var _primitives = require("@atlaskit/primitives");
|
|
18
17
|
var _constants = require("../../common/constants");
|
|
19
18
|
var _ModalDialog = require("../../common/ui/ModalDialog");
|
|
@@ -57,38 +56,6 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
|
|
|
57
56
|
entityKey = _ref2.entityKey,
|
|
58
57
|
modalHero = _ref2.modalHero;
|
|
59
58
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
60
|
-
var _useFormContext = (0, _formContext.useFormContext)(),
|
|
61
|
-
setFormErrorMessage = _useFormContext.setFormErrorMessage;
|
|
62
|
-
var handleCreate = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
63
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(result) {
|
|
64
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
65
|
-
while (1) switch (_context.prev = _context.next) {
|
|
66
|
-
case 0:
|
|
67
|
-
// Reset the form error message
|
|
68
|
-
setFormErrorMessage(undefined);
|
|
69
|
-
if (!onCreate) {
|
|
70
|
-
_context.next = 4;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
_context.next = 4;
|
|
74
|
-
return onCreate(result);
|
|
75
|
-
case 4:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}, _callee);
|
|
80
|
-
}));
|
|
81
|
-
return function (_x) {
|
|
82
|
-
return _ref3.apply(this, arguments);
|
|
83
|
-
};
|
|
84
|
-
}(), [onCreate, setFormErrorMessage]);
|
|
85
|
-
var handleFailure = (0, _react.useCallback)(function (error) {
|
|
86
|
-
// Set the form error message
|
|
87
|
-
if (error instanceof Error) {
|
|
88
|
-
setFormErrorMessage(error.message);
|
|
89
|
-
}
|
|
90
|
-
onFailure && onFailure(error);
|
|
91
|
-
}, [onFailure, setFormErrorMessage]);
|
|
92
59
|
var _useExitWarningModal = (0, _exitWarningModalContext.useExitWarningModal)(),
|
|
93
60
|
getShouldShowWarning = _useExitWarningModal.getShouldShowWarning;
|
|
94
61
|
var _useState = (0, _react.useState)(false),
|
|
@@ -106,8 +73,8 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
|
|
|
106
73
|
return setShowExitWarning(false);
|
|
107
74
|
}, []);
|
|
108
75
|
return (0, _react2.jsx)(_callbackContext.LinkCreateCallbackProvider, {
|
|
109
|
-
onCreate:
|
|
110
|
-
onFailure:
|
|
76
|
+
onCreate: onCreate,
|
|
77
|
+
onFailure: onFailure,
|
|
111
78
|
onCancel: handleCancel
|
|
112
79
|
}, (0, _react2.jsx)(_modalDialog.ModalTransition, null, active && (0, _react2.jsx)(_ModalDialog.Modal, {
|
|
113
80
|
testId: "link-create-modal",
|
|
@@ -148,23 +115,23 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
148
115
|
}, function (pluginsProvider) {
|
|
149
116
|
return (0, _react2.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
|
|
150
117
|
active: !!props.active
|
|
151
|
-
}, function (
|
|
118
|
+
}, function (_ref3) {
|
|
152
119
|
var _pluginsProvider$acti;
|
|
153
|
-
var setEditViewPayload =
|
|
154
|
-
editViewPayload =
|
|
155
|
-
shouldActivateEditView =
|
|
156
|
-
enableEditView =
|
|
120
|
+
var setEditViewPayload = _ref3.setEditViewPayload,
|
|
121
|
+
editViewPayload = _ref3.editViewPayload,
|
|
122
|
+
shouldActivateEditView = _ref3.shouldActivateEditView,
|
|
123
|
+
enableEditView = _ref3.enableEditView;
|
|
157
124
|
return (0, _react2.jsx)(_formContext.FormContextProvider, {
|
|
158
125
|
enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView && props !== null && props !== void 0 && props.onComplete ? enableEditView : undefined
|
|
159
126
|
}, (0, _react2.jsx)(_exitWarningModalContext.ExitWarningModalProvider, null, (0, _react2.jsx)(LinkCreateWithModal, (0, _extends2.default)({}, props, {
|
|
160
127
|
active: props.active && !editViewPayload,
|
|
161
128
|
onCreate: ( /*#__PURE__*/function () {
|
|
162
|
-
var
|
|
129
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload) {
|
|
163
130
|
var _props$onCreate;
|
|
164
|
-
return _regenerator.default.wrap(function
|
|
165
|
-
while (1) switch (
|
|
131
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
132
|
+
while (1) switch (_context.prev = _context.next) {
|
|
166
133
|
case 0:
|
|
167
|
-
|
|
134
|
+
_context.next = 2;
|
|
168
135
|
return (_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload);
|
|
169
136
|
case 2:
|
|
170
137
|
// if onComplete exists then there is an edit flow
|
|
@@ -179,12 +146,12 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
179
146
|
}
|
|
180
147
|
case 3:
|
|
181
148
|
case "end":
|
|
182
|
-
return
|
|
149
|
+
return _context.stop();
|
|
183
150
|
}
|
|
184
|
-
},
|
|
151
|
+
}, _callee);
|
|
185
152
|
}));
|
|
186
|
-
return function (
|
|
187
|
-
return
|
|
153
|
+
return function (_x) {
|
|
154
|
+
return _ref4.apply(this, arguments);
|
|
188
155
|
};
|
|
189
156
|
}()),
|
|
190
157
|
onCloseComplete: function onCloseComplete() {
|
package/dist/cjs/ui/main.js
CHANGED
|
@@ -9,7 +9,6 @@ var _react = require("react");
|
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
11
|
var _intlMessagesProvider = require("@atlaskit/intl-messages-provider");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _constants = require("../common/constants");
|
|
14
13
|
var _errorBoundaryModal = require("../common/ui/error-boundary-modal");
|
|
15
14
|
var _analytics = require("../common/utils/analytics");
|
|
@@ -21,8 +20,7 @@ var _errorBoundary = require("./link-create/error-boundary");
|
|
|
21
20
|
/** @jsx jsx */
|
|
22
21
|
|
|
23
22
|
var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
24
|
-
|
|
25
|
-
return (0, _react2.jsx)(ExperienceProvider, null, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, {
|
|
23
|
+
return (0, _react2.jsx)(_experienceTracker.Experience, null, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, {
|
|
26
24
|
errorComponent: (0, _react2.jsx)(_errorBoundaryModal.ErrorBoundaryModal, {
|
|
27
25
|
active: props.active,
|
|
28
26
|
onClose: props.onCancel
|
|
@@ -31,7 +29,7 @@ var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsConte
|
|
|
31
29
|
}));
|
|
32
30
|
var PACKAGE_DATA = exports.PACKAGE_DATA = {
|
|
33
31
|
packageName: "@atlaskit/link-create" || '',
|
|
34
|
-
packageVersion: "
|
|
32
|
+
packageVersion: "2.0.0" || '',
|
|
35
33
|
component: _constants.COMPONENT_NAME,
|
|
36
34
|
componentName: _constants.COMPONENT_NAME
|
|
37
35
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { ANALYTICS_CHANNEL } from '../../common/constants';
|
|
5
4
|
import createEventPayload from '../../common/utils/analytics/analytics.codegen';
|
|
6
5
|
import { getErrorType } from '../../common/utils/errors';
|
|
@@ -15,18 +14,14 @@ const LinkCreateCallbackProvider = ({
|
|
|
15
14
|
const {
|
|
16
15
|
createAnalyticsEvent
|
|
17
16
|
} = useAnalyticsEvents();
|
|
18
|
-
const experience =
|
|
19
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
20
|
-
useExperience() : null;
|
|
17
|
+
const experience = useExperience();
|
|
21
18
|
const handleCreate = useMemo(() => ({
|
|
22
19
|
onCreate: async result => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
experience === null || experience === void 0 ? void 0 : experience.success();
|
|
29
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* We consider the experience successful once we have
|
|
22
|
+
* successfully created an object
|
|
23
|
+
*/
|
|
24
|
+
experience === null || experience === void 0 ? void 0 : experience.success();
|
|
30
25
|
const {
|
|
31
26
|
objectId,
|
|
32
27
|
objectType
|
|
@@ -45,9 +40,7 @@ const LinkCreateCallbackProvider = ({
|
|
|
45
40
|
createAnalyticsEvent(createEventPayload('track.object.createFailed.linkCreate', {
|
|
46
41
|
failureType: getErrorType(error)
|
|
47
42
|
})).fire(ANALYTICS_CHANNEL);
|
|
48
|
-
|
|
49
|
-
experience === null || experience === void 0 ? void 0 : experience.failure(error);
|
|
50
|
-
}
|
|
43
|
+
experience === null || experience === void 0 ? void 0 : experience.failure(error);
|
|
51
44
|
onFailure && onFailure(error);
|
|
52
45
|
}
|
|
53
46
|
}), [createAnalyticsEvent, onFailure, experience]);
|
|
@@ -5,7 +5,6 @@ import { jsx } from '@emotion/react';
|
|
|
5
5
|
import debounce from 'debounce-promise';
|
|
6
6
|
import { useForm } from 'react-final-form';
|
|
7
7
|
import { useIntl } from 'react-intl-next';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
|
|
10
9
|
import messages from '../../../common/messages';
|
|
11
10
|
import { useLinkCreateCallback } from '../../../controllers/callback-context';
|
|
@@ -48,9 +47,7 @@ export function AsyncSelect({
|
|
|
48
47
|
/**
|
|
49
48
|
* This binds experience to fail if async fetch ever fails to load
|
|
50
49
|
*/
|
|
51
|
-
const loadOptions =
|
|
52
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
53
|
-
useMemo(() => {
|
|
50
|
+
const loadOptions = useMemo(() => {
|
|
54
51
|
if (loadOptionsFn) {
|
|
55
52
|
return async function (...args) {
|
|
56
53
|
try {
|
|
@@ -62,7 +59,7 @@ export function AsyncSelect({
|
|
|
62
59
|
}
|
|
63
60
|
};
|
|
64
61
|
}
|
|
65
|
-
}, [intl, onFailure, loadOptionsFn, setFormErrorMessage])
|
|
62
|
+
}, [intl, onFailure, loadOptionsFn, setFormErrorMessage]);
|
|
66
63
|
useEffect(() => {
|
|
67
64
|
let current = true;
|
|
68
65
|
const fetch = async (query = '') => {
|
|
@@ -5,7 +5,6 @@ import { FORM_ERROR } from 'final-form';
|
|
|
5
5
|
import { Form, FormSpy } from 'react-final-form';
|
|
6
6
|
import { useIntl } from 'react-intl-next';
|
|
7
7
|
import { RequiredAsterisk } from '@atlaskit/form';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { Box } from '@atlaskit/primitives';
|
|
10
9
|
import { CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
|
|
11
10
|
import messages from '../../common/messages';
|
|
@@ -91,7 +90,7 @@ export const CreateForm = ({
|
|
|
91
90
|
return jsx(CreateFormLoader, null);
|
|
92
91
|
}
|
|
93
92
|
return jsx(Form, {
|
|
94
|
-
onSubmit:
|
|
93
|
+
onSubmit: handleSubmitWithErrorHandling,
|
|
95
94
|
initialValues: initialValues,
|
|
96
95
|
mutators: {
|
|
97
96
|
setField: (args, state, tools) => {
|
|
@@ -120,7 +119,7 @@ export const CreateForm = ({
|
|
|
120
119
|
const isModified = Object.values(state.modified).some(value => value);
|
|
121
120
|
setShouldShowWarning(isModified);
|
|
122
121
|
}
|
|
123
|
-
}),
|
|
122
|
+
}), jsx("p", {
|
|
124
123
|
"aria-hidden": "true"
|
|
125
124
|
}, intl.formatMessage(messages.requiredFieldInstruction), ' ', jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
|
|
126
125
|
/**
|
|
@@ -129,7 +128,7 @@ export const CreateForm = ({
|
|
|
129
128
|
* default to the `formErrorMessage` that we sometimes use with our own
|
|
130
129
|
* "form context" (only currently used for AsyncSelect field reporting failed loading)
|
|
131
130
|
*/, {
|
|
132
|
-
formErrorMessage:
|
|
131
|
+
formErrorMessage: submitError || formErrorMessage,
|
|
133
132
|
handleCancel: handleCancel,
|
|
134
133
|
testId: testId
|
|
135
134
|
}));
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
|
-
import { captureException } from '@atlaskit/linking-common/sentry';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
3
|
import { ANALYTICS_CHANNEL } from '../../../common/constants';
|
|
6
4
|
import { ErrorBoundaryUI } from '../../../common/ui/error-boundary-ui';
|
|
7
5
|
import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
|
|
@@ -14,24 +12,17 @@ export const ErrorBoundary = ({
|
|
|
14
12
|
const {
|
|
15
13
|
createAnalyticsEvent
|
|
16
14
|
} = useAnalyticsEvents();
|
|
17
|
-
const experience =
|
|
18
|
-
|
|
19
|
-
useExperience() : null;
|
|
20
|
-
const handleError = useCallback((error, info) => {
|
|
15
|
+
const experience = useExperience();
|
|
16
|
+
const handleError = useCallback(error => {
|
|
21
17
|
var _window, _window$navigator;
|
|
22
|
-
if (!getBooleanFF('platform.linking-platform.link-create.better-observability')) {
|
|
23
|
-
// Capture exception to Sentry
|
|
24
|
-
captureException(error, 'link-create');
|
|
25
|
-
}
|
|
26
18
|
createAnalyticsEvent(createEventPayload('operational.linkCreate.unhandledErrorCaught', {
|
|
27
19
|
browserInfo: ((_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent) || 'unknown',
|
|
28
20
|
error: error.name,
|
|
29
21
|
componentStack: 'unknown'
|
|
30
22
|
})).fire(ANALYTICS_CHANNEL);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
23
|
+
|
|
24
|
+
// Track experience as failed for SLO
|
|
25
|
+
experience === null || experience === void 0 ? void 0 : experience.failure(error);
|
|
35
26
|
}, [createAnalyticsEvent, experience]);
|
|
36
27
|
return /*#__PURE__*/React.createElement(BaseErrorBoundary, {
|
|
37
28
|
onError: handleError,
|
|
@@ -4,14 +4,13 @@ import { Fragment, useCallback, useLayoutEffect, useRef, useState } from 'react'
|
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { useIntl } from 'react-intl-next';
|
|
6
6
|
import { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { Box } from '@atlaskit/primitives';
|
|
9
8
|
import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
|
|
10
9
|
import { Modal } from '../../common/ui/ModalDialog';
|
|
11
10
|
import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
|
|
12
11
|
import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
|
|
13
12
|
import { ExitWarningModalProvider, useExitWarningModal } from '../../controllers/exit-warning-modal-context';
|
|
14
|
-
import { FormContextProvider
|
|
13
|
+
import { FormContextProvider } from '../../controllers/form-context';
|
|
15
14
|
import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
|
|
16
15
|
import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
|
|
17
16
|
import { EditModal } from './edit-modal';
|
|
@@ -45,23 +44,6 @@ const LinkCreateWithModal = ({
|
|
|
45
44
|
modalHero
|
|
46
45
|
}) => {
|
|
47
46
|
const intl = useIntl();
|
|
48
|
-
const {
|
|
49
|
-
setFormErrorMessage
|
|
50
|
-
} = useFormContext();
|
|
51
|
-
const handleCreate = useCallback(async result => {
|
|
52
|
-
// Reset the form error message
|
|
53
|
-
setFormErrorMessage(undefined);
|
|
54
|
-
if (onCreate) {
|
|
55
|
-
await onCreate(result);
|
|
56
|
-
}
|
|
57
|
-
}, [onCreate, setFormErrorMessage]);
|
|
58
|
-
const handleFailure = useCallback(error => {
|
|
59
|
-
// Set the form error message
|
|
60
|
-
if (error instanceof Error) {
|
|
61
|
-
setFormErrorMessage(error.message);
|
|
62
|
-
}
|
|
63
|
-
onFailure && onFailure(error);
|
|
64
|
-
}, [onFailure, setFormErrorMessage]);
|
|
65
47
|
const {
|
|
66
48
|
getShouldShowWarning
|
|
67
49
|
} = useExitWarningModal();
|
|
@@ -75,8 +57,8 @@ const LinkCreateWithModal = ({
|
|
|
75
57
|
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
76
58
|
const handleCloseExitWarning = useCallback(() => setShowExitWarning(false), []);
|
|
77
59
|
return jsx(LinkCreateCallbackProvider, {
|
|
78
|
-
onCreate:
|
|
79
|
-
onFailure:
|
|
60
|
+
onCreate: onCreate,
|
|
61
|
+
onFailure: onFailure,
|
|
80
62
|
onCancel: handleCancel
|
|
81
63
|
}, jsx(ModalTransition, null, active && jsx(Modal, {
|
|
82
64
|
testId: "link-create-modal",
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import {
|
|
2
|
+
import { memo } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
5
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { COMPONENT_NAME } from '../common/constants';
|
|
8
7
|
import { ErrorBoundaryModal } from '../common/ui/error-boundary-modal';
|
|
9
8
|
import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
|
|
@@ -13,8 +12,7 @@ import i18nEN from '../i18n/en';
|
|
|
13
12
|
import LinkCreate from './link-create';
|
|
14
13
|
import { ErrorBoundary } from './link-create/error-boundary';
|
|
15
14
|
const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(props => {
|
|
16
|
-
|
|
17
|
-
return jsx(ExperienceProvider, null, jsx(ErrorBoundary, {
|
|
15
|
+
return jsx(Experience, null, jsx(ErrorBoundary, {
|
|
18
16
|
errorComponent: jsx(ErrorBoundaryModal, {
|
|
19
17
|
active: props.active,
|
|
20
18
|
onClose: props.onCancel
|
|
@@ -23,7 +21,7 @@ const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE
|
|
|
23
21
|
}));
|
|
24
22
|
export const PACKAGE_DATA = {
|
|
25
23
|
packageName: "@atlaskit/link-create" || '',
|
|
26
|
-
packageVersion: "
|
|
24
|
+
packageVersion: "2.0.0" || '',
|
|
27
25
|
component: COMPONENT_NAME,
|
|
28
26
|
componentName: COMPONENT_NAME
|
|
29
27
|
};
|
|
@@ -5,7 +5,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import React, { useContext, useMemo } from 'react';
|
|
7
7
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { ANALYTICS_CHANNEL } from '../../common/constants';
|
|
10
9
|
import createEventPayload from '../../common/utils/analytics/analytics.codegen';
|
|
11
10
|
import { getErrorType } from '../../common/utils/errors';
|
|
@@ -18,9 +17,7 @@ var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
|
|
|
18
17
|
onCancel = _ref.onCancel;
|
|
19
18
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
20
19
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
21
|
-
var experience =
|
|
22
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
23
|
-
useExperience() : null;
|
|
20
|
+
var experience = useExperience();
|
|
24
21
|
var handleCreate = useMemo(function () {
|
|
25
22
|
return {
|
|
26
23
|
onCreate: function () {
|
|
@@ -29,13 +26,11 @@ var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
|
|
|
29
26
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
30
27
|
while (1) switch (_context.prev = _context.next) {
|
|
31
28
|
case 0:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
experience === null || experience === void 0 || experience.success();
|
|
38
|
-
}
|
|
29
|
+
/**
|
|
30
|
+
* We consider the experience successful once we have
|
|
31
|
+
* successfully created an object
|
|
32
|
+
*/
|
|
33
|
+
experience === null || experience === void 0 || experience.success();
|
|
39
34
|
objectId = result.objectId, objectType = result.objectType;
|
|
40
35
|
createAnalyticsEvent(createEventPayload('track.object.created.linkCreate', {
|
|
41
36
|
objectId: objectId,
|
|
@@ -70,9 +65,7 @@ var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
|
|
|
70
65
|
createAnalyticsEvent(createEventPayload('track.object.createFailed.linkCreate', {
|
|
71
66
|
failureType: getErrorType(error)
|
|
72
67
|
})).fire(ANALYTICS_CHANNEL);
|
|
73
|
-
|
|
74
|
-
experience === null || experience === void 0 || experience.failure(error);
|
|
75
|
-
}
|
|
68
|
+
experience === null || experience === void 0 || experience.failure(error);
|
|
76
69
|
_onFailure && _onFailure(error);
|
|
77
70
|
case 3:
|
|
78
71
|
case "end":
|