@atlaskit/link-create 1.8.1 → 1.9.1
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 +16 -0
- package/dist/cjs/ui/create-form/main.js +10 -2
- package/dist/cjs/ui/link-create/confirm-dismiss-dialog/main.js +1 -1
- package/dist/cjs/ui/link-create/main.js +53 -35
- package/dist/cjs/ui/main.js +1 -1
- package/dist/es2019/ui/create-form/main.js +10 -2
- package/dist/es2019/ui/link-create/confirm-dismiss-dialog/main.js +1 -1
- package/dist/es2019/ui/link-create/main.js +29 -13
- package/dist/es2019/ui/main.js +1 -1
- package/dist/esm/ui/create-form/main.js +10 -2
- package/dist/esm/ui/link-create/confirm-dismiss-dialog/main.js +1 -1
- package/dist/esm/ui/link-create/main.js +52 -35
- package/dist/esm/ui/main.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/link-create
|
|
2
2
|
|
|
3
|
+
## 1.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#43170](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43170) [`959e2b89af9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/959e2b89af9) - Change exit warning modal to show only when fields have been modified by user
|
|
8
|
+
|
|
9
|
+
## 1.9.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#43068](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43068) [`76817bfbd5d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/76817bfbd5d) - EDM-8402: under a FF platform.linking-platform.link-create.enable-edit internally refactor onCloseComplete hook to be conditionally called when active prop is false
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 1.8.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -118,10 +118,18 @@ var CreateForm = exports.CreateForm = function CreateForm(_ref) {
|
|
|
118
118
|
css: formStyles
|
|
119
119
|
}, (0, _react2.jsx)(_reactFinalForm.FormSpy, {
|
|
120
120
|
subscription: {
|
|
121
|
-
|
|
121
|
+
modified: true
|
|
122
122
|
},
|
|
123
123
|
onChange: function onChange(state) {
|
|
124
|
-
|
|
124
|
+
// determine if any of the fields have been modified
|
|
125
|
+
if (!state.modified) {
|
|
126
|
+
setShouldShowWarning(false);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
var isModified = Object.values(state.modified).some(function (value) {
|
|
130
|
+
return value;
|
|
131
|
+
});
|
|
132
|
+
setShouldShowWarning(isModified);
|
|
125
133
|
}
|
|
126
134
|
}), (0, _react2.jsx)(_primitives.Box, null, children), !hideFooter && (0, _react2.jsx)(_formFooter.CreateFormFooter, {
|
|
127
135
|
formErrorMessage: formErrorMessage,
|
|
@@ -41,7 +41,7 @@ var ConfirmDismissDialog = exports.ConfirmDismissDialog = function ConfirmDismis
|
|
|
41
41
|
onClose: onCancelDismiss,
|
|
42
42
|
width: "small"
|
|
43
43
|
}, /*#__PURE__*/_react.default.createElement(_components.ScreenViewedEvent, {
|
|
44
|
-
screen:
|
|
44
|
+
screen: screen
|
|
45
45
|
}), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalHeader, null, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTitle, null, intl.formatMessage(_messages.default.title))), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, intl.formatMessage(_messages.default.description)), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_Button.Button, {
|
|
46
46
|
actionSubjectId: "cancel",
|
|
47
47
|
appearance: "subtle",
|
|
@@ -10,7 +10,6 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
14
13
|
var _react = require("react");
|
|
15
14
|
var _react2 = require("@emotion/react");
|
|
16
15
|
var _reactIntlNext = require("react-intl-next");
|
|
@@ -28,11 +27,10 @@ var _editModal = require("./edit-modal");
|
|
|
28
27
|
var _errorBoundary = require("./error-boundary");
|
|
29
28
|
var _messages = require("./messages");
|
|
30
29
|
var _trackMount = _interopRequireDefault(require("./track-mount"));
|
|
31
|
-
var _excluded = ["testId", "triggeredFrom"],
|
|
32
|
-
_excluded2 = ["active", "modalTitle", "onCreate", "onFailure", "onCancel", "onOpenComplete", "onCloseComplete"];
|
|
33
|
-
/** @jsx jsx */
|
|
34
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
31
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
32
|
+
/** @jsx jsx */
|
|
33
|
+
|
|
36
34
|
var TEST_ID = exports.TEST_ID = 'link-create';
|
|
37
35
|
var LinkCreateContent = function LinkCreateContent(_ref) {
|
|
38
36
|
var plugins = _ref.plugins,
|
|
@@ -45,29 +43,24 @@ var LinkCreateContent = function LinkCreateContent(_ref) {
|
|
|
45
43
|
}
|
|
46
44
|
return (0, _react2.jsx)(_react.Fragment, null, chosenOne.form);
|
|
47
45
|
};
|
|
48
|
-
var
|
|
49
|
-
var
|
|
46
|
+
var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
|
|
47
|
+
var active = _ref2.active,
|
|
48
|
+
modalTitle = _ref2.modalTitle,
|
|
49
|
+
onCreate = _ref2.onCreate,
|
|
50
|
+
onFailure = _ref2.onFailure,
|
|
51
|
+
onCancel = _ref2.onCancel,
|
|
52
|
+
onComplete = _ref2.onComplete,
|
|
53
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
54
|
+
onCloseComplete = _ref2.onCloseComplete,
|
|
55
|
+
_ref2$testId = _ref2.testId,
|
|
50
56
|
testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return (0, _react2.jsx)(_primitives.Box, {
|
|
54
|
-
testId: testId
|
|
55
|
-
}, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_trackMount.default, null), (0, _react2.jsx)(LinkCreateContent, restProps)));
|
|
56
|
-
};
|
|
57
|
-
var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
58
|
-
var active = _ref3.active,
|
|
59
|
-
modalTitle = _ref3.modalTitle,
|
|
60
|
-
onCreate = _ref3.onCreate,
|
|
61
|
-
onFailure = _ref3.onFailure,
|
|
62
|
-
onCancel = _ref3.onCancel,
|
|
63
|
-
onOpenComplete = _ref3.onOpenComplete,
|
|
64
|
-
onCloseComplete = _ref3.onCloseComplete,
|
|
65
|
-
createProps = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
|
|
57
|
+
plugins = _ref2.plugins,
|
|
58
|
+
entityKey = _ref2.entityKey;
|
|
66
59
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
67
60
|
var _useFormContext = (0, _formContext.useFormContext)(),
|
|
68
61
|
setFormErrorMessage = _useFormContext.setFormErrorMessage;
|
|
69
62
|
var handleCreate = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
70
|
-
var
|
|
63
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(result) {
|
|
71
64
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
72
65
|
while (1) switch (_context.prev = _context.next) {
|
|
73
66
|
case 0:
|
|
@@ -86,7 +79,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
|
86
79
|
}, _callee);
|
|
87
80
|
}));
|
|
88
81
|
return function (_x) {
|
|
89
|
-
return
|
|
82
|
+
return _ref3.apply(this, arguments);
|
|
90
83
|
};
|
|
91
84
|
}(), [onCreate, setFormErrorMessage]);
|
|
92
85
|
var handleFailure = (0, _react.useCallback)(function (error) {
|
|
@@ -123,9 +116,14 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
|
123
116
|
onOpenComplete: onOpenComplete,
|
|
124
117
|
onCloseComplete: onCloseComplete,
|
|
125
118
|
width: "".concat(_constants.CREATE_FORM_MAX_WIDTH_IN_PX, "px")
|
|
126
|
-
}, (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)(
|
|
119
|
+
}, (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, {
|
|
120
|
+
testId: testId
|
|
121
|
+
}, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_trackMount.default, null), (0, _react2.jsx)(LinkCreateContent, {
|
|
122
|
+
plugins: plugins,
|
|
123
|
+
entityKey: entityKey
|
|
124
|
+
})))))), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.enable-edit') && onComplete && (0, _react2.jsx)(_editModal.EditModal, {
|
|
127
125
|
onCloseComplete: onCloseComplete,
|
|
128
|
-
onClose:
|
|
126
|
+
onClose: onComplete
|
|
129
127
|
}), (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.confirm-dismiss-dialog') && (0, _react2.jsx)(_confirmDismissDialog.ConfirmDismissDialog, {
|
|
130
128
|
active: showExitWarning,
|
|
131
129
|
onClose: handleCloseExitWarning
|
|
@@ -133,24 +131,35 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
|
133
131
|
};
|
|
134
132
|
var LinkCreateModal = function LinkCreateModal(props) {
|
|
135
133
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.link-create.enable-edit')) {
|
|
134
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
135
|
+
var shouldCallCloseComplete = (0, _react.useRef)(!props.active);
|
|
136
|
+
|
|
137
|
+
// modal calls onCloseComplete in a useEffect(), so we can track whether
|
|
138
|
+
// or not we should execute it based on the active prop in a
|
|
139
|
+
// useLayoutEffect() which will be run before child useEffect()s
|
|
140
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
141
|
+
(0, _react.useLayoutEffect)(function () {
|
|
142
|
+
// onCloseComplete should only be called when it is not active
|
|
143
|
+
shouldCallCloseComplete.current = !props.active;
|
|
144
|
+
}, [props.active]);
|
|
136
145
|
return (0, _react2.jsx)(_pluginContext.LinkCreatePluginsProvider, {
|
|
137
146
|
plugins: props.plugins,
|
|
138
147
|
entityKey: props.entityKey
|
|
139
148
|
}, function (pluginsProvider) {
|
|
140
149
|
return (0, _react2.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
|
|
141
150
|
active: !!props.active
|
|
142
|
-
}, function (
|
|
151
|
+
}, function (_ref4) {
|
|
143
152
|
var _pluginsProvider$acti;
|
|
144
|
-
var setEditViewPayload =
|
|
145
|
-
editViewPayload =
|
|
146
|
-
shouldActivateEditView =
|
|
147
|
-
enableEditView =
|
|
153
|
+
var setEditViewPayload = _ref4.setEditViewPayload,
|
|
154
|
+
editViewPayload = _ref4.editViewPayload,
|
|
155
|
+
shouldActivateEditView = _ref4.shouldActivateEditView,
|
|
156
|
+
enableEditView = _ref4.enableEditView;
|
|
148
157
|
return (0, _react2.jsx)(_formContext.FormContextProvider, {
|
|
149
158
|
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
|
|
150
159
|
}, (0, _react2.jsx)(_exitWarningModalContext.ExitWarningModalProvider, null, (0, _react2.jsx)(LinkCreateWithModal, (0, _extends2.default)({}, props, {
|
|
151
160
|
active: props.active && !editViewPayload,
|
|
152
161
|
onCreate: /*#__PURE__*/function () {
|
|
153
|
-
var
|
|
162
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(payload) {
|
|
154
163
|
var _props$onCreate;
|
|
155
164
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
156
165
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -175,16 +184,25 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
175
184
|
}, _callee2);
|
|
176
185
|
}));
|
|
177
186
|
return function (_x2) {
|
|
178
|
-
return
|
|
187
|
+
return _ref5.apply(this, arguments);
|
|
179
188
|
};
|
|
180
|
-
}()
|
|
189
|
+
}(),
|
|
190
|
+
onCloseComplete: function onCloseComplete() {
|
|
191
|
+
if (shouldCallCloseComplete.current) {
|
|
192
|
+
var _props$onCloseComplet;
|
|
193
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
194
|
+
args[_key] = arguments[_key];
|
|
195
|
+
}
|
|
196
|
+
(_props$onCloseComplet = props.onCloseComplete) === null || _props$onCloseComplet === void 0 || _props$onCloseComplet.call.apply(_props$onCloseComplet, [props].concat(args));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
181
199
|
}))));
|
|
182
200
|
});
|
|
183
201
|
});
|
|
184
202
|
}
|
|
185
203
|
return (0, _react2.jsx)(_formContext.FormContextProvider, null, (0, _react2.jsx)(_exitWarningModalContext.ExitWarningModalProvider, null, (0, _react2.jsx)(LinkCreateWithModal, (0, _extends2.default)({}, props, {
|
|
186
204
|
onCreate: /*#__PURE__*/function () {
|
|
187
|
-
var
|
|
205
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(payload) {
|
|
188
206
|
var _props$onCreate2, _props$onComplete;
|
|
189
207
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
190
208
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -200,7 +218,7 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
200
218
|
}, _callee3);
|
|
201
219
|
}));
|
|
202
220
|
return function (_x3) {
|
|
203
|
-
return
|
|
221
|
+
return _ref6.apply(this, arguments);
|
|
204
222
|
};
|
|
205
223
|
}()
|
|
206
224
|
}))));
|
package/dist/cjs/ui/main.js
CHANGED
|
@@ -35,7 +35,7 @@ var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsConte
|
|
|
35
35
|
}));
|
|
36
36
|
var PACKAGE_DATA = exports.PACKAGE_DATA = {
|
|
37
37
|
packageName: "@atlaskit/link-create" || '',
|
|
38
|
-
packageVersion: "1.
|
|
38
|
+
packageVersion: "1.9.1" || '',
|
|
39
39
|
componentName: _constants.COMPONENT_NAME,
|
|
40
40
|
source: _constants.COMPONENT_NAME
|
|
41
41
|
};
|
|
@@ -91,9 +91,17 @@ export const CreateForm = ({
|
|
|
91
91
|
css: formStyles
|
|
92
92
|
}, jsx(FormSpy, {
|
|
93
93
|
subscription: {
|
|
94
|
-
|
|
94
|
+
modified: true
|
|
95
95
|
},
|
|
96
|
-
onChange: state =>
|
|
96
|
+
onChange: state => {
|
|
97
|
+
// determine if any of the fields have been modified
|
|
98
|
+
if (!state.modified) {
|
|
99
|
+
setShouldShowWarning(false);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const isModified = Object.values(state.modified).some(value => value);
|
|
103
|
+
setShouldShowWarning(isModified);
|
|
104
|
+
}
|
|
97
105
|
}), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter, {
|
|
98
106
|
formErrorMessage: formErrorMessage,
|
|
99
107
|
handleCancel: handleCancel,
|
|
@@ -31,7 +31,7 @@ export const ConfirmDismissDialog = ({
|
|
|
31
31
|
onClose: onCancelDismiss,
|
|
32
32
|
width: "small"
|
|
33
33
|
}, /*#__PURE__*/React.createElement(ScreenViewedEvent, {
|
|
34
|
-
screen:
|
|
34
|
+
screen: screen
|
|
35
35
|
}), /*#__PURE__*/React.createElement(ModalHeader, null, /*#__PURE__*/React.createElement(ModalTitle, null, intl.formatMessage(messages.title))), /*#__PURE__*/React.createElement(ModalBody, null, intl.formatMessage(messages.description)), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
36
36
|
actionSubjectId: "cancel",
|
|
37
37
|
appearance: "subtle",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import { Fragment, useCallback, useState } from 'react';
|
|
3
|
+
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 Modal, { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
@@ -28,24 +28,18 @@ const LinkCreateContent = ({
|
|
|
28
28
|
}
|
|
29
29
|
return jsx(Fragment, null, chosenOne.form);
|
|
30
30
|
};
|
|
31
|
-
const LinkCreate = ({
|
|
32
|
-
testId = TEST_ID,
|
|
33
|
-
triggeredFrom,
|
|
34
|
-
...restProps
|
|
35
|
-
}) => {
|
|
36
|
-
return jsx(Box, {
|
|
37
|
-
testId: testId
|
|
38
|
-
}, jsx(ErrorBoundary, null, jsx(TrackMount, null), jsx(LinkCreateContent, restProps)));
|
|
39
|
-
};
|
|
40
31
|
const LinkCreateWithModal = ({
|
|
41
32
|
active,
|
|
42
33
|
modalTitle,
|
|
43
34
|
onCreate,
|
|
44
35
|
onFailure,
|
|
45
36
|
onCancel,
|
|
37
|
+
onComplete,
|
|
46
38
|
onOpenComplete,
|
|
47
39
|
onCloseComplete,
|
|
48
|
-
|
|
40
|
+
testId = TEST_ID,
|
|
41
|
+
plugins,
|
|
42
|
+
entityKey
|
|
49
43
|
}) => {
|
|
50
44
|
const intl = useIntl();
|
|
51
45
|
const {
|
|
@@ -88,9 +82,14 @@ const LinkCreateWithModal = ({
|
|
|
88
82
|
onOpenComplete: onOpenComplete,
|
|
89
83
|
onCloseComplete: onCloseComplete,
|
|
90
84
|
width: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`
|
|
91
|
-
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(
|
|
85
|
+
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(Box, {
|
|
86
|
+
testId: testId
|
|
87
|
+
}, jsx(ErrorBoundary, null, jsx(TrackMount, null), jsx(LinkCreateContent, {
|
|
88
|
+
plugins: plugins,
|
|
89
|
+
entityKey: entityKey
|
|
90
|
+
})))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && onComplete && jsx(EditModal, {
|
|
92
91
|
onCloseComplete: onCloseComplete,
|
|
93
|
-
onClose:
|
|
92
|
+
onClose: onComplete
|
|
94
93
|
}), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
|
|
95
94
|
active: showExitWarning,
|
|
96
95
|
onClose: handleCloseExitWarning
|
|
@@ -98,6 +97,17 @@ const LinkCreateWithModal = ({
|
|
|
98
97
|
};
|
|
99
98
|
const LinkCreateModal = props => {
|
|
100
99
|
if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
|
|
100
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
101
|
+
const shouldCallCloseComplete = useRef(!props.active);
|
|
102
|
+
|
|
103
|
+
// modal calls onCloseComplete in a useEffect(), so we can track whether
|
|
104
|
+
// or not we should execute it based on the active prop in a
|
|
105
|
+
// useLayoutEffect() which will be run before child useEffect()s
|
|
106
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
// onCloseComplete should only be called when it is not active
|
|
109
|
+
shouldCallCloseComplete.current = !props.active;
|
|
110
|
+
}, [props.active]);
|
|
101
111
|
return jsx(LinkCreatePluginsProvider, {
|
|
102
112
|
plugins: props.plugins,
|
|
103
113
|
entityKey: props.entityKey
|
|
@@ -128,6 +138,12 @@ const LinkCreateModal = props => {
|
|
|
128
138
|
props.onComplete();
|
|
129
139
|
}
|
|
130
140
|
}
|
|
141
|
+
},
|
|
142
|
+
onCloseComplete: (...args) => {
|
|
143
|
+
if (shouldCallCloseComplete.current) {
|
|
144
|
+
var _props$onCloseComplet;
|
|
145
|
+
(_props$onCloseComplet = props.onCloseComplete) === null || _props$onCloseComplet === void 0 ? void 0 : _props$onCloseComplet.call(props, ...args);
|
|
146
|
+
}
|
|
131
147
|
}
|
|
132
148
|
}))));
|
|
133
149
|
}));
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -26,7 +26,7 @@ const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE
|
|
|
26
26
|
}));
|
|
27
27
|
export const PACKAGE_DATA = {
|
|
28
28
|
packageName: "@atlaskit/link-create" || '',
|
|
29
|
-
packageVersion: "1.
|
|
29
|
+
packageVersion: "1.9.1" || '',
|
|
30
30
|
componentName: COMPONENT_NAME,
|
|
31
31
|
source: COMPONENT_NAME
|
|
32
32
|
};
|
|
@@ -112,10 +112,18 @@ export var CreateForm = function CreateForm(_ref) {
|
|
|
112
112
|
css: formStyles
|
|
113
113
|
}, jsx(FormSpy, {
|
|
114
114
|
subscription: {
|
|
115
|
-
|
|
115
|
+
modified: true
|
|
116
116
|
},
|
|
117
117
|
onChange: function onChange(state) {
|
|
118
|
-
|
|
118
|
+
// determine if any of the fields have been modified
|
|
119
|
+
if (!state.modified) {
|
|
120
|
+
setShouldShowWarning(false);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
var isModified = Object.values(state.modified).some(function (value) {
|
|
124
|
+
return value;
|
|
125
|
+
});
|
|
126
|
+
setShouldShowWarning(isModified);
|
|
119
127
|
}
|
|
120
128
|
}), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter, {
|
|
121
129
|
formErrorMessage: formErrorMessage,
|
|
@@ -31,7 +31,7 @@ export var ConfirmDismissDialog = function ConfirmDismissDialog(_ref) {
|
|
|
31
31
|
onClose: onCancelDismiss,
|
|
32
32
|
width: "small"
|
|
33
33
|
}, /*#__PURE__*/React.createElement(ScreenViewedEvent, {
|
|
34
|
-
screen:
|
|
34
|
+
screen: screen
|
|
35
35
|
}), /*#__PURE__*/React.createElement(ModalHeader, null, /*#__PURE__*/React.createElement(ModalTitle, null, intl.formatMessage(messages.title))), /*#__PURE__*/React.createElement(ModalBody, null, intl.formatMessage(messages.description)), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
36
36
|
actionSubjectId: "cancel",
|
|
37
37
|
appearance: "subtle",
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["testId", "triggeredFrom"],
|
|
6
|
-
_excluded2 = ["active", "modalTitle", "onCreate", "onFailure", "onCancel", "onOpenComplete", "onCloseComplete"];
|
|
7
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
5
|
/** @jsx jsx */
|
|
9
|
-
import { Fragment, useCallback, useState } from 'react';
|
|
6
|
+
import { Fragment, useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
10
7
|
import { jsx } from '@emotion/react';
|
|
11
8
|
import { useIntl } from 'react-intl-next';
|
|
12
9
|
import Modal, { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
@@ -35,29 +32,24 @@ var LinkCreateContent = function LinkCreateContent(_ref) {
|
|
|
35
32
|
}
|
|
36
33
|
return jsx(Fragment, null, chosenOne.form);
|
|
37
34
|
};
|
|
38
|
-
var
|
|
39
|
-
var
|
|
35
|
+
var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
|
|
36
|
+
var active = _ref2.active,
|
|
37
|
+
modalTitle = _ref2.modalTitle,
|
|
38
|
+
onCreate = _ref2.onCreate,
|
|
39
|
+
onFailure = _ref2.onFailure,
|
|
40
|
+
onCancel = _ref2.onCancel,
|
|
41
|
+
onComplete = _ref2.onComplete,
|
|
42
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
43
|
+
onCloseComplete = _ref2.onCloseComplete,
|
|
44
|
+
_ref2$testId = _ref2.testId,
|
|
40
45
|
testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return jsx(Box, {
|
|
44
|
-
testId: testId
|
|
45
|
-
}, jsx(ErrorBoundary, null, jsx(TrackMount, null), jsx(LinkCreateContent, restProps)));
|
|
46
|
-
};
|
|
47
|
-
var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
48
|
-
var active = _ref3.active,
|
|
49
|
-
modalTitle = _ref3.modalTitle,
|
|
50
|
-
onCreate = _ref3.onCreate,
|
|
51
|
-
onFailure = _ref3.onFailure,
|
|
52
|
-
onCancel = _ref3.onCancel,
|
|
53
|
-
onOpenComplete = _ref3.onOpenComplete,
|
|
54
|
-
onCloseComplete = _ref3.onCloseComplete,
|
|
55
|
-
createProps = _objectWithoutProperties(_ref3, _excluded2);
|
|
46
|
+
plugins = _ref2.plugins,
|
|
47
|
+
entityKey = _ref2.entityKey;
|
|
56
48
|
var intl = useIntl();
|
|
57
49
|
var _useFormContext = useFormContext(),
|
|
58
50
|
setFormErrorMessage = _useFormContext.setFormErrorMessage;
|
|
59
51
|
var handleCreate = useCallback( /*#__PURE__*/function () {
|
|
60
|
-
var
|
|
52
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(result) {
|
|
61
53
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
62
54
|
while (1) switch (_context.prev = _context.next) {
|
|
63
55
|
case 0:
|
|
@@ -76,7 +68,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
|
76
68
|
}, _callee);
|
|
77
69
|
}));
|
|
78
70
|
return function (_x) {
|
|
79
|
-
return
|
|
71
|
+
return _ref3.apply(this, arguments);
|
|
80
72
|
};
|
|
81
73
|
}(), [onCreate, setFormErrorMessage]);
|
|
82
74
|
var handleFailure = useCallback(function (error) {
|
|
@@ -113,9 +105,14 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
|
113
105
|
onOpenComplete: onOpenComplete,
|
|
114
106
|
onCloseComplete: onCloseComplete,
|
|
115
107
|
width: "".concat(CREATE_FORM_MAX_WIDTH_IN_PX, "px")
|
|
116
|
-
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(
|
|
108
|
+
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(Box, {
|
|
109
|
+
testId: testId
|
|
110
|
+
}, jsx(ErrorBoundary, null, jsx(TrackMount, null), jsx(LinkCreateContent, {
|
|
111
|
+
plugins: plugins,
|
|
112
|
+
entityKey: entityKey
|
|
113
|
+
})))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && onComplete && jsx(EditModal, {
|
|
117
114
|
onCloseComplete: onCloseComplete,
|
|
118
|
-
onClose:
|
|
115
|
+
onClose: onComplete
|
|
119
116
|
}), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
|
|
120
117
|
active: showExitWarning,
|
|
121
118
|
onClose: handleCloseExitWarning
|
|
@@ -123,24 +120,35 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref3) {
|
|
|
123
120
|
};
|
|
124
121
|
var LinkCreateModal = function LinkCreateModal(props) {
|
|
125
122
|
if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
|
|
123
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
124
|
+
var shouldCallCloseComplete = useRef(!props.active);
|
|
125
|
+
|
|
126
|
+
// modal calls onCloseComplete in a useEffect(), so we can track whether
|
|
127
|
+
// or not we should execute it based on the active prop in a
|
|
128
|
+
// useLayoutEffect() which will be run before child useEffect()s
|
|
129
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
130
|
+
useLayoutEffect(function () {
|
|
131
|
+
// onCloseComplete should only be called when it is not active
|
|
132
|
+
shouldCallCloseComplete.current = !props.active;
|
|
133
|
+
}, [props.active]);
|
|
126
134
|
return jsx(LinkCreatePluginsProvider, {
|
|
127
135
|
plugins: props.plugins,
|
|
128
136
|
entityKey: props.entityKey
|
|
129
137
|
}, function (pluginsProvider) {
|
|
130
138
|
return jsx(EditPostCreateModalProvider, {
|
|
131
139
|
active: !!props.active
|
|
132
|
-
}, function (
|
|
140
|
+
}, function (_ref4) {
|
|
133
141
|
var _pluginsProvider$acti;
|
|
134
|
-
var setEditViewPayload =
|
|
135
|
-
editViewPayload =
|
|
136
|
-
shouldActivateEditView =
|
|
137
|
-
enableEditView =
|
|
142
|
+
var setEditViewPayload = _ref4.setEditViewPayload,
|
|
143
|
+
editViewPayload = _ref4.editViewPayload,
|
|
144
|
+
shouldActivateEditView = _ref4.shouldActivateEditView,
|
|
145
|
+
enableEditView = _ref4.enableEditView;
|
|
138
146
|
return jsx(FormContextProvider, {
|
|
139
147
|
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
|
|
140
148
|
}, jsx(ExitWarningModalProvider, null, jsx(LinkCreateWithModal, _extends({}, props, {
|
|
141
149
|
active: props.active && !editViewPayload,
|
|
142
150
|
onCreate: /*#__PURE__*/function () {
|
|
143
|
-
var
|
|
151
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(payload) {
|
|
144
152
|
var _props$onCreate;
|
|
145
153
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
146
154
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -165,16 +173,25 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
165
173
|
}, _callee2);
|
|
166
174
|
}));
|
|
167
175
|
return function (_x2) {
|
|
168
|
-
return
|
|
176
|
+
return _ref5.apply(this, arguments);
|
|
169
177
|
};
|
|
170
|
-
}()
|
|
178
|
+
}(),
|
|
179
|
+
onCloseComplete: function onCloseComplete() {
|
|
180
|
+
if (shouldCallCloseComplete.current) {
|
|
181
|
+
var _props$onCloseComplet;
|
|
182
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
183
|
+
args[_key] = arguments[_key];
|
|
184
|
+
}
|
|
185
|
+
(_props$onCloseComplet = props.onCloseComplete) === null || _props$onCloseComplet === void 0 || _props$onCloseComplet.call.apply(_props$onCloseComplet, [props].concat(args));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
171
188
|
}))));
|
|
172
189
|
});
|
|
173
190
|
});
|
|
174
191
|
}
|
|
175
192
|
return jsx(FormContextProvider, null, jsx(ExitWarningModalProvider, null, jsx(LinkCreateWithModal, _extends({}, props, {
|
|
176
193
|
onCreate: /*#__PURE__*/function () {
|
|
177
|
-
var
|
|
194
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(payload) {
|
|
178
195
|
var _props$onCreate2, _props$onComplete;
|
|
179
196
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
180
197
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -190,7 +207,7 @@ var LinkCreateModal = function LinkCreateModal(props) {
|
|
|
190
207
|
}, _callee3);
|
|
191
208
|
}));
|
|
192
209
|
return function (_x3) {
|
|
193
|
-
return
|
|
210
|
+
return _ref6.apply(this, arguments);
|
|
194
211
|
};
|
|
195
212
|
}()
|
|
196
213
|
}))));
|
package/dist/esm/ui/main.js
CHANGED
|
@@ -27,7 +27,7 @@ var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__
|
|
|
27
27
|
}));
|
|
28
28
|
export var PACKAGE_DATA = {
|
|
29
29
|
packageName: "@atlaskit/link-create" || '',
|
|
30
|
-
packageVersion: "1.
|
|
30
|
+
packageVersion: "1.9.1" || '',
|
|
31
31
|
componentName: COMPONENT_NAME,
|
|
32
32
|
source: COMPONENT_NAME
|
|
33
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-create",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "The driver component of meta creation flow",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
38
|
-
"@atlaskit/button": "^16.
|
|
38
|
+
"@atlaskit/button": "^16.16.0",
|
|
39
39
|
"@atlaskit/empty-state": "^7.6.0",
|
|
40
40
|
"@atlaskit/form": "^9.0.0",
|
|
41
41
|
"@atlaskit/icon": "^21.12.0",
|
|
42
42
|
"@atlaskit/intl-messages-provider": "^1.0.0",
|
|
43
|
-
"@atlaskit/linking-common": "^4.
|
|
43
|
+
"@atlaskit/linking-common": "^4.18.0",
|
|
44
44
|
"@atlaskit/modal-dialog": "^12.8.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
46
46
|
"@atlaskit/primitives": "^1.10.0",
|