@atlaskit/link-create 1.5.0 → 1.6.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 (83) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/analytics.spec.yaml +14 -0
  3. package/dist/cjs/common/ui/Button/index.js +37 -0
  4. package/dist/cjs/common/ui/error-boundary-modal/index.js +30 -0
  5. package/dist/cjs/common/utils/analytics/analytics.codegen.js +1 -1
  6. package/dist/cjs/common/utils/analytics/components.js +20 -0
  7. package/dist/cjs/controllers/edit-post-create-context/index.js +14 -3
  8. package/dist/cjs/controllers/plugin-context/index.js +1 -1
  9. package/dist/cjs/ui/create-form/main.js +24 -6
  10. package/dist/cjs/ui/link-create/confirm-dismiss-dialog/main.js +18 -5
  11. package/dist/cjs/ui/link-create/edit-modal/index.js +12 -3
  12. package/dist/cjs/ui/link-create/error-boundary/error-boundary-base/index.js +4 -7
  13. package/dist/cjs/ui/link-create/error-boundary/index.js +4 -3
  14. package/dist/cjs/ui/link-create/main.js +53 -6
  15. package/dist/cjs/ui/main.js +12 -1
  16. package/dist/es2019/common/ui/Button/index.js +27 -0
  17. package/dist/es2019/common/ui/error-boundary-modal/index.js +22 -0
  18. package/dist/es2019/common/utils/analytics/analytics.codegen.js +1 -1
  19. package/dist/es2019/common/utils/analytics/components.js +15 -0
  20. package/dist/es2019/controllers/edit-post-create-context/index.js +11 -4
  21. package/dist/es2019/controllers/plugin-context/index.js +1 -1
  22. package/dist/es2019/ui/create-form/main.js +20 -3
  23. package/dist/es2019/ui/link-create/confirm-dismiss-dialog/main.js +17 -4
  24. package/dist/es2019/ui/link-create/edit-modal/index.js +13 -3
  25. package/dist/es2019/ui/link-create/error-boundary/error-boundary-base/index.js +4 -4
  26. package/dist/es2019/ui/link-create/error-boundary/index.js +4 -3
  27. package/dist/es2019/ui/link-create/main.js +38 -6
  28. package/dist/es2019/ui/main.js +12 -1
  29. package/dist/esm/common/ui/Button/index.js +27 -0
  30. package/dist/esm/common/ui/error-boundary-modal/index.js +21 -0
  31. package/dist/esm/common/utils/analytics/analytics.codegen.js +1 -1
  32. package/dist/esm/common/utils/analytics/components.js +13 -0
  33. package/dist/esm/controllers/edit-post-create-context/index.js +15 -4
  34. package/dist/esm/controllers/plugin-context/index.js +1 -1
  35. package/dist/esm/ui/create-form/main.js +24 -5
  36. package/dist/esm/ui/link-create/confirm-dismiss-dialog/main.js +17 -4
  37. package/dist/esm/ui/link-create/edit-modal/index.js +12 -3
  38. package/dist/esm/ui/link-create/error-boundary/error-boundary-base/index.js +4 -4
  39. package/dist/esm/ui/link-create/error-boundary/index.js +4 -3
  40. package/dist/esm/ui/link-create/main.js +54 -7
  41. package/dist/esm/ui/main.js +12 -1
  42. package/dist/types/common/types.d.ts +14 -0
  43. package/dist/types/common/ui/Button/index.d.ts +5 -0
  44. package/dist/types/common/ui/error-boundary-modal/index.d.ts +11 -0
  45. package/dist/types/common/utils/analytics/analytics.codegen.d.ts +6 -2
  46. package/dist/types/common/utils/analytics/components.d.ts +8 -0
  47. package/dist/types/controllers/edit-post-create-context/index.d.ts +23 -3
  48. package/dist/types/controllers/plugin-context/index.d.ts +4 -1
  49. package/dist/types/ui/create-form/main.d.ts +18 -2
  50. package/dist/types/ui/link-create/edit-modal/index.d.ts +8 -4
  51. package/dist/types/ui/link-create/error-boundary/error-boundary-base/index.d.ts +3 -3
  52. package/dist/types/ui/link-create/error-boundary/index.d.ts +5 -1
  53. package/dist/types/ui/link-create/main.d.ts +3 -3
  54. package/dist/types-ts4.5/common/types.d.ts +14 -0
  55. package/dist/types-ts4.5/common/ui/Button/index.d.ts +5 -0
  56. package/dist/types-ts4.5/common/ui/error-boundary-modal/index.d.ts +11 -0
  57. package/dist/types-ts4.5/common/utils/analytics/analytics.codegen.d.ts +6 -2
  58. package/dist/types-ts4.5/common/utils/analytics/components.d.ts +8 -0
  59. package/dist/types-ts4.5/controllers/edit-post-create-context/index.d.ts +23 -3
  60. package/dist/types-ts4.5/controllers/plugin-context/index.d.ts +4 -1
  61. package/dist/types-ts4.5/ui/create-form/main.d.ts +20 -2
  62. package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +8 -4
  63. package/dist/types-ts4.5/ui/link-create/error-boundary/error-boundary-base/index.d.ts +3 -3
  64. package/dist/types-ts4.5/ui/link-create/error-boundary/index.d.ts +5 -1
  65. package/dist/types-ts4.5/ui/link-create/main.d.ts +3 -3
  66. package/package.json +6 -3
  67. package/report.api.md +25 -4
  68. package/tmp/api-report-tmp.d.ts +25 -4
  69. /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
  70. /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
  71. /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
  72. /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
  73. /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
  74. /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
  75. /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
  76. /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
  77. /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
  78. /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.d.ts +0 -0
  79. /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.d.ts +0 -0
  80. /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.d.ts +0 -0
  81. /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.d.ts +0 -0
  82. /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.d.ts +0 -0
  83. /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.d.ts +0 -0
@@ -1,23 +1,30 @@
1
- import React, { createContext, useContext, useMemo, useState } from 'react';
1
+ import React, { createContext, useContext, useMemo, useRef, useState } from 'react';
2
2
  const EditPostCreateModalContext = /*#__PURE__*/createContext({
3
3
  editViewPayload: undefined,
4
- setEditViewPayload: () => {}
4
+ setEditViewPayload: () => {},
5
+ enableEditView: () => {},
6
+ shouldActivateEditView: () => false
5
7
  });
6
8
  export const EditPostCreateModalProvider = ({
7
9
  active,
8
10
  children
9
11
  }) => {
12
+ const shouldActivateEditView = useRef(false);
10
13
  const [editViewPayload, setEditViewPayload] = useState(undefined);
11
14
  const value = useMemo(() => ({
12
15
  editViewPayload,
13
- setEditViewPayload
16
+ setEditViewPayload,
17
+ enableEditView: enable => {
18
+ shouldActivateEditView.current = enable;
19
+ },
20
+ shouldActivateEditView: () => shouldActivateEditView.current
14
21
  }), [editViewPayload, setEditViewPayload]);
15
22
  if (editViewPayload && !active) {
16
23
  setEditViewPayload(undefined);
17
24
  }
18
25
  return /*#__PURE__*/React.createElement(EditPostCreateModalContext.Provider, {
19
26
  value: value
20
- }, children);
27
+ }, typeof children === 'function' ? children(value) : children);
21
28
  };
22
29
  export const useEditPostCreateModal = () => {
23
30
  const value = useContext(EditPostCreateModalContext);
@@ -14,7 +14,7 @@ export const LinkCreatePluginsProvider = ({
14
14
  }, [entityKey, plugins]);
15
15
  return /*#__PURE__*/React.createElement(LinkCreatePluginsContext.Provider, {
16
16
  value: value
17
- }, children);
17
+ }, typeof children === 'function' ? children(value) : children);
18
18
  };
19
19
  export const useLinkCreatePlugins = () => {
20
20
  const value = useContext(LinkCreatePluginsContext);
@@ -3,8 +3,9 @@ import { useCallback } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { Form, FormSpy } from 'react-final-form';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { Box } from '@atlaskit/primitives';
7
- import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
8
+ import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
8
9
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
9
10
  import { useFormContext } from '../../controllers/form-context';
10
11
  import { CreateFormFooter } from './form-footer';
@@ -15,6 +16,7 @@ const formStyles = css({
15
16
  padding: `0 0 ${"var(--ds-space-300, 24px)"} 0`,
16
17
  margin: `${"var(--ds-space-0, 0px)"} auto`
17
18
  });
19
+ const RESERVED_FIELDS = [LINK_CREATE_FORM_POST_CREATE_FIELD];
18
20
  export const TEST_ID = 'link-create-form';
19
21
  export const CreateForm = ({
20
22
  children,
@@ -31,7 +33,8 @@ export const CreateForm = ({
31
33
  const {
32
34
  getValidators,
33
35
  formErrorMessage,
34
- setFormDirty
36
+ setFormDirty,
37
+ enableEditView
35
38
  } = useFormContext();
36
39
  const handleSubmit = useCallback(async data => {
37
40
  createAnalyticsEvent(createEventPayload('ui.button.clicked.create', {})).fire(ANALYTICS_CHANNEL);
@@ -43,8 +46,22 @@ export const CreateForm = ({
43
46
  if (Object.keys(errors).length !== 0) {
44
47
  return errors;
45
48
  }
49
+ if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
50
+ const {
51
+ [LINK_CREATE_FORM_POST_CREATE_FIELD]: shouldEnableEditView,
52
+ ...formData
53
+ } = data;
54
+
55
+ /**
56
+ * If form has post-create field set to trigger post-create edit
57
+ * send this to the form context so we know what to do next
58
+ * if submission is successful
59
+ */
60
+ enableEditView === null || enableEditView === void 0 ? void 0 : enableEditView(!!shouldEnableEditView);
61
+ return onSubmit(formData);
62
+ }
46
63
  return onSubmit(data);
47
- }, [createAnalyticsEvent, getValidators, onSubmit]);
64
+ }, [createAnalyticsEvent, getValidators, onSubmit, enableEditView]);
48
65
  const handleCancel = useCallback(() => {
49
66
  createAnalyticsEvent(createEventPayload('ui.button.clicked.cancel', {})).fire(ANALYTICS_CHANNEL);
50
67
  onCancel && onCancel();
@@ -1,23 +1,36 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
- import Button from '@atlaskit/button';
3
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
4
4
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
5
+ import { Button } from '../../../common/ui/Button';
6
+ import { ScreenViewedEvent } from '../../../common/utils/analytics/components';
5
7
  import messages from './messages';
8
+ const screen = 'linkCreateExitWarningScreen';
9
+ const context = {
10
+ component: screen,
11
+ source: screen
12
+ };
6
13
  export const ConfirmDismissDialog = ({
7
14
  active,
8
15
  onCancelDismiss,
9
16
  onConfirmDismiss
10
17
  }) => {
11
18
  const intl = useIntl();
12
- return /*#__PURE__*/React.createElement(ModalTransition, null, active && /*#__PURE__*/React.createElement(Modal, {
19
+ return /*#__PURE__*/React.createElement(ModalTransition, null, active && /*#__PURE__*/React.createElement(AnalyticsContext, {
20
+ data: context
21
+ }, /*#__PURE__*/React.createElement(Modal, {
13
22
  testId: "link-create-confirm-dismiss-dialog",
14
23
  onClose: onCancelDismiss,
15
24
  width: "small"
16
- }, /*#__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, {
25
+ }, /*#__PURE__*/React.createElement(ScreenViewedEvent, {
26
+ screen: "linkCreateExitWarningScreen"
27
+ }), /*#__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, {
28
+ actionSubjectId: "cancel",
17
29
  appearance: "subtle",
18
30
  onClick: onCancelDismiss
19
31
  }, intl.formatMessage(messages.cancelButtonLabel)), /*#__PURE__*/React.createElement(Button, {
32
+ actionSubjectId: "confirm",
20
33
  appearance: "primary",
21
34
  onClick: onConfirmDismiss
22
- }, intl.formatMessage(messages.confirmButtonLabel)))));
35
+ }, intl.formatMessage(messages.confirmButtonLabel))))));
23
36
  };
@@ -1,17 +1,27 @@
1
1
  import React from 'react';
2
2
  import Modal, { ModalTransition } from '@atlaskit/modal-dialog';
3
3
  import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
4
+ import { useLinkCreatePlugins } from '../../../controllers/plugin-context';
4
5
  export const EditModal = ({
5
- onClose
6
+ onClose,
7
+ onCloseComplete
6
8
  }) => {
9
+ var _activePlugin$editVie;
7
10
  const {
8
11
  editViewPayload
9
12
  } = useEditPostCreateModal();
13
+ const {
14
+ activePlugin
15
+ } = useLinkCreatePlugins();
10
16
  return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(Modal, {
11
17
  testId: "link-create-edit-modal",
12
18
  onClose: onClose,
13
19
  shouldScrollInViewport: true,
14
20
  width: "calc(100vw - 120px)",
15
- height: "calc(100vh - 120px)"
16
- }));
21
+ height: "calc(100vh - 120px)",
22
+ onCloseComplete: onCloseComplete
23
+ }, activePlugin === null || activePlugin === void 0 ? void 0 : (_activePlugin$editVie = activePlugin.editView) === null || _activePlugin$editVie === void 0 ? void 0 : _activePlugin$editVie.call(activePlugin, {
24
+ payload: editViewPayload,
25
+ onClose
26
+ })));
17
27
  };
@@ -1,4 +1,4 @@
1
- import React, { Component } from 'react';
1
+ import { Component } from 'react';
2
2
  // eslint-disable-next-line @repo/internal/react/no-class-components
3
3
  export class BaseErrorBoundary extends Component {
4
4
  constructor(props) {
@@ -19,13 +19,13 @@ export class BaseErrorBoundary extends Component {
19
19
  render() {
20
20
  const {
21
21
  children,
22
- ErrorComponent
22
+ errorComponent
23
23
  } = this.props;
24
24
  const {
25
25
  hasError
26
26
  } = this.state;
27
- if (hasError && ErrorComponent) {
28
- return /*#__PURE__*/React.createElement(ErrorComponent, null);
27
+ if (hasError && errorComponent) {
28
+ return errorComponent;
29
29
  }
30
30
  return children;
31
31
  }
@@ -1,11 +1,12 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../../common/constants';
4
+ import { ErrorBoundaryUI } from '../../../common/ui/error-boundary-ui';
4
5
  import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
5
6
  import { BaseErrorBoundary } from './error-boundary-base';
6
- import { ErrorBoundaryUI } from './error-boundary-ui';
7
7
  export const ErrorBoundary = ({
8
- children
8
+ children,
9
+ errorComponent
9
10
  }) => {
10
11
  const {
11
12
  createAnalyticsEvent
@@ -24,6 +25,6 @@ export const ErrorBoundary = ({
24
25
  }, [createAnalyticsEvent]);
25
26
  return /*#__PURE__*/React.createElement(BaseErrorBoundary, {
26
27
  onError: handleError,
27
- ErrorComponent: ErrorBoundaryUI
28
+ errorComponent: errorComponent !== null && errorComponent !== void 0 ? errorComponent : /*#__PURE__*/React.createElement(ErrorBoundaryUI, null)
28
29
  }, children);
29
30
  };
@@ -9,7 +9,7 @@ import { Box } from '@atlaskit/primitives';
9
9
  import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
10
10
  import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
11
11
  import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
12
- import { useFormContext, withLinkCreateFormContext } from '../../controllers/form-context';
12
+ import { FormContextProvider, useFormContext } from '../../controllers/form-context';
13
13
  import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
14
14
  import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
15
15
  import { EditModal } from './edit-modal';
@@ -96,6 +96,7 @@ const LinkCreateWithModal = ({
96
96
  }, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(LinkCreate, _extends({}, createProps, {
97
97
  onCancel: handleCancel
98
98
  }))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && jsx(EditModal, {
99
+ onCloseComplete: onCloseComplete,
99
100
  onClose: handleCancel
100
101
  }), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
101
102
  active: dismissDialog,
@@ -103,14 +104,45 @@ const LinkCreateWithModal = ({
103
104
  onConfirmDismiss: handleConfirmDismiss
104
105
  }));
105
106
  };
106
- export default withLinkCreateFormContext(props => {
107
+ const LinkCreateModalInternal = props => {
107
108
  if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
108
109
  return jsx(LinkCreatePluginsProvider, {
109
110
  plugins: props.plugins,
110
111
  entityKey: props.entityKey
111
- }, jsx(EditPostCreateModalProvider, {
112
+ }, pluginsProvider => jsx(EditPostCreateModalProvider, {
112
113
  active: !!props.active
113
- }, jsx(LinkCreateWithModal, props)));
114
+ }, ({
115
+ setEditViewPayload,
116
+ editViewPayload,
117
+ shouldActivateEditView,
118
+ enableEditView
119
+ }) => {
120
+ var _pluginsProvider$acti;
121
+ return jsx(FormContextProvider, {
122
+ enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView ? enableEditView : undefined
123
+ }, jsx(LinkCreateWithModal, _extends({}, props, {
124
+ active: props.active && !editViewPayload,
125
+ onCreate: async payload => {
126
+ var _props$onCreate;
127
+ await ((_props$onCreate = props.onCreate) === null || _props$onCreate === void 0 ? void 0 : _props$onCreate.call(props, payload));
128
+
129
+ // if onComplete exists then there is an edit flow
130
+ if (props.onComplete) {
131
+ if (shouldActivateEditView()) {
132
+ //edit button is pressed
133
+ setEditViewPayload(payload);
134
+ } else {
135
+ //create button is pressed
136
+ props.onComplete();
137
+ }
138
+ }
139
+ }
140
+ })));
141
+ }));
114
142
  }
115
- return jsx(LinkCreateWithModal, props);
116
- });
143
+ return jsx(FormContextProvider, null, jsx(LinkCreateWithModal, props));
144
+ };
145
+ const LinkCreateModalPublic = props => {
146
+ return jsx(LinkCreateModalInternal, props);
147
+ };
148
+ export default LinkCreateModalPublic;
@@ -3,19 +3,30 @@ import { memo } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import { AnalyticsContext } from '@atlaskit/analytics-next';
5
5
  import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { COMPONENT_NAME } from '../common/constants';
8
+ import { ErrorBoundaryModal } from '../common/ui/error-boundary-modal';
7
9
  import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
8
10
  import { fetchMessagesForLocale } from '../common/utils/locale/fetch-messages-for-locale';
9
11
  import i18nEN from '../i18n/en';
10
12
  import LinkCreate from './link-create';
13
+ import { ErrorBoundary } from './link-create/error-boundary';
11
14
  const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(({
12
15
  ...props
13
16
  }) => {
17
+ if (getBooleanFF('platform.linking-platform.link-create.outer-error-boundary')) {
18
+ return jsx(ErrorBoundary, {
19
+ errorComponent: jsx(ErrorBoundaryModal, {
20
+ active: props.active,
21
+ onClose: props.onCancel
22
+ })
23
+ }, jsx(LinkCreate, props));
24
+ }
14
25
  return jsx(LinkCreate, props);
15
26
  }));
16
27
  export const PACKAGE_DATA = {
17
28
  packageName: "@atlaskit/link-create" || '',
18
- packageVersion: "1.5.0" || '',
29
+ packageVersion: "1.6.0" || '',
19
30
  componentName: COMPONENT_NAME,
20
31
  source: COMPONENT_NAME
21
32
  };
@@ -0,0 +1,27 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["actionSubjectId"];
4
+ import React, { forwardRef } from 'react';
5
+ import { UIAnalyticsEvent, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
+ import AkButton from '@atlaskit/button';
7
+ import { ANALYTICS_CHANNEL } from '../../../common/constants';
8
+ import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
9
+ export var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
+ var actionSubjectId = _ref.actionSubjectId,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+ var _useAnalyticsEvents = useAnalyticsEvents(),
13
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
14
+ return /*#__PURE__*/React.createElement(AkButton, _extends({}, props, {
15
+ ref: ref,
16
+ onClick: function onClick(event) {
17
+ var _props$onClick;
18
+ var payload = createEventPayload("ui.button.clicked.".concat(actionSubjectId), {});
19
+ var analyticEvent = createAnalyticsEvent(payload);
20
+ var cloned = analyticEvent.clone();
21
+ analyticEvent.fire(ANALYTICS_CHANNEL);
22
+ (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, event, cloned !== null && cloned !== void 0 ? cloned : new UIAnalyticsEvent({
23
+ payload: payload
24
+ }));
25
+ }
26
+ }));
27
+ });
@@ -0,0 +1,21 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import Modal, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
4
+ import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../constants';
5
+ import { ErrorBoundaryUI } from '../error-boundary-ui';
6
+
7
+ /**
8
+ * ErrorBoundaryModal props are the same as those passed to LinkCreate, which
9
+ * are used to control its active state
10
+ */
11
+
12
+ export var ErrorBoundaryModal = function ErrorBoundaryModal(_ref) {
13
+ var active = _ref.active,
14
+ onClose = _ref.onClose;
15
+ return jsx(ModalTransition, null, active && jsx(Modal, {
16
+ testId: "link-create-error-boundary-modal",
17
+ onClose: onClose,
18
+ shouldScrollInViewport: true,
19
+ width: "".concat(CREATE_FORM_MAX_WIDTH_IN_PX, "px")
20
+ }, jsx(ModalBody, null, jsx(ErrorBoundaryUI, null))));
21
+ };
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  *
5
5
  * Generates Typescript types for analytics events from analytics.spec.yaml
6
6
  *
7
- * @codegen <<SignedSource::afcb2b69ebf56a35a2926fa7fdfd1118>>
7
+ * @codegen <<SignedSource::af0139619517f37a8bca32ddb6b7d6e0>>
8
8
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
9
9
  */
10
10
 
@@ -0,0 +1,13 @@
1
+ import { useEffect } from 'react';
2
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
+ import { ANALYTICS_CHANNEL } from '../../../common/constants';
4
+ import createEventPayload from './analytics.codegen';
5
+ export var ScreenViewedEvent = function ScreenViewedEvent(_ref) {
6
+ var screen = _ref.screen;
7
+ var _useAnalyticsEvents = useAnalyticsEvents(),
8
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
9
+ useEffect(function () {
10
+ createAnalyticsEvent(createEventPayload("screen.".concat(screen, ".viewed"), {})).fire(ANALYTICS_CHANNEL);
11
+ }, [createAnalyticsEvent, screen]);
12
+ return null;
13
+ };
@@ -1,12 +1,17 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { createContext, useContext, useMemo, useState } from 'react';
2
+ import React, { createContext, useContext, useMemo, useRef, useState } from 'react';
3
3
  var EditPostCreateModalContext = /*#__PURE__*/createContext({
4
4
  editViewPayload: undefined,
5
- setEditViewPayload: function setEditViewPayload() {}
5
+ setEditViewPayload: function setEditViewPayload() {},
6
+ enableEditView: function enableEditView() {},
7
+ shouldActivateEditView: function shouldActivateEditView() {
8
+ return false;
9
+ }
6
10
  });
7
11
  export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_ref) {
8
12
  var active = _ref.active,
9
13
  children = _ref.children;
14
+ var _shouldActivateEditView = useRef(false);
10
15
  var _useState = useState(undefined),
11
16
  _useState2 = _slicedToArray(_useState, 2),
12
17
  editViewPayload = _useState2[0],
@@ -14,7 +19,13 @@ export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_r
14
19
  var value = useMemo(function () {
15
20
  return {
16
21
  editViewPayload: editViewPayload,
17
- setEditViewPayload: setEditViewPayload
22
+ setEditViewPayload: setEditViewPayload,
23
+ enableEditView: function enableEditView(enable) {
24
+ _shouldActivateEditView.current = enable;
25
+ },
26
+ shouldActivateEditView: function shouldActivateEditView() {
27
+ return _shouldActivateEditView.current;
28
+ }
18
29
  };
19
30
  }, [editViewPayload, setEditViewPayload]);
20
31
  if (editViewPayload && !active) {
@@ -22,7 +33,7 @@ export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_r
22
33
  }
23
34
  return /*#__PURE__*/React.createElement(EditPostCreateModalContext.Provider, {
24
35
  value: value
25
- }, children);
36
+ }, typeof children === 'function' ? children(value) : children);
26
37
  };
27
38
  export var useEditPostCreateModal = function useEditPostCreateModal() {
28
39
  var value = useContext(EditPostCreateModalContext);
@@ -18,7 +18,7 @@ export var LinkCreatePluginsProvider = function LinkCreatePluginsProvider(_ref)
18
18
  }, [entityKey, plugins]);
19
19
  return /*#__PURE__*/React.createElement(LinkCreatePluginsContext.Provider, {
20
20
  value: value
21
- }, children);
21
+ }, typeof children === 'function' ? children(value) : children);
22
22
  };
23
23
  export var useLinkCreatePlugins = function useLinkCreatePlugins() {
24
24
  var value = useContext(LinkCreatePluginsContext);
@@ -1,14 +1,18 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  var _excluded = ["submitting"];
4
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
8
  /** @jsx jsx */
6
9
  import { useCallback } from 'react';
7
10
  import { css, jsx } from '@emotion/react';
8
11
  import { Form, FormSpy } from 'react-final-form';
9
12
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
14
  import { Box } from '@atlaskit/primitives';
11
- import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
15
+ import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
12
16
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
13
17
  import { useFormContext } from '../../controllers/form-context';
14
18
  import { CreateFormFooter } from './form-footer';
@@ -19,6 +23,7 @@ var formStyles = css({
19
23
  padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
20
24
  margin: "var(--ds-space-0, 0px)".concat(" auto")
21
25
  });
26
+ var RESERVED_FIELDS = [LINK_CREATE_FORM_POST_CREATE_FIELD];
22
27
  export var TEST_ID = 'link-create-form';
23
28
  export var CreateForm = function CreateForm(_ref) {
24
29
  var children = _ref.children,
@@ -34,10 +39,11 @@ export var CreateForm = function CreateForm(_ref) {
34
39
  var _useFormContext = useFormContext(),
35
40
  getValidators = _useFormContext.getValidators,
36
41
  formErrorMessage = _useFormContext.formErrorMessage,
37
- setFormDirty = _useFormContext.setFormDirty;
42
+ setFormDirty = _useFormContext.setFormDirty,
43
+ enableEditView = _useFormContext.enableEditView;
38
44
  var handleSubmit = useCallback( /*#__PURE__*/function () {
39
45
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
40
- var validators, errors;
46
+ var validators, errors, shouldEnableEditView, formData;
41
47
  return _regeneratorRuntime.wrap(function _callee$(_context) {
42
48
  while (1) switch (_context.prev = _context.next) {
43
49
  case 0:
@@ -53,8 +59,21 @@ export var CreateForm = function CreateForm(_ref) {
53
59
  }
54
60
  return _context.abrupt("return", errors);
55
61
  case 5:
62
+ if (!getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
63
+ _context.next = 9;
64
+ break;
65
+ }
66
+ shouldEnableEditView = data[LINK_CREATE_FORM_POST_CREATE_FIELD], formData = _objectWithoutProperties(data, [LINK_CREATE_FORM_POST_CREATE_FIELD].map(_toPropertyKey));
67
+ /**
68
+ * If form has post-create field set to trigger post-create edit
69
+ * send this to the form context so we know what to do next
70
+ * if submission is successful
71
+ */
72
+ enableEditView === null || enableEditView === void 0 || enableEditView(!!shouldEnableEditView);
73
+ return _context.abrupt("return", onSubmit(formData));
74
+ case 9:
56
75
  return _context.abrupt("return", onSubmit(data));
57
- case 6:
76
+ case 10:
58
77
  case "end":
59
78
  return _context.stop();
60
79
  }
@@ -63,7 +82,7 @@ export var CreateForm = function CreateForm(_ref) {
63
82
  return function (_x) {
64
83
  return _ref2.apply(this, arguments);
65
84
  };
66
- }(), [createAnalyticsEvent, getValidators, onSubmit]);
85
+ }(), [createAnalyticsEvent, getValidators, onSubmit, enableEditView]);
67
86
  var handleCancel = useCallback(function () {
68
87
  createAnalyticsEvent(createEventPayload('ui.button.clicked.cancel', {})).fire(ANALYTICS_CHANNEL);
69
88
  onCancel && onCancel();
@@ -1,22 +1,35 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
- import Button from '@atlaskit/button';
3
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
4
4
  import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
5
+ import { Button } from '../../../common/ui/Button';
6
+ import { ScreenViewedEvent } from '../../../common/utils/analytics/components';
5
7
  import messages from './messages';
8
+ var screen = 'linkCreateExitWarningScreen';
9
+ var context = {
10
+ component: screen,
11
+ source: screen
12
+ };
6
13
  export var ConfirmDismissDialog = function ConfirmDismissDialog(_ref) {
7
14
  var active = _ref.active,
8
15
  onCancelDismiss = _ref.onCancelDismiss,
9
16
  onConfirmDismiss = _ref.onConfirmDismiss;
10
17
  var intl = useIntl();
11
- return /*#__PURE__*/React.createElement(ModalTransition, null, active && /*#__PURE__*/React.createElement(Modal, {
18
+ return /*#__PURE__*/React.createElement(ModalTransition, null, active && /*#__PURE__*/React.createElement(AnalyticsContext, {
19
+ data: context
20
+ }, /*#__PURE__*/React.createElement(Modal, {
12
21
  testId: "link-create-confirm-dismiss-dialog",
13
22
  onClose: onCancelDismiss,
14
23
  width: "small"
15
- }, /*#__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, {
24
+ }, /*#__PURE__*/React.createElement(ScreenViewedEvent, {
25
+ screen: "linkCreateExitWarningScreen"
26
+ }), /*#__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, {
27
+ actionSubjectId: "cancel",
16
28
  appearance: "subtle",
17
29
  onClick: onCancelDismiss
18
30
  }, intl.formatMessage(messages.cancelButtonLabel)), /*#__PURE__*/React.createElement(Button, {
31
+ actionSubjectId: "confirm",
19
32
  appearance: "primary",
20
33
  onClick: onConfirmDismiss
21
- }, intl.formatMessage(messages.confirmButtonLabel)))));
34
+ }, intl.formatMessage(messages.confirmButtonLabel))))));
22
35
  };
@@ -1,15 +1,24 @@
1
1
  import React from 'react';
2
2
  import Modal, { ModalTransition } from '@atlaskit/modal-dialog';
3
3
  import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
4
+ import { useLinkCreatePlugins } from '../../../controllers/plugin-context';
4
5
  export var EditModal = function EditModal(_ref) {
5
- var onClose = _ref.onClose;
6
+ var _activePlugin$editVie;
7
+ var onClose = _ref.onClose,
8
+ onCloseComplete = _ref.onCloseComplete;
6
9
  var _useEditPostCreateMod = useEditPostCreateModal(),
7
10
  editViewPayload = _useEditPostCreateMod.editViewPayload;
11
+ var _useLinkCreatePlugins = useLinkCreatePlugins(),
12
+ activePlugin = _useLinkCreatePlugins.activePlugin;
8
13
  return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(Modal, {
9
14
  testId: "link-create-edit-modal",
10
15
  onClose: onClose,
11
16
  shouldScrollInViewport: true,
12
17
  width: "calc(100vw - 120px)",
13
- height: "calc(100vh - 120px)"
14
- }));
18
+ height: "calc(100vh - 120px)",
19
+ onCloseComplete: onCloseComplete
20
+ }, activePlugin === null || activePlugin === void 0 || (_activePlugin$editVie = activePlugin.editView) === null || _activePlugin$editVie === void 0 ? void 0 : _activePlugin$editVie.call(activePlugin, {
21
+ payload: editViewPayload,
22
+ onClose: onClose
23
+ })));
15
24
  };
@@ -5,7 +5,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
- import React, { Component } from 'react';
8
+ import { Component } from 'react';
9
9
  // eslint-disable-next-line @repo/internal/react/no-class-components
10
10
  export var BaseErrorBoundary = /*#__PURE__*/function (_Component) {
11
11
  _inherits(BaseErrorBoundary, _Component);
@@ -33,10 +33,10 @@ export var BaseErrorBoundary = /*#__PURE__*/function (_Component) {
33
33
  value: function render() {
34
34
  var _this$props = this.props,
35
35
  children = _this$props.children,
36
- ErrorComponent = _this$props.ErrorComponent;
36
+ errorComponent = _this$props.errorComponent;
37
37
  var hasError = this.state.hasError;
38
- if (hasError && ErrorComponent) {
39
- return /*#__PURE__*/React.createElement(ErrorComponent, null);
38
+ if (hasError && errorComponent) {
39
+ return errorComponent;
40
40
  }
41
41
  return children;
42
42
  }
@@ -1,11 +1,12 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../../common/constants';
4
+ import { ErrorBoundaryUI } from '../../../common/ui/error-boundary-ui';
4
5
  import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
5
6
  import { BaseErrorBoundary } from './error-boundary-base';
6
- import { ErrorBoundaryUI } from './error-boundary-ui';
7
7
  export var ErrorBoundary = function ErrorBoundary(_ref) {
8
- var children = _ref.children;
8
+ var children = _ref.children,
9
+ errorComponent = _ref.errorComponent;
9
10
  var _useAnalyticsEvents = useAnalyticsEvents(),
10
11
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
11
12
  var handleError = useCallback(function (error, info) {
@@ -22,6 +23,6 @@ export var ErrorBoundary = function ErrorBoundary(_ref) {
22
23
  }, [createAnalyticsEvent]);
23
24
  return /*#__PURE__*/React.createElement(BaseErrorBoundary, {
24
25
  onError: handleError,
25
- ErrorComponent: ErrorBoundaryUI
26
+ errorComponent: errorComponent !== null && errorComponent !== void 0 ? errorComponent : /*#__PURE__*/React.createElement(ErrorBoundaryUI, null)
26
27
  }, children);
27
28
  };