@atlaskit/link-create 1.15.9 → 2.1.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 +357 -310
- package/CONTRIBUTING.md +3 -0
- package/dist/cjs/common/constants.js +8 -2
- package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -6
- package/dist/cjs/{ui/link-create → common/ui}/edit-modal/index.js +4 -8
- package/dist/cjs/{ui/link-create → common/ui}/error-boundary/index.js +6 -15
- package/dist/cjs/{controllers → common/ui}/experience-tracker/index.js +3 -3
- package/dist/cjs/common/ui/link-create-content/index.js +21 -0
- package/dist/cjs/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
- package/dist/cjs/controllers/callback-context/main.js +8 -15
- 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/index.js +11 -4
- package/dist/cjs/ui/inline-create/index.js +38 -0
- package/dist/cjs/ui/inline-create/main.js +125 -0
- package/dist/cjs/ui/modal-create/index.js +38 -0
- package/dist/cjs/ui/{link-create → modal-create}/main.js +45 -81
- package/dist/es2019/common/constants.js +7 -1
- package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -7
- package/dist/es2019/{ui/link-create → common/ui}/edit-modal/index.js +4 -10
- package/dist/es2019/{ui/link-create → common/ui}/error-boundary/index.js +6 -15
- package/dist/es2019/{controllers → common/ui}/experience-tracker/index.js +3 -3
- package/dist/es2019/common/ui/link-create-content/index.js +11 -0
- package/dist/es2019/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
- package/dist/es2019/controllers/callback-context/main.js +8 -15
- package/dist/es2019/index.js +4 -1
- 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/index.js +2 -1
- package/dist/es2019/ui/inline-create/index.js +30 -0
- package/dist/es2019/ui/inline-create/main.js +100 -0
- package/dist/es2019/ui/modal-create/index.js +30 -0
- package/dist/es2019/ui/{link-create → modal-create}/main.js +22 -40
- package/dist/esm/common/constants.js +7 -1
- package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -6
- package/dist/esm/{ui/link-create → common/ui}/edit-modal/index.js +4 -8
- package/dist/esm/{ui/link-create → common/ui}/error-boundary/index.js +6 -15
- package/dist/esm/{controllers → common/ui}/experience-tracker/index.js +3 -3
- package/dist/esm/common/ui/link-create-content/index.js +12 -0
- package/dist/esm/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
- package/dist/esm/controllers/callback-context/main.js +8 -15
- package/dist/esm/index.js +4 -1
- 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/index.js +2 -1
- package/dist/esm/ui/inline-create/index.js +30 -0
- package/dist/esm/ui/inline-create/main.js +119 -0
- package/dist/esm/ui/modal-create/index.js +30 -0
- package/dist/esm/ui/{link-create → modal-create}/main.js +48 -84
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/common/types.d.ts +2 -2
- package/dist/types/common/ui/Button/index.d.ts +2 -2
- package/dist/types/common/ui/ModalDialog/index.d.ts +1 -1
- package/dist/types/common/ui/confirm-dismiss-dialog/main.d.ts +7 -0
- package/dist/types/common/ui/edit-modal/index.d.ts +11 -0
- package/dist/types/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.d.ts +1 -1
- package/dist/types/{ui/link-create → common/ui}/error-boundary/index.d.ts +1 -1
- package/dist/types/common/ui/link-create-content/index.d.ts +8 -0
- 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/index.d.ts +2 -1
- package/dist/types/ui/inline-create/index.d.ts +5 -0
- package/dist/types/ui/inline-create/main.d.ts +5 -0
- package/dist/types/ui/modal-create/index.d.ts +5 -0
- package/dist/{types-ts4.5/ui/link-create → types/ui/modal-create}/main.d.ts +1 -1
- package/dist/types-ts4.5/common/constants.d.ts +2 -0
- package/dist/types-ts4.5/common/types.d.ts +2 -2
- package/dist/types-ts4.5/common/ui/Button/index.d.ts +2 -2
- package/dist/types-ts4.5/common/ui/ModalDialog/index.d.ts +1 -1
- package/dist/types-ts4.5/common/ui/confirm-dismiss-dialog/main.d.ts +7 -0
- package/dist/types-ts4.5/common/ui/edit-modal/index.d.ts +11 -0
- package/dist/types-ts4.5/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.d.ts +1 -1
- package/dist/types-ts4.5/{ui/link-create → common/ui}/error-boundary/index.d.ts +1 -1
- package/dist/types-ts4.5/common/ui/link-create-content/index.d.ts +8 -0
- 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/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/{main.d.ts → inline-create/index.d.ts} +1 -3
- package/dist/types-ts4.5/ui/inline-create/main.d.ts +5 -0
- package/dist/{types/ui/main.d.ts → types-ts4.5/ui/modal-create/index.d.ts} +1 -3
- package/dist/{types/ui/link-create → types-ts4.5/ui/modal-create}/main.d.ts +1 -1
- package/example-helpers/mock-plugin-form.tsx +2 -2
- package/package.json +9 -19
- package/dist/cjs/ui/link-create/index.js +0 -13
- package/dist/cjs/ui/main.js +0 -46
- package/dist/es2019/ui/link-create/index.js +0 -1
- package/dist/es2019/ui/main.js +0 -38
- package/dist/esm/ui/link-create/index.js +0 -1
- package/dist/esm/ui/main.js +0 -38
- package/dist/types/ui/link-create/confirm-dismiss-dialog/main.d.ts +0 -6
- package/dist/types/ui/link-create/edit-modal/index.d.ts +0 -8
- package/dist/types/ui/link-create/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/link-create/confirm-dismiss-dialog/main.d.ts +0 -6
- package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +0 -8
- package/dist/types-ts4.5/ui/link-create/index.d.ts +0 -1
- /package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
- /package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
- /package/dist/cjs/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
- /package/dist/cjs/ui/{link-create → modal-create}/messages.js +0 -0
- /package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
- /package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
- /package/dist/es2019/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
- /package/dist/es2019/ui/{link-create → modal-create}/messages.js +0 -0
- /package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
- /package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
- /package/dist/esm/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
- /package/dist/esm/ui/{link-create → modal-create}/messages.js +0 -0
- /package/dist/types/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.d.ts +0 -0
- /package/dist/types/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.d.ts +0 -0
- /package/dist/types/{controllers → common/ui}/experience-tracker/index.d.ts +0 -0
- /package/dist/types/{ui/link-create → common/ui}/modal-hero/index.d.ts +0 -0
- /package/dist/types/ui/{link-create → modal-create}/messages.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.d.ts +0 -0
- /package/dist/types-ts4.5/{controllers → common/ui}/experience-tracker/index.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/link-create → common/ui}/modal-hero/index.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{link-create → modal-create}/messages.d.ts +0 -0
|
@@ -7,94 +7,55 @@ 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");
|
|
18
|
+
var _confirmDismissDialog = require("../../common/ui/confirm-dismiss-dialog");
|
|
19
|
+
var _editModal = require("../../common/ui/edit-modal");
|
|
20
|
+
var _errorBoundary = require("../../common/ui/error-boundary");
|
|
21
|
+
var _linkCreateContent = require("../../common/ui/link-create-content");
|
|
22
|
+
var _modalHero = require("../../common/ui/modal-hero");
|
|
19
23
|
var _ModalDialog = require("../../common/ui/ModalDialog");
|
|
20
24
|
var _callbackContext = require("../../controllers/callback-context");
|
|
21
25
|
var _editPostCreateContext = require("../../controllers/edit-post-create-context");
|
|
22
26
|
var _exitWarningModalContext = require("../../controllers/exit-warning-modal-context");
|
|
23
27
|
var _formContext = require("../../controllers/form-context");
|
|
24
28
|
var _pluginContext = require("../../controllers/plugin-context");
|
|
25
|
-
var _confirmDismissDialog = require("./confirm-dismiss-dialog");
|
|
26
|
-
var _editModal = require("./edit-modal");
|
|
27
|
-
var _errorBoundary = require("./error-boundary");
|
|
28
29
|
var _messages = require("./messages");
|
|
29
|
-
var _modalHero = require("./modal-hero");
|
|
30
30
|
/** @jsx jsx */
|
|
31
31
|
|
|
32
32
|
var TEST_ID = exports.TEST_ID = 'link-create';
|
|
33
33
|
var SCREEN_ID = 'linkCreateScreen';
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
onCreate = _ref2.onCreate,
|
|
49
|
-
onFailure = _ref2.onFailure,
|
|
50
|
-
onCancel = _ref2.onCancel,
|
|
51
|
-
onComplete = _ref2.onComplete,
|
|
52
|
-
onOpenComplete = _ref2.onOpenComplete,
|
|
53
|
-
onCloseComplete = _ref2.onCloseComplete,
|
|
54
|
-
_ref2$testId = _ref2.testId,
|
|
55
|
-
testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
|
|
56
|
-
plugins = _ref2.plugins,
|
|
57
|
-
entityKey = _ref2.entityKey,
|
|
58
|
-
modalHero = _ref2.modalHero;
|
|
34
|
+
var LinkCreateWithModal = function LinkCreateWithModal(_ref) {
|
|
35
|
+
var active = _ref.active,
|
|
36
|
+
modalTitle = _ref.modalTitle,
|
|
37
|
+
onCreate = _ref.onCreate,
|
|
38
|
+
onFailure = _ref.onFailure,
|
|
39
|
+
onCancel = _ref.onCancel,
|
|
40
|
+
onComplete = _ref.onComplete,
|
|
41
|
+
onOpenComplete = _ref.onOpenComplete,
|
|
42
|
+
onCloseComplete = _ref.onCloseComplete,
|
|
43
|
+
_ref$testId = _ref.testId,
|
|
44
|
+
testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
|
|
45
|
+
plugins = _ref.plugins,
|
|
46
|
+
entityKey = _ref.entityKey,
|
|
47
|
+
modalHero = _ref.modalHero;
|
|
59
48
|
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
49
|
var _useExitWarningModal = (0, _exitWarningModalContext.useExitWarningModal)(),
|
|
93
50
|
getShouldShowWarning = _useExitWarningModal.getShouldShowWarning;
|
|
94
51
|
var _useState = (0, _react.useState)(false),
|
|
95
52
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
96
53
|
showExitWarning = _useState2[0],
|
|
97
54
|
setShowExitWarning = _useState2[1];
|
|
55
|
+
var _useEditPostCreateMod = (0, _editPostCreateContext.useEditPostCreateModal)(),
|
|
56
|
+
editViewPayload = _useEditPostCreateMod.editViewPayload;
|
|
57
|
+
var _useLinkCreatePlugins = (0, _pluginContext.useLinkCreatePlugins)(),
|
|
58
|
+
activePlugin = _useLinkCreatePlugins.activePlugin;
|
|
98
59
|
var handleCancel = (0, _react.useCallback)(function () {
|
|
99
60
|
if (getShouldShowWarning() && !showExitWarning) {
|
|
100
61
|
setShowExitWarning(true);
|
|
@@ -106,8 +67,8 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
|
|
|
106
67
|
return setShowExitWarning(false);
|
|
107
68
|
}, []);
|
|
108
69
|
return (0, _react2.jsx)(_callbackContext.LinkCreateCallbackProvider, {
|
|
109
|
-
onCreate:
|
|
110
|
-
onFailure:
|
|
70
|
+
onCreate: onCreate,
|
|
71
|
+
onFailure: onFailure,
|
|
111
72
|
onCancel: handleCancel
|
|
112
73
|
}, (0, _react2.jsx)(_modalDialog.ModalTransition, null, active && (0, _react2.jsx)(_ModalDialog.Modal, {
|
|
113
74
|
testId: "link-create-modal",
|
|
@@ -121,15 +82,18 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
|
|
|
121
82
|
hero: modalHero
|
|
122
83
|
}), (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(_modalDialog.ModalTitle, null, modalTitle || intl.formatMessage(_messages.messages.heading))), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)(_primitives.Box, {
|
|
123
84
|
testId: testId
|
|
124
|
-
}, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(LinkCreateContent, {
|
|
85
|
+
}, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_linkCreateContent.LinkCreateContent, {
|
|
125
86
|
plugins: plugins,
|
|
126
87
|
entityKey: entityKey
|
|
127
88
|
})))))), onComplete && (0, _react2.jsx)(_editModal.EditModal, {
|
|
128
89
|
onCloseComplete: onCloseComplete,
|
|
129
|
-
onClose: onComplete
|
|
90
|
+
onClose: onComplete,
|
|
91
|
+
editViewPayload: editViewPayload,
|
|
92
|
+
activePlugin: activePlugin
|
|
130
93
|
}), (0, _react2.jsx)(_confirmDismissDialog.ConfirmDismissDialog, {
|
|
131
94
|
active: showExitWarning,
|
|
132
|
-
onClose: handleCloseExitWarning
|
|
95
|
+
onClose: handleCloseExitWarning,
|
|
96
|
+
onCancel: onCancel
|
|
133
97
|
}));
|
|
134
98
|
};
|
|
135
99
|
var LinkCreateModal = function LinkCreateModal(props) {
|
|
@@ -148,23 +112,23 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
148
112
|
}, function (pluginsProvider) {
|
|
149
113
|
return (0, _react2.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
|
|
150
114
|
active: !!props.active
|
|
151
|
-
}, function (
|
|
115
|
+
}, function (_ref2) {
|
|
152
116
|
var _pluginsProvider$acti;
|
|
153
|
-
var setEditViewPayload =
|
|
154
|
-
editViewPayload =
|
|
155
|
-
shouldActivateEditView =
|
|
156
|
-
enableEditView =
|
|
117
|
+
var setEditViewPayload = _ref2.setEditViewPayload,
|
|
118
|
+
editViewPayload = _ref2.editViewPayload,
|
|
119
|
+
shouldActivateEditView = _ref2.shouldActivateEditView,
|
|
120
|
+
enableEditView = _ref2.enableEditView;
|
|
157
121
|
return (0, _react2.jsx)(_formContext.FormContextProvider, {
|
|
158
122
|
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
123
|
}, (0, _react2.jsx)(_exitWarningModalContext.ExitWarningModalProvider, null, (0, _react2.jsx)(LinkCreateWithModal, (0, _extends2.default)({}, props, {
|
|
160
124
|
active: props.active && !editViewPayload,
|
|
161
125
|
onCreate: ( /*#__PURE__*/function () {
|
|
162
|
-
var
|
|
126
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload) {
|
|
163
127
|
var _props$onCreate;
|
|
164
|
-
return _regenerator.default.wrap(function
|
|
165
|
-
while (1) switch (
|
|
128
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
129
|
+
while (1) switch (_context.prev = _context.next) {
|
|
166
130
|
case 0:
|
|
167
|
-
|
|
131
|
+
_context.next = 2;
|
|
168
132
|
return (_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload);
|
|
169
133
|
case 2:
|
|
170
134
|
// if onComplete exists then there is an edit flow
|
|
@@ -179,12 +143,12 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
179
143
|
}
|
|
180
144
|
case 3:
|
|
181
145
|
case "end":
|
|
182
|
-
return
|
|
146
|
+
return _context.stop();
|
|
183
147
|
}
|
|
184
|
-
},
|
|
148
|
+
}, _callee);
|
|
185
149
|
}));
|
|
186
|
-
return function (
|
|
187
|
-
return
|
|
150
|
+
return function (_x) {
|
|
151
|
+
return _ref3.apply(this, arguments);
|
|
188
152
|
};
|
|
189
153
|
}()),
|
|
190
154
|
onCloseComplete: function onCloseComplete() {
|
|
@@ -2,4 +2,10 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
2
2
|
export const COMPONENT_NAME = 'linkCreate';
|
|
3
3
|
export const CREATE_FORM_MAX_WIDTH_IN_PX = '480';
|
|
4
4
|
export const CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
|
|
5
|
-
export const LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
|
|
5
|
+
export const LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
|
|
6
|
+
export const PACKAGE_DATA = {
|
|
7
|
+
packageName: "@atlaskit/link-create" || '',
|
|
8
|
+
packageVersion: "2.1.0" || '',
|
|
9
|
+
component: COMPONENT_NAME,
|
|
10
|
+
componentName: COMPONENT_NAME
|
|
11
|
+
};
|
|
@@ -2,9 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
4
4
|
import { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
5
|
-
import { Button } from '
|
|
6
|
-
import { Modal } from '
|
|
7
|
-
import { useLinkCreateCallback } from '../../../controllers/callback-context';
|
|
5
|
+
import { Button } from '../Button';
|
|
6
|
+
import { Modal } from '../ModalDialog';
|
|
8
7
|
import messages from './messages';
|
|
9
8
|
const screen = 'linkCreateExitWarningScreen';
|
|
10
9
|
const context = {
|
|
@@ -13,12 +12,10 @@ const context = {
|
|
|
13
12
|
};
|
|
14
13
|
export const ConfirmDismissDialog = ({
|
|
15
14
|
active,
|
|
16
|
-
onClose
|
|
15
|
+
onClose,
|
|
16
|
+
onCancel
|
|
17
17
|
}) => {
|
|
18
18
|
const intl = useIntl();
|
|
19
|
-
const {
|
|
20
|
-
onCancel
|
|
21
|
-
} = useLinkCreateCallback();
|
|
22
19
|
const onCancelDismiss = () => onClose();
|
|
23
20
|
const onConfirmDismiss = () => {
|
|
24
21
|
onClose();
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ModalTransition } from '@atlaskit/modal-dialog';
|
|
3
|
-
import { Modal } from '
|
|
4
|
-
import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
|
|
5
|
-
import { useLinkCreatePlugins } from '../../../controllers/plugin-context';
|
|
3
|
+
import { Modal } from '../ModalDialog';
|
|
6
4
|
const SCREEN = 'linkCreateEditScreen';
|
|
7
5
|
export const EditModal = ({
|
|
8
6
|
onClose,
|
|
9
|
-
onCloseComplete
|
|
7
|
+
onCloseComplete,
|
|
8
|
+
editViewPayload,
|
|
9
|
+
activePlugin
|
|
10
10
|
}) => {
|
|
11
11
|
var _activePlugin$editVie;
|
|
12
|
-
const {
|
|
13
|
-
editViewPayload
|
|
14
|
-
} = useEditPostCreateModal();
|
|
15
|
-
const {
|
|
16
|
-
activePlugin
|
|
17
|
-
} = useLinkCreatePlugins();
|
|
18
12
|
return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Modal, {
|
|
19
13
|
testId: "link-create-edit-modal",
|
|
20
14
|
screen: SCREEN,
|
|
@@ -1,11 +1,9 @@
|
|
|
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';
|
|
8
|
-
import { useExperience } from '
|
|
6
|
+
import { useExperience } from '../experience-tracker';
|
|
9
7
|
import { BaseErrorBoundary } from './error-boundary-base';
|
|
10
8
|
export const ErrorBoundary = ({
|
|
11
9
|
children,
|
|
@@ -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,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo, useRef } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
3
|
import { captureException } from '@atlaskit/linking-common/sentry';
|
|
4
|
-
import { ANALYTICS_CHANNEL } from '../../
|
|
5
|
-
import createEventPayload from '../../
|
|
6
|
-
import { getErrorType, getNetworkFields } from '../../
|
|
4
|
+
import { ANALYTICS_CHANNEL } from '../../constants';
|
|
5
|
+
import createEventPayload from '../../utils/analytics/analytics.codegen';
|
|
6
|
+
import { getErrorType, getNetworkFields } from '../../utils/errors';
|
|
7
7
|
const ExperienceContext = /*#__PURE__*/createContext({
|
|
8
8
|
success: () => {},
|
|
9
9
|
failure: () => {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
export const LinkCreateContent = ({
|
|
3
|
+
plugins,
|
|
4
|
+
entityKey
|
|
5
|
+
}) => {
|
|
6
|
+
const chosenOne = plugins.find(plugin => plugin.key === entityKey);
|
|
7
|
+
if (!chosenOne) {
|
|
8
|
+
throw new Error('Make sure you specified a valid entityKey');
|
|
9
|
+
}
|
|
10
|
+
return /*#__PURE__*/React.createElement(Fragment, null, chosenOne.form);
|
|
11
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import { Stack } from '@atlaskit/primitives';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @atlassian/tangerine/import/no-parent-imports
|
|
5
|
-
import { ErrorBoundary } from '../error-boundary';
|
|
3
|
+
import { ErrorBoundary } from '../../../common/ui/error-boundary';
|
|
6
4
|
const ErrorComponent = () => {
|
|
7
5
|
// when there's an error, render nothing but report the issue
|
|
8
6
|
return /*#__PURE__*/React.createElement(Fragment, null, null);
|
|
@@ -1,10 +1,9 @@
|
|
|
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';
|
|
4
|
+
import { useExperience } from '../../common/ui/experience-tracker';
|
|
5
5
|
import createEventPayload from '../../common/utils/analytics/analytics.codegen';
|
|
6
6
|
import { getErrorType } from '../../common/utils/errors';
|
|
7
|
-
import { useExperience } from '../experience-tracker';
|
|
8
7
|
const LinkCreateCallbackContext = /*#__PURE__*/React.createContext({});
|
|
9
8
|
const LinkCreateCallbackProvider = ({
|
|
10
9
|
children,
|
|
@@ -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]);
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy
|
|
1
|
+
export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy
|
|
2
|
+
// todo: EDM-10077 - export this once inline-create is tested/ready
|
|
3
|
+
//InlineCreate,
|
|
4
|
+
} from './ui/index';
|
|
2
5
|
export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
|
|
3
6
|
export { FORM_ERROR } from 'final-form';
|
|
@@ -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
|
}));
|
package/dist/es2019/ui/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './modal-create';
|
|
2
|
+
export { default as InlineCreate } from './inline-create';
|
|
2
3
|
export { TextField } from './create-form/textfield';
|
|
3
4
|
export { CreateForm } from './create-form/main';
|
|
4
5
|
export { CreateFormLoader } from './create-form/form-loader';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
|
+
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
6
|
+
import { PACKAGE_DATA } from '../../common/constants';
|
|
7
|
+
import { ErrorBoundary } from '../../common/ui/error-boundary';
|
|
8
|
+
import { ErrorBoundaryModal } from '../../common/ui/error-boundary-modal';
|
|
9
|
+
import { Experience } from '../../common/ui/experience-tracker';
|
|
10
|
+
import { withLinkCreateAnalyticsContext } from '../../common/utils/analytics';
|
|
11
|
+
import { fetchMessagesForLocale } from '../../common/utils/locale/fetch-messages-for-locale';
|
|
12
|
+
import i18nEN from '../../i18n/en';
|
|
13
|
+
import InlineCreate from './main';
|
|
14
|
+
const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(props => {
|
|
15
|
+
return jsx(Experience, null, jsx(ErrorBoundary, {
|
|
16
|
+
errorComponent: jsx(ErrorBoundaryModal, {
|
|
17
|
+
active: props.active,
|
|
18
|
+
onClose: props.onCancel
|
|
19
|
+
})
|
|
20
|
+
}, jsx(InlineCreate, props)));
|
|
21
|
+
}));
|
|
22
|
+
const ComposedLinkCreate = /*#__PURE__*/memo(props => {
|
|
23
|
+
return jsx(AnalyticsContext, {
|
|
24
|
+
data: PACKAGE_DATA
|
|
25
|
+
}, jsx(IntlMessagesProvider, {
|
|
26
|
+
defaultMessages: i18nEN,
|
|
27
|
+
loaderFn: fetchMessagesForLocale
|
|
28
|
+
}, jsx(LinkCreateWithAnalyticsContext, props)));
|
|
29
|
+
});
|
|
30
|
+
export default ComposedLinkCreate;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { useCallback, useState } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { Box } from '@atlaskit/primitives';
|
|
6
|
+
import { ConfirmDismissDialog } from '../../common/ui/confirm-dismiss-dialog';
|
|
7
|
+
import { EditModal } from '../../common/ui/edit-modal';
|
|
8
|
+
import { ErrorBoundary } from '../../common/ui/error-boundary';
|
|
9
|
+
import { LinkCreateContent } from '../../common/ui/link-create-content';
|
|
10
|
+
import { LinkCreateCallbackProvider
|
|
11
|
+
// useLinkCreateCallback,
|
|
12
|
+
} from '../../controllers/callback-context';
|
|
13
|
+
import { EditPostCreateModalProvider, useEditPostCreateModal } from '../../controllers/edit-post-create-context';
|
|
14
|
+
import { ExitWarningModalProvider, useExitWarningModal } from '../../controllers/exit-warning-modal-context';
|
|
15
|
+
import { FormContextProvider } from '../../controllers/form-context';
|
|
16
|
+
import { LinkCreatePluginsProvider, useLinkCreatePlugins } from '../../controllers/plugin-context';
|
|
17
|
+
export const TEST_ID = 'link-create';
|
|
18
|
+
// todo: EDM-10075 trigger the screen.viewed_linkCreateScreen event when inline-create is mounted
|
|
19
|
+
// const SCREEN_ID = 'linkCreateScreen';
|
|
20
|
+
|
|
21
|
+
const InlineCreateContent = ({
|
|
22
|
+
onCreate,
|
|
23
|
+
onFailure,
|
|
24
|
+
onCancel,
|
|
25
|
+
onComplete,
|
|
26
|
+
plugins,
|
|
27
|
+
entityKey,
|
|
28
|
+
testId
|
|
29
|
+
}) => {
|
|
30
|
+
const {
|
|
31
|
+
getShouldShowWarning
|
|
32
|
+
} = useExitWarningModal();
|
|
33
|
+
const [showExitWarning, setShowExitWarning] = useState(false);
|
|
34
|
+
const {
|
|
35
|
+
editViewPayload
|
|
36
|
+
} = useEditPostCreateModal();
|
|
37
|
+
const {
|
|
38
|
+
activePlugin
|
|
39
|
+
} = useLinkCreatePlugins();
|
|
40
|
+
const handleCancel = useCallback(() => {
|
|
41
|
+
if (getShouldShowWarning() && !showExitWarning) {
|
|
42
|
+
setShowExitWarning(true);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
46
|
+
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
47
|
+
const handleCloseExitWarning = useCallback(() => setShowExitWarning(false), []);
|
|
48
|
+
return jsx(LinkCreateCallbackProvider, {
|
|
49
|
+
onCreate: onCreate,
|
|
50
|
+
onFailure: onFailure,
|
|
51
|
+
onCancel: handleCancel
|
|
52
|
+
}, jsx(ErrorBoundary, null, jsx(Box, {
|
|
53
|
+
testId: testId
|
|
54
|
+
}, jsx(LinkCreateContent, {
|
|
55
|
+
plugins: plugins,
|
|
56
|
+
entityKey: entityKey
|
|
57
|
+
}))), onComplete && jsx(EditModal, {
|
|
58
|
+
onClose: onComplete,
|
|
59
|
+
editViewPayload: editViewPayload,
|
|
60
|
+
activePlugin: activePlugin
|
|
61
|
+
}), jsx(ConfirmDismissDialog, {
|
|
62
|
+
active: showExitWarning,
|
|
63
|
+
onClose: handleCloseExitWarning,
|
|
64
|
+
onCancel: onCancel
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
const InlineCreate = props => {
|
|
68
|
+
return jsx(LinkCreatePluginsProvider, {
|
|
69
|
+
plugins: props.plugins,
|
|
70
|
+
entityKey: props.entityKey
|
|
71
|
+
}, pluginsProvider => jsx(EditPostCreateModalProvider, {
|
|
72
|
+
active: true
|
|
73
|
+
}, ({
|
|
74
|
+
setEditViewPayload,
|
|
75
|
+
shouldActivateEditView,
|
|
76
|
+
enableEditView
|
|
77
|
+
}) => {
|
|
78
|
+
var _pluginsProvider$acti;
|
|
79
|
+
return jsx(FormContextProvider, {
|
|
80
|
+
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
|
|
81
|
+
}, jsx(ExitWarningModalProvider, null, jsx(InlineCreateContent, _extends({}, props, {
|
|
82
|
+
onCreate: async payload => {
|
|
83
|
+
var _props$onCreate;
|
|
84
|
+
await ((_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload));
|
|
85
|
+
|
|
86
|
+
// if onComplete exists then there is an edit flow
|
|
87
|
+
if (props.onComplete) {
|
|
88
|
+
if (shouldActivateEditView()) {
|
|
89
|
+
//edit button is pressed
|
|
90
|
+
setEditViewPayload(payload);
|
|
91
|
+
} else {
|
|
92
|
+
//create button is pressed
|
|
93
|
+
props.onComplete();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}))));
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
export default InlineCreate;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
|
+
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
6
|
+
import { PACKAGE_DATA } from '../../common/constants';
|
|
7
|
+
import { ErrorBoundary } from '../../common/ui/error-boundary';
|
|
8
|
+
import { ErrorBoundaryModal } from '../../common/ui/error-boundary-modal';
|
|
9
|
+
import { Experience } from '../../common/ui/experience-tracker';
|
|
10
|
+
import { withLinkCreateAnalyticsContext } from '../../common/utils/analytics';
|
|
11
|
+
import { fetchMessagesForLocale } from '../../common/utils/locale/fetch-messages-for-locale';
|
|
12
|
+
import i18nEN from '../../i18n/en';
|
|
13
|
+
import LinkCreate from './main';
|
|
14
|
+
const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(props => {
|
|
15
|
+
return jsx(Experience, null, jsx(ErrorBoundary, {
|
|
16
|
+
errorComponent: jsx(ErrorBoundaryModal, {
|
|
17
|
+
active: props.active,
|
|
18
|
+
onClose: props.onCancel
|
|
19
|
+
})
|
|
20
|
+
}, jsx(LinkCreate, props)));
|
|
21
|
+
}));
|
|
22
|
+
const ComposedLinkCreate = /*#__PURE__*/memo(props => {
|
|
23
|
+
return jsx(AnalyticsContext, {
|
|
24
|
+
data: PACKAGE_DATA
|
|
25
|
+
}, jsx(IntlMessagesProvider, {
|
|
26
|
+
defaultMessages: i18nEN,
|
|
27
|
+
loaderFn: fetchMessagesForLocale
|
|
28
|
+
}, jsx(LinkCreateWithAnalyticsContext, props)));
|
|
29
|
+
});
|
|
30
|
+
export default ComposedLinkCreate;
|