@atlaskit/link-create 2.0.0 → 2.2.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +352 -337
  2. package/dist/cjs/common/constants.js +8 -2
  3. package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -6
  4. package/dist/cjs/{ui/link-create → common/ui}/edit-modal/index.js +4 -8
  5. package/dist/cjs/{ui/link-create → common/ui}/error-boundary/index.js +1 -1
  6. package/dist/cjs/{controllers → common/ui}/experience-tracker/index.js +3 -3
  7. package/dist/cjs/common/ui/link-create-content/index.js +21 -0
  8. package/dist/cjs/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
  9. package/dist/cjs/controllers/callback-context/main.js +1 -1
  10. package/dist/cjs/index.js +6 -0
  11. package/dist/cjs/ui/create-form/main.js +1 -1
  12. package/dist/cjs/ui/create-form/user-picker/index.js +12 -0
  13. package/dist/cjs/ui/create-form/user-picker/main.js +59 -0
  14. package/dist/cjs/ui/create-form/user-picker/types.js +5 -0
  15. package/dist/cjs/ui/index.js +19 -5
  16. package/dist/cjs/ui/{main.js → inline-create/index.js} +11 -17
  17. package/dist/cjs/ui/inline-create/main.js +125 -0
  18. package/dist/cjs/ui/modal-create/index.js +38 -0
  19. package/dist/cjs/ui/{link-create → modal-create}/main.js +36 -39
  20. package/dist/es2019/common/constants.js +7 -1
  21. package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -7
  22. package/dist/es2019/{ui/link-create → common/ui}/edit-modal/index.js +4 -10
  23. package/dist/es2019/{ui/link-create → common/ui}/error-boundary/index.js +1 -1
  24. package/dist/es2019/{controllers → common/ui}/experience-tracker/index.js +3 -3
  25. package/dist/es2019/common/ui/link-create-content/index.js +11 -0
  26. package/dist/es2019/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
  27. package/dist/es2019/controllers/callback-context/main.js +1 -1
  28. package/dist/es2019/index.js +4 -1
  29. package/dist/es2019/ui/create-form/main.js +1 -1
  30. package/dist/es2019/ui/create-form/user-picker/index.js +1 -0
  31. package/dist/es2019/ui/create-form/user-picker/main.js +48 -0
  32. package/dist/es2019/ui/create-form/user-picker/types.js +1 -0
  33. package/dist/es2019/ui/index.js +4 -2
  34. package/dist/es2019/ui/inline-create/index.js +30 -0
  35. package/dist/es2019/ui/inline-create/main.js +100 -0
  36. package/dist/es2019/ui/{main.js → modal-create/index.js} +8 -14
  37. package/dist/es2019/ui/{link-create → modal-create}/main.js +19 -19
  38. package/dist/esm/common/constants.js +7 -1
  39. package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/main.js +4 -6
  40. package/dist/esm/{ui/link-create → common/ui}/edit-modal/index.js +4 -8
  41. package/dist/esm/{ui/link-create → common/ui}/error-boundary/index.js +1 -1
  42. package/dist/esm/{controllers → common/ui}/experience-tracker/index.js +3 -3
  43. package/dist/esm/common/ui/link-create-content/index.js +12 -0
  44. package/dist/esm/{ui/link-create → common/ui}/modal-hero/index.js +1 -3
  45. package/dist/esm/controllers/callback-context/main.js +1 -1
  46. package/dist/esm/index.js +4 -1
  47. package/dist/esm/ui/create-form/main.js +1 -1
  48. package/dist/esm/ui/create-form/user-picker/index.js +1 -0
  49. package/dist/esm/ui/create-form/user-picker/main.js +51 -0
  50. package/dist/esm/ui/create-form/user-picker/types.js +1 -0
  51. package/dist/esm/ui/index.js +4 -2
  52. package/dist/esm/ui/inline-create/index.js +30 -0
  53. package/dist/esm/ui/inline-create/main.js +119 -0
  54. package/dist/esm/ui/{main.js → modal-create/index.js} +8 -14
  55. package/dist/esm/ui/{link-create → modal-create}/main.js +38 -41
  56. package/dist/types/common/constants.d.ts +2 -0
  57. package/dist/types/common/ui/Button/index.d.ts +1 -1
  58. package/dist/types/common/ui/confirm-dismiss-dialog/main.d.ts +7 -0
  59. package/dist/types/common/ui/edit-modal/index.d.ts +11 -0
  60. package/dist/types/{ui/link-create → common/ui}/error-boundary/index.d.ts +1 -1
  61. package/dist/types/common/ui/link-create-content/index.d.ts +8 -0
  62. package/dist/types/common/utils/analytics/index.d.ts +1 -1
  63. package/dist/types/controllers/exit-warning-modal-context/index.d.ts +1 -1
  64. package/dist/types/controllers/form-context/index.d.ts +1 -1
  65. package/dist/types/index.d.ts +2 -2
  66. package/dist/types/ui/create-form/form-spy/index.d.ts +1 -1
  67. package/dist/types/ui/create-form/user-picker/index.d.ts +1 -0
  68. package/dist/types/ui/create-form/user-picker/main.d.ts +8 -0
  69. package/dist/types/ui/create-form/user-picker/types.d.ts +25 -0
  70. package/dist/types/ui/index.d.ts +3 -1
  71. package/dist/types/ui/inline-create/index.d.ts +5 -0
  72. package/dist/types/ui/inline-create/main.d.ts +5 -0
  73. package/dist/types/ui/modal-create/index.d.ts +5 -0
  74. package/dist/{types-ts4.5/ui/link-create → types/ui/modal-create}/main.d.ts +1 -1
  75. package/dist/types-ts4.5/common/constants.d.ts +2 -0
  76. package/dist/types-ts4.5/common/ui/Button/index.d.ts +1 -1
  77. package/dist/types-ts4.5/common/ui/confirm-dismiss-dialog/main.d.ts +7 -0
  78. package/dist/types-ts4.5/common/ui/edit-modal/index.d.ts +11 -0
  79. package/dist/types-ts4.5/{ui/link-create → common/ui}/error-boundary/index.d.ts +1 -1
  80. package/dist/types-ts4.5/common/ui/link-create-content/index.d.ts +8 -0
  81. package/dist/types-ts4.5/common/utils/analytics/index.d.ts +1 -1
  82. package/dist/types-ts4.5/controllers/exit-warning-modal-context/index.d.ts +1 -1
  83. package/dist/types-ts4.5/controllers/form-context/index.d.ts +1 -1
  84. package/dist/types-ts4.5/index.d.ts +2 -2
  85. package/dist/types-ts4.5/ui/create-form/form-spy/index.d.ts +1 -1
  86. package/dist/types-ts4.5/ui/create-form/user-picker/index.d.ts +1 -0
  87. package/dist/types-ts4.5/ui/create-form/user-picker/main.d.ts +8 -0
  88. package/dist/types-ts4.5/ui/create-form/user-picker/types.d.ts +25 -0
  89. package/dist/types-ts4.5/ui/index.d.ts +3 -1
  90. package/dist/types-ts4.5/ui/{main.d.ts → inline-create/index.d.ts} +1 -3
  91. package/dist/types-ts4.5/ui/inline-create/main.d.ts +5 -0
  92. package/dist/{types/ui/main.d.ts → types-ts4.5/ui/modal-create/index.d.ts} +1 -3
  93. package/dist/{types/ui/link-create → types-ts4.5/ui/modal-create}/main.d.ts +1 -1
  94. package/example-helpers/mock-disclaimer.tsx +11 -11
  95. package/example-helpers/mock-plugin-form.tsx +71 -74
  96. package/package.json +6 -7
  97. package/dist/cjs/ui/link-create/index.js +0 -13
  98. package/dist/es2019/ui/link-create/index.js +0 -1
  99. package/dist/esm/ui/link-create/index.js +0 -1
  100. package/dist/types/ui/link-create/confirm-dismiss-dialog/main.d.ts +0 -6
  101. package/dist/types/ui/link-create/edit-modal/index.d.ts +0 -8
  102. package/dist/types/ui/link-create/index.d.ts +0 -1
  103. package/dist/types-ts4.5/ui/link-create/confirm-dismiss-dialog/main.d.ts +0 -6
  104. package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +0 -8
  105. package/dist/types-ts4.5/ui/link-create/index.d.ts +0 -1
  106. /package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
  107. /package/dist/cjs/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
  108. /package/dist/cjs/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
  109. /package/dist/cjs/ui/{link-create → modal-create}/messages.js +0 -0
  110. /package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
  111. /package/dist/es2019/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
  112. /package/dist/es2019/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
  113. /package/dist/es2019/ui/{link-create → modal-create}/messages.js +0 -0
  114. /package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.js +0 -0
  115. /package/dist/esm/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.js +0 -0
  116. /package/dist/esm/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.js +0 -0
  117. /package/dist/esm/ui/{link-create → modal-create}/messages.js +0 -0
  118. /package/dist/types/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.d.ts +0 -0
  119. /package/dist/types/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.d.ts +0 -0
  120. /package/dist/types/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.d.ts +0 -0
  121. /package/dist/types/{controllers → common/ui}/experience-tracker/index.d.ts +0 -0
  122. /package/dist/types/{ui/link-create → common/ui}/modal-hero/index.d.ts +0 -0
  123. /package/dist/types/ui/{link-create → modal-create}/messages.d.ts +0 -0
  124. /package/dist/types-ts4.5/{ui/link-create → common/ui}/confirm-dismiss-dialog/index.d.ts +0 -0
  125. /package/dist/types-ts4.5/{ui/link-create → common/ui}/confirm-dismiss-dialog/messages.d.ts +0 -0
  126. /package/dist/types-ts4.5/{ui/link-create → common/ui}/error-boundary/error-boundary-base/index.d.ts +0 -0
  127. /package/dist/types-ts4.5/{controllers → common/ui}/experience-tracker/index.d.ts +0 -0
  128. /package/dist/types-ts4.5/{ui/link-create → common/ui}/modal-hero/index.d.ts +0 -0
  129. /package/dist/types-ts4.5/ui/{link-create → modal-create}/messages.d.ts +0 -0
@@ -15,46 +15,36 @@ var _reactIntlNext = require("react-intl-next");
15
15
  var _modalDialog = require("@atlaskit/modal-dialog");
16
16
  var _primitives = require("@atlaskit/primitives");
17
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");
18
23
  var _ModalDialog = require("../../common/ui/ModalDialog");
19
24
  var _callbackContext = require("../../controllers/callback-context");
20
25
  var _editPostCreateContext = require("../../controllers/edit-post-create-context");
21
26
  var _exitWarningModalContext = require("../../controllers/exit-warning-modal-context");
22
27
  var _formContext = require("../../controllers/form-context");
23
28
  var _pluginContext = require("../../controllers/plugin-context");
24
- var _confirmDismissDialog = require("./confirm-dismiss-dialog");
25
- var _editModal = require("./edit-modal");
26
- var _errorBoundary = require("./error-boundary");
27
29
  var _messages = require("./messages");
28
- var _modalHero = require("./modal-hero");
29
30
  /** @jsx jsx */
30
31
 
31
32
  var TEST_ID = exports.TEST_ID = 'link-create';
32
33
  var SCREEN_ID = 'linkCreateScreen';
33
- var LinkCreateContent = function LinkCreateContent(_ref) {
34
- var plugins = _ref.plugins,
35
- entityKey = _ref.entityKey;
36
- var chosenOne = plugins.find(function (plugin) {
37
- return plugin.key === entityKey;
38
- });
39
- if (!chosenOne) {
40
- throw new Error('Make sure you specified a valid entityKey');
41
- }
42
- return (0, _react2.jsx)(_react.Fragment, null, chosenOne.form);
43
- };
44
- var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
45
- var active = _ref2.active,
46
- modalTitle = _ref2.modalTitle,
47
- onCreate = _ref2.onCreate,
48
- onFailure = _ref2.onFailure,
49
- onCancel = _ref2.onCancel,
50
- onComplete = _ref2.onComplete,
51
- onOpenComplete = _ref2.onOpenComplete,
52
- onCloseComplete = _ref2.onCloseComplete,
53
- _ref2$testId = _ref2.testId,
54
- testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
55
- plugins = _ref2.plugins,
56
- entityKey = _ref2.entityKey,
57
- 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;
58
48
  var intl = (0, _reactIntlNext.useIntl)();
59
49
  var _useExitWarningModal = (0, _exitWarningModalContext.useExitWarningModal)(),
60
50
  getShouldShowWarning = _useExitWarningModal.getShouldShowWarning;
@@ -62,6 +52,10 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
62
52
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
63
53
  showExitWarning = _useState2[0],
64
54
  setShowExitWarning = _useState2[1];
55
+ var _useEditPostCreateMod = (0, _editPostCreateContext.useEditPostCreateModal)(),
56
+ editViewPayload = _useEditPostCreateMod.editViewPayload;
57
+ var _useLinkCreatePlugins = (0, _pluginContext.useLinkCreatePlugins)(),
58
+ activePlugin = _useLinkCreatePlugins.activePlugin;
65
59
  var handleCancel = (0, _react.useCallback)(function () {
66
60
  if (getShouldShowWarning() && !showExitWarning) {
67
61
  setShowExitWarning(true);
@@ -88,15 +82,18 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref2) {
88
82
  hero: modalHero
89
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, {
90
84
  testId: testId
91
- }, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(LinkCreateContent, {
85
+ }, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_linkCreateContent.LinkCreateContent, {
92
86
  plugins: plugins,
93
87
  entityKey: entityKey
94
88
  })))))), onComplete && (0, _react2.jsx)(_editModal.EditModal, {
95
89
  onCloseComplete: onCloseComplete,
96
- onClose: onComplete
90
+ onClose: onComplete,
91
+ editViewPayload: editViewPayload,
92
+ activePlugin: activePlugin
97
93
  }), (0, _react2.jsx)(_confirmDismissDialog.ConfirmDismissDialog, {
98
94
  active: showExitWarning,
99
- onClose: handleCloseExitWarning
95
+ onClose: handleCloseExitWarning,
96
+ onCancel: onCancel
100
97
  }));
101
98
  };
102
99
  var LinkCreateModal = function LinkCreateModal(props) {
@@ -115,18 +112,18 @@ var LinkCreateModal = function LinkCreateModal(props) {
115
112
  }, function (pluginsProvider) {
116
113
  return (0, _react2.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
117
114
  active: !!props.active
118
- }, function (_ref3) {
115
+ }, function (_ref2) {
119
116
  var _pluginsProvider$acti;
120
- var setEditViewPayload = _ref3.setEditViewPayload,
121
- editViewPayload = _ref3.editViewPayload,
122
- shouldActivateEditView = _ref3.shouldActivateEditView,
123
- enableEditView = _ref3.enableEditView;
117
+ var setEditViewPayload = _ref2.setEditViewPayload,
118
+ editViewPayload = _ref2.editViewPayload,
119
+ shouldActivateEditView = _ref2.shouldActivateEditView,
120
+ enableEditView = _ref2.enableEditView;
124
121
  return (0, _react2.jsx)(_formContext.FormContextProvider, {
125
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
126
123
  }, (0, _react2.jsx)(_exitWarningModalContext.ExitWarningModalProvider, null, (0, _react2.jsx)(LinkCreateWithModal, (0, _extends2.default)({}, props, {
127
124
  active: props.active && !editViewPayload,
128
125
  onCreate: ( /*#__PURE__*/function () {
129
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload) {
126
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload) {
130
127
  var _props$onCreate;
131
128
  return _regenerator.default.wrap(function _callee$(_context) {
132
129
  while (1) switch (_context.prev = _context.next) {
@@ -151,7 +148,7 @@ var LinkCreateModal = function LinkCreateModal(props) {
151
148
  }, _callee);
152
149
  }));
153
150
  return function (_x) {
154
- return _ref4.apply(this, arguments);
151
+ return _ref3.apply(this, arguments);
155
152
  };
156
153
  }()),
157
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.2.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 '../../../common/ui/Button';
6
- import { Modal } from '../../../common/ui/ModalDialog';
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 '../../../common/ui/ModalDialog';
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,
@@ -3,7 +3,7 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../../common/constants';
4
4
  import { ErrorBoundaryUI } from '../../../common/ui/error-boundary-ui';
5
5
  import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
6
- import { useExperience } from '../../../controllers/experience-tracker';
6
+ import { useExperience } from '../experience-tracker';
7
7
  import { BaseErrorBoundary } from './error-boundary-base';
8
8
  export const ErrorBoundary = ({
9
9
  children,
@@ -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 '../../common/constants';
5
- import createEventPayload from '../../common/utils/analytics/analytics.codegen';
6
- import { getErrorType, getNetworkFields } from '../../common/utils/errors';
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,9 +1,9 @@
1
1
  import React, { useContext, useMemo } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../common/constants';
4
+ import { useExperience } from '../../common/ui/experience-tracker';
4
5
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
5
6
  import { getErrorType } from '../../common/utils/errors';
6
- import { useExperience } from '../experience-tracker';
7
7
  const LinkCreateCallbackContext = /*#__PURE__*/React.createContext({});
8
8
  const LinkCreateCallbackProvider = ({
9
9
  children,
@@ -1,3 +1,6 @@
1
- export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy } from './ui/index';
1
+ export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy,
2
+ // todo: EDM-10077 - export this once inline-create is tested/ready
3
+ //InlineCreate,
4
+ UserPicker } from './ui/index';
2
5
  export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
3
6
  export { FORM_ERROR } from 'final-form';
@@ -121,7 +121,7 @@ export const CreateForm = ({
121
121
  }
122
122
  }), jsx("p", {
123
123
  "aria-hidden": "true"
124
- }, intl.formatMessage(messages.requiredFieldInstruction), ' ', jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
124
+ }, intl.formatMessage(messages.requiredFieldInstruction), " ", jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
125
125
  /**
126
126
  * We will prefer to render the error message connected to
127
127
  * react final form state (submitError) otherwise we can
@@ -0,0 +1 @@
1
+ export { UserPicker } from './main';
@@ -0,0 +1,48 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import SmartUserPicker from '@atlaskit/smart-user-picker';
4
+ import { CreateField } from '../../../controllers/create-field';
5
+ export const TEST_ID = 'link-create-user-picker';
6
+ const DEFAULT_DEBOUNCE_TIME = 400;
7
+ const UserPickerWidth = "100%";
8
+
9
+ /**
10
+ * A user picker utilising the SmartUserPicker.
11
+ */
12
+
13
+ export function UserPicker({
14
+ productKey,
15
+ siteId,
16
+ name,
17
+ label,
18
+ placeholder,
19
+ validators,
20
+ testId = TEST_ID,
21
+ defaultValue
22
+ }) {
23
+ return jsx(CreateField, {
24
+ name: name,
25
+ label: label,
26
+ isRequired: true,
27
+ testId: testId,
28
+ validators: validators
29
+ }, ({
30
+ fieldId,
31
+ ...fieldProps
32
+ }) => {
33
+ return jsx(SmartUserPicker, {
34
+ defaultValue: defaultValue,
35
+ placeholder: placeholder,
36
+ onChange: value => fieldProps.onChange(value),
37
+ subtle: true,
38
+ isMulti: false,
39
+ productKey: productKey,
40
+ siteId: siteId,
41
+ fieldId: fieldId,
42
+ debounceTime: DEFAULT_DEBOUNCE_TIME,
43
+ prefetch: true,
44
+ isClearable: false,
45
+ width: UserPickerWidth
46
+ });
47
+ });
48
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,9 @@
1
- export { default } from './main';
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';
5
6
  export { Select } from './create-form/select';
6
7
  export { AsyncSelect } from './create-form/async-select';
7
- export { FormSpy } from './create-form/form-spy';
8
+ export { FormSpy } from './create-form/form-spy';
9
+ export { UserPicker } from './create-form/user-picker';
@@ -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;
@@ -3,14 +3,14 @@ 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 { COMPONENT_NAME } from '../common/constants';
7
- import { ErrorBoundaryModal } from '../common/ui/error-boundary-modal';
8
- import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
9
- import { fetchMessagesForLocale } from '../common/utils/locale/fetch-messages-for-locale';
10
- import { Experience } from '../controllers/experience-tracker';
11
- import i18nEN from '../i18n/en';
12
- import LinkCreate from './link-create';
13
- import { ErrorBoundary } from './link-create/error-boundary';
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
14
  const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(props => {
15
15
  return jsx(Experience, null, jsx(ErrorBoundary, {
16
16
  errorComponent: jsx(ErrorBoundaryModal, {
@@ -19,12 +19,6 @@ const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE
19
19
  })
20
20
  }, jsx(LinkCreate, props)));
21
21
  }));
22
- export const PACKAGE_DATA = {
23
- packageName: "@atlaskit/link-create" || '',
24
- packageVersion: "2.0.0" || '',
25
- component: COMPONENT_NAME,
26
- componentName: COMPONENT_NAME
27
- };
28
22
  const ComposedLinkCreate = /*#__PURE__*/memo(props => {
29
23
  return jsx(AnalyticsContext, {
30
24
  data: PACKAGE_DATA
@@ -1,34 +1,25 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
- import { Fragment, useCallback, useLayoutEffect, useRef, useState } from 'react';
3
+ import { 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
7
  import { Box } from '@atlaskit/primitives';
8
8
  import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
9
+ import { ConfirmDismissDialog } from '../../common/ui/confirm-dismiss-dialog';
10
+ import { EditModal } from '../../common/ui/edit-modal';
11
+ import { ErrorBoundary } from '../../common/ui/error-boundary';
12
+ import { LinkCreateContent } from '../../common/ui/link-create-content';
13
+ import { ModalHero } from '../../common/ui/modal-hero';
9
14
  import { Modal } from '../../common/ui/ModalDialog';
10
15
  import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
11
- import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
16
+ import { EditPostCreateModalProvider, useEditPostCreateModal } from '../../controllers/edit-post-create-context';
12
17
  import { ExitWarningModalProvider, useExitWarningModal } from '../../controllers/exit-warning-modal-context';
13
18
  import { FormContextProvider } from '../../controllers/form-context';
14
- import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
15
- import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
16
- import { EditModal } from './edit-modal';
17
- import { ErrorBoundary } from './error-boundary';
19
+ import { LinkCreatePluginsProvider, useLinkCreatePlugins } from '../../controllers/plugin-context';
18
20
  import { messages } from './messages';
19
- import { ModalHero } from './modal-hero';
20
21
  export const TEST_ID = 'link-create';
21
22
  const SCREEN_ID = 'linkCreateScreen';
22
- const LinkCreateContent = ({
23
- plugins,
24
- entityKey
25
- }) => {
26
- const chosenOne = plugins.find(plugin => plugin.key === entityKey);
27
- if (!chosenOne) {
28
- throw new Error('Make sure you specified a valid entityKey');
29
- }
30
- return jsx(Fragment, null, chosenOne.form);
31
- };
32
23
  const LinkCreateWithModal = ({
33
24
  active,
34
25
  modalTitle,
@@ -48,6 +39,12 @@ const LinkCreateWithModal = ({
48
39
  getShouldShowWarning
49
40
  } = useExitWarningModal();
50
41
  const [showExitWarning, setShowExitWarning] = useState(false);
42
+ const {
43
+ editViewPayload
44
+ } = useEditPostCreateModal();
45
+ const {
46
+ activePlugin
47
+ } = useLinkCreatePlugins();
51
48
  const handleCancel = useCallback(() => {
52
49
  if (getShouldShowWarning() && !showExitWarning) {
53
50
  setShowExitWarning(true);
@@ -77,10 +74,13 @@ const LinkCreateWithModal = ({
77
74
  entityKey: entityKey
78
75
  })))))), onComplete && jsx(EditModal, {
79
76
  onCloseComplete: onCloseComplete,
80
- onClose: onComplete
77
+ onClose: onComplete,
78
+ editViewPayload: editViewPayload,
79
+ activePlugin: activePlugin
81
80
  }), jsx(ConfirmDismissDialog, {
82
81
  active: showExitWarning,
83
- onClose: handleCloseExitWarning
82
+ onClose: handleCloseExitWarning,
83
+ onCancel: onCancel
84
84
  }));
85
85
  };
86
86
  const LinkCreateModal = props => {
@@ -2,4 +2,10 @@ export var ANALYTICS_CHANNEL = 'media';
2
2
  export var COMPONENT_NAME = 'linkCreate';
3
3
  export var CREATE_FORM_MAX_WIDTH_IN_PX = '480';
4
4
  export var CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
5
- export var LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
5
+ export var LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
6
+ export var PACKAGE_DATA = {
7
+ packageName: "@atlaskit/link-create" || '',
8
+ packageVersion: "2.2.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 '../../../common/ui/Button';
6
- import { Modal } from '../../../common/ui/ModalDialog';
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
  var screen = 'linkCreateExitWarningScreen';
10
9
  var context = {
@@ -13,10 +12,9 @@ var context = {
13
12
  };
14
13
  export var ConfirmDismissDialog = function ConfirmDismissDialog(_ref) {
15
14
  var active = _ref.active,
16
- onClose = _ref.onClose;
15
+ onClose = _ref.onClose,
16
+ onCancel = _ref.onCancel;
17
17
  var intl = useIntl();
18
- var _useLinkCreateCallbac = useLinkCreateCallback(),
19
- onCancel = _useLinkCreateCallbac.onCancel;
20
18
  var onCancelDismiss = function onCancelDismiss() {
21
19
  return onClose();
22
20
  };
@@ -1,17 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ModalTransition } from '@atlaskit/modal-dialog';
3
- import { Modal } from '../../../common/ui/ModalDialog';
4
- import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
5
- import { useLinkCreatePlugins } from '../../../controllers/plugin-context';
3
+ import { Modal } from '../ModalDialog';
6
4
  var SCREEN = 'linkCreateEditScreen';
7
5
  export var EditModal = function EditModal(_ref) {
8
6
  var _activePlugin$editVie;
9
7
  var onClose = _ref.onClose,
10
- onCloseComplete = _ref.onCloseComplete;
11
- var _useEditPostCreateMod = useEditPostCreateModal(),
12
- editViewPayload = _useEditPostCreateMod.editViewPayload;
13
- var _useLinkCreatePlugins = useLinkCreatePlugins(),
14
- activePlugin = _useLinkCreatePlugins.activePlugin;
8
+ onCloseComplete = _ref.onCloseComplete,
9
+ editViewPayload = _ref.editViewPayload,
10
+ activePlugin = _ref.activePlugin;
15
11
  return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Modal, {
16
12
  testId: "link-create-edit-modal",
17
13
  screen: SCREEN,