@atlaskit/link-create 1.4.0 → 1.5.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 +14 -0
- package/analytics.spec.yaml +14 -0
- package/dist/cjs/common/ui/Button/index.js +37 -0
- package/dist/cjs/common/ui/error-boundary-modal/index.js +30 -0
- package/dist/cjs/common/utils/analytics/analytics.codegen.js +1 -1
- package/dist/cjs/common/utils/analytics/components.js +20 -0
- package/dist/cjs/controllers/edit-post-create-context/index.js +43 -0
- package/dist/cjs/controllers/plugin-context/index.js +39 -0
- package/dist/cjs/ui/link-create/confirm-dismiss-dialog/main.js +18 -5
- package/dist/cjs/ui/link-create/edit-modal/index.js +25 -0
- package/dist/cjs/ui/link-create/error-boundary/error-boundary-base/index.js +4 -7
- package/dist/cjs/ui/link-create/error-boundary/index.js +4 -3
- package/dist/cjs/ui/link-create/main.js +17 -2
- package/dist/cjs/ui/main.js +12 -1
- package/dist/es2019/common/ui/Button/index.js +27 -0
- package/dist/es2019/common/ui/error-boundary-modal/index.js +22 -0
- package/dist/es2019/common/utils/analytics/analytics.codegen.js +1 -1
- package/dist/es2019/common/utils/analytics/components.js +15 -0
- package/dist/es2019/controllers/edit-post-create-context/index.js +28 -0
- package/dist/es2019/controllers/plugin-context/index.js +25 -0
- package/dist/es2019/ui/link-create/confirm-dismiss-dialog/main.js +17 -4
- package/dist/es2019/ui/link-create/edit-modal/index.js +17 -0
- package/dist/es2019/ui/link-create/error-boundary/error-boundary-base/index.js +4 -4
- package/dist/es2019/ui/link-create/error-boundary/index.js +4 -3
- package/dist/es2019/ui/link-create/main.js +17 -2
- package/dist/es2019/ui/main.js +12 -1
- package/dist/esm/common/ui/Button/index.js +27 -0
- package/dist/esm/common/ui/error-boundary-modal/index.js +21 -0
- package/dist/esm/common/utils/analytics/analytics.codegen.js +1 -1
- package/dist/esm/common/utils/analytics/components.js +13 -0
- package/dist/esm/controllers/edit-post-create-context/index.js +33 -0
- package/dist/esm/controllers/plugin-context/index.js +29 -0
- package/dist/esm/ui/link-create/confirm-dismiss-dialog/main.js +17 -4
- package/dist/esm/ui/link-create/edit-modal/index.js +15 -0
- package/dist/esm/ui/link-create/error-boundary/error-boundary-base/index.js +4 -4
- package/dist/esm/ui/link-create/error-boundary/index.js +4 -3
- package/dist/esm/ui/link-create/main.js +17 -2
- package/dist/esm/ui/main.js +12 -1
- package/dist/types/common/ui/Button/index.d.ts +5 -0
- package/dist/types/common/ui/error-boundary-modal/index.d.ts +11 -0
- package/dist/types/common/utils/analytics/analytics.codegen.d.ts +6 -2
- package/dist/types/common/utils/analytics/components.d.ts +8 -0
- package/dist/types/controllers/edit-post-create-context/index.d.ts +12 -0
- package/dist/types/controllers/plugin-context/index.d.ts +18 -0
- package/dist/types/ui/link-create/edit-modal/index.d.ts +4 -0
- package/dist/types/ui/link-create/error-boundary/error-boundary-base/index.d.ts +3 -3
- package/dist/types/ui/link-create/error-boundary/index.d.ts +5 -1
- package/dist/types-ts4.5/common/ui/Button/index.d.ts +5 -0
- package/dist/types-ts4.5/common/ui/error-boundary-modal/index.d.ts +11 -0
- package/dist/types-ts4.5/common/utils/analytics/analytics.codegen.d.ts +6 -2
- package/dist/types-ts4.5/common/utils/analytics/components.d.ts +8 -0
- package/dist/types-ts4.5/controllers/edit-post-create-context/index.d.ts +12 -0
- package/dist/types-ts4.5/controllers/plugin-context/index.d.ts +18 -0
- package/dist/types-ts4.5/ui/link-create/edit-modal/index.d.ts +4 -0
- package/dist/types-ts4.5/ui/link-create/error-boundary/error-boundary-base/index.d.ts +3 -3
- package/dist/types-ts4.5/ui/link-create/error-boundary/index.d.ts +5 -1
- package/package.json +6 -3
- /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
- /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
- /package/dist/cjs/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
- /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
- /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
- /package/dist/es2019/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
- /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.js +0 -0
- /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.js +0 -0
- /package/dist/esm/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.js +0 -0
- /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.d.ts +0 -0
- /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.d.ts +0 -0
- /package/dist/types/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/error-svg/index.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/index.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/link-create/error-boundary → common/ui}/error-boundary-ui/messages.d.ts +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Modal, { ModalTransition } from '@atlaskit/modal-dialog';
|
|
3
|
+
import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
|
|
4
|
+
export const EditModal = ({
|
|
5
|
+
onClose
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
editViewPayload
|
|
9
|
+
} = useEditPostCreateModal();
|
|
10
|
+
return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(Modal, {
|
|
11
|
+
testId: "link-create-edit-modal",
|
|
12
|
+
onClose: onClose,
|
|
13
|
+
shouldScrollInViewport: true,
|
|
14
|
+
width: "calc(100vw - 120px)",
|
|
15
|
+
height: "calc(100vh - 120px)"
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
22
|
+
errorComponent
|
|
23
23
|
} = this.props;
|
|
24
24
|
const {
|
|
25
25
|
hasError
|
|
26
26
|
} = this.state;
|
|
27
|
-
if (hasError &&
|
|
28
|
-
return
|
|
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
|
-
|
|
28
|
+
errorComponent: errorComponent !== null && errorComponent !== void 0 ? errorComponent : /*#__PURE__*/React.createElement(ErrorBoundaryUI, null)
|
|
28
29
|
}, children);
|
|
29
30
|
};
|
|
@@ -8,8 +8,11 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
8
8
|
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
|
+
import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
|
|
11
12
|
import { useFormContext, withLinkCreateFormContext } from '../../controllers/form-context';
|
|
13
|
+
import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
|
|
12
14
|
import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
|
|
15
|
+
import { EditModal } from './edit-modal';
|
|
13
16
|
import { ErrorBoundary } from './error-boundary';
|
|
14
17
|
import { messages } from './messages';
|
|
15
18
|
import TrackMount from './track-mount';
|
|
@@ -92,10 +95,22 @@ const LinkCreateWithModal = ({
|
|
|
92
95
|
width: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`
|
|
93
96
|
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(LinkCreate, _extends({}, createProps, {
|
|
94
97
|
onCancel: handleCancel
|
|
95
|
-
}))))), jsx(
|
|
98
|
+
}))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && jsx(EditModal, {
|
|
99
|
+
onClose: handleCancel
|
|
100
|
+
}), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
|
|
96
101
|
active: dismissDialog,
|
|
97
102
|
onCancelDismiss: handleCancelDismiss,
|
|
98
103
|
onConfirmDismiss: handleConfirmDismiss
|
|
99
104
|
}));
|
|
100
105
|
};
|
|
101
|
-
export default withLinkCreateFormContext(
|
|
106
|
+
export default withLinkCreateFormContext(props => {
|
|
107
|
+
if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
|
|
108
|
+
return jsx(LinkCreatePluginsProvider, {
|
|
109
|
+
plugins: props.plugins,
|
|
110
|
+
entityKey: props.entityKey
|
|
111
|
+
}, jsx(EditPostCreateModalProvider, {
|
|
112
|
+
active: !!props.active
|
|
113
|
+
}, jsx(LinkCreateWithModal, props)));
|
|
114
|
+
}
|
|
115
|
+
return jsx(LinkCreateWithModal, props);
|
|
116
|
+
});
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -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.
|
|
29
|
+
packageVersion: "1.5.1" || '',
|
|
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::
|
|
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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useContext, useMemo, useState } from 'react';
|
|
3
|
+
var EditPostCreateModalContext = /*#__PURE__*/createContext({
|
|
4
|
+
editViewPayload: undefined,
|
|
5
|
+
setEditViewPayload: function setEditViewPayload() {}
|
|
6
|
+
});
|
|
7
|
+
export var EditPostCreateModalProvider = function EditPostCreateModalProvider(_ref) {
|
|
8
|
+
var active = _ref.active,
|
|
9
|
+
children = _ref.children;
|
|
10
|
+
var _useState = useState(undefined),
|
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
12
|
+
editViewPayload = _useState2[0],
|
|
13
|
+
setEditViewPayload = _useState2[1];
|
|
14
|
+
var value = useMemo(function () {
|
|
15
|
+
return {
|
|
16
|
+
editViewPayload: editViewPayload,
|
|
17
|
+
setEditViewPayload: setEditViewPayload
|
|
18
|
+
};
|
|
19
|
+
}, [editViewPayload, setEditViewPayload]);
|
|
20
|
+
if (editViewPayload && !active) {
|
|
21
|
+
setEditViewPayload(undefined);
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/React.createElement(EditPostCreateModalContext.Provider, {
|
|
24
|
+
value: value
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
export var useEditPostCreateModal = function useEditPostCreateModal() {
|
|
28
|
+
var value = useContext(EditPostCreateModalContext);
|
|
29
|
+
if (!value) {
|
|
30
|
+
throw new Error('useEditPostCreateModal used outside of useEditPostCreateModalProvider');
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useContext, useMemo, useState } from 'react';
|
|
3
|
+
var LinkCreatePluginsContext = /*#__PURE__*/createContext(null);
|
|
4
|
+
export var LinkCreatePluginsProvider = function LinkCreatePluginsProvider(_ref) {
|
|
5
|
+
var plugins = _ref.plugins,
|
|
6
|
+
propEntityKey = _ref.entityKey,
|
|
7
|
+
children = _ref.children;
|
|
8
|
+
var _useState = useState(propEntityKey),
|
|
9
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
10
|
+
entityKey = _useState2[0];
|
|
11
|
+
var value = useMemo(function () {
|
|
12
|
+
var _plugins$find;
|
|
13
|
+
return {
|
|
14
|
+
activePlugin: (_plugins$find = plugins.find(function (plugin) {
|
|
15
|
+
return plugin.key === entityKey;
|
|
16
|
+
})) !== null && _plugins$find !== void 0 ? _plugins$find : null
|
|
17
|
+
};
|
|
18
|
+
}, [entityKey, plugins]);
|
|
19
|
+
return /*#__PURE__*/React.createElement(LinkCreatePluginsContext.Provider, {
|
|
20
|
+
value: value
|
|
21
|
+
}, children);
|
|
22
|
+
};
|
|
23
|
+
export var useLinkCreatePlugins = function useLinkCreatePlugins() {
|
|
24
|
+
var value = useContext(LinkCreatePluginsContext);
|
|
25
|
+
if (!value) {
|
|
26
|
+
throw new Error('useLinkCreatePlugins used outside of LinkCreatePluginsProvider');
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
|
-
import
|
|
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(
|
|
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(
|
|
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
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Modal, { ModalTransition } from '@atlaskit/modal-dialog';
|
|
3
|
+
import { useEditPostCreateModal } from '../../../controllers/edit-post-create-context';
|
|
4
|
+
export var EditModal = function EditModal(_ref) {
|
|
5
|
+
var onClose = _ref.onClose;
|
|
6
|
+
var _useEditPostCreateMod = useEditPostCreateModal(),
|
|
7
|
+
editViewPayload = _useEditPostCreateMod.editViewPayload;
|
|
8
|
+
return /*#__PURE__*/React.createElement(ModalTransition, null, !!editViewPayload && /*#__PURE__*/React.createElement(Modal, {
|
|
9
|
+
testId: "link-create-edit-modal",
|
|
10
|
+
onClose: onClose,
|
|
11
|
+
shouldScrollInViewport: true,
|
|
12
|
+
width: "calc(100vw - 120px)",
|
|
13
|
+
height: "calc(100vh - 120px)"
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
@@ -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
|
|
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
|
-
|
|
36
|
+
errorComponent = _this$props.errorComponent;
|
|
37
37
|
var hasError = this.state.hasError;
|
|
38
|
-
if (hasError &&
|
|
39
|
-
return
|
|
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
|
-
|
|
26
|
+
errorComponent: errorComponent !== null && errorComponent !== void 0 ? errorComponent : /*#__PURE__*/React.createElement(ErrorBoundaryUI, null)
|
|
26
27
|
}, children);
|
|
27
28
|
};
|
|
@@ -14,8 +14,11 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
14
14
|
import { Box } from '@atlaskit/primitives';
|
|
15
15
|
import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
|
|
16
16
|
import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
|
|
17
|
+
import { EditPostCreateModalProvider } from '../../controllers/edit-post-create-context';
|
|
17
18
|
import { useFormContext, withLinkCreateFormContext } from '../../controllers/form-context';
|
|
19
|
+
import { LinkCreatePluginsProvider } from '../../controllers/plugin-context';
|
|
18
20
|
import { ConfirmDismissDialog } from './confirm-dismiss-dialog';
|
|
21
|
+
import { EditModal } from './edit-modal';
|
|
19
22
|
import { ErrorBoundary } from './error-boundary';
|
|
20
23
|
import { messages } from './messages';
|
|
21
24
|
import TrackMount from './track-mount';
|
|
@@ -115,10 +118,22 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
|
|
|
115
118
|
width: "".concat(CREATE_FORM_MAX_WIDTH_IN_PX, "px")
|
|
116
119
|
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(LinkCreate, _extends({}, createProps, {
|
|
117
120
|
onCancel: handleCancel
|
|
118
|
-
}))))), jsx(
|
|
121
|
+
}))))), getBooleanFF('platform.linking-platform.link-create.enable-edit') && jsx(EditModal, {
|
|
122
|
+
onClose: handleCancel
|
|
123
|
+
}), getBooleanFF('platform.linking-platform.link-create.confirm-dismiss-dialog') && jsx(ConfirmDismissDialog, {
|
|
119
124
|
active: dismissDialog,
|
|
120
125
|
onCancelDismiss: handleCancelDismiss,
|
|
121
126
|
onConfirmDismiss: handleConfirmDismiss
|
|
122
127
|
}));
|
|
123
128
|
};
|
|
124
|
-
export default withLinkCreateFormContext(
|
|
129
|
+
export default withLinkCreateFormContext(function (props) {
|
|
130
|
+
if (getBooleanFF('platform.linking-platform.link-create.enable-edit')) {
|
|
131
|
+
return jsx(LinkCreatePluginsProvider, {
|
|
132
|
+
plugins: props.plugins,
|
|
133
|
+
entityKey: props.entityKey
|
|
134
|
+
}, jsx(EditPostCreateModalProvider, {
|
|
135
|
+
active: !!props.active
|
|
136
|
+
}, jsx(LinkCreateWithModal, props)));
|
|
137
|
+
}
|
|
138
|
+
return jsx(LinkCreateWithModal, props);
|
|
139
|
+
});
|
package/dist/esm/ui/main.js
CHANGED
|
@@ -5,18 +5,29 @@ import { memo } from 'react';
|
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
7
7
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { COMPONENT_NAME } from '../common/constants';
|
|
10
|
+
import { ErrorBoundaryModal } from '../common/ui/error-boundary-modal';
|
|
9
11
|
import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
|
|
10
12
|
import { fetchMessagesForLocale } from '../common/utils/locale/fetch-messages-for-locale';
|
|
11
13
|
import i18nEN from '../i18n/en';
|
|
12
14
|
import LinkCreate from './link-create';
|
|
15
|
+
import { ErrorBoundary } from './link-create/error-boundary';
|
|
13
16
|
var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(function (_ref) {
|
|
14
17
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
18
|
+
if (getBooleanFF('platform.linking-platform.link-create.outer-error-boundary')) {
|
|
19
|
+
return jsx(ErrorBoundary, {
|
|
20
|
+
errorComponent: jsx(ErrorBoundaryModal, {
|
|
21
|
+
active: props.active,
|
|
22
|
+
onClose: props.onCancel
|
|
23
|
+
})
|
|
24
|
+
}, jsx(LinkCreate, props));
|
|
25
|
+
}
|
|
15
26
|
return jsx(LinkCreate, props);
|
|
16
27
|
}));
|
|
17
28
|
export var PACKAGE_DATA = {
|
|
18
29
|
packageName: "@atlaskit/link-create" || '',
|
|
19
|
-
packageVersion: "1.
|
|
30
|
+
packageVersion: "1.5.1" || '',
|
|
20
31
|
componentName: COMPONENT_NAME,
|
|
21
32
|
source: COMPONENT_NAME
|
|
22
33
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnalyticsEventAttributes } from '../../../common/utils/analytics/analytics.codegen';
|
|
3
|
+
export declare const Button: React.ForwardRefExoticComponent<Pick<import("@atlaskit/button").ButtonProps & React.RefAttributes<HTMLElement> & {
|
|
4
|
+
actionSubjectId: "create" | "cancel" | "confirm";
|
|
5
|
+
}, "key" | keyof import("@atlaskit/button").ButtonProps | "actionSubjectId"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* ErrorBoundaryModal props are the same as those passed to LinkCreate, which
|
|
4
|
+
* are used to control its active state
|
|
5
|
+
*/
|
|
6
|
+
type ErrorBoundaryModalProps = {
|
|
7
|
+
active?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const ErrorBoundaryModal: React.FC<ErrorBoundaryModalProps>;
|
|
11
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates Typescript types for analytics events from analytics.spec.yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::af0139619517f37a8bca32ddb6b7d6e0>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
export type PackageMetaDataType = {
|
|
@@ -18,8 +18,10 @@ export type LinkCreateAnalyticsContextType = {
|
|
|
18
18
|
appearance: 'modal' | 'popup';
|
|
19
19
|
};
|
|
20
20
|
export type LinkCreateScreenViewedAttributesType = {};
|
|
21
|
+
export type LinkCreateExitWarningScreenViewedAttributesType = {};
|
|
21
22
|
export type ButtonClickedCreateAttributesType = {};
|
|
22
23
|
export type ButtonClickedCancelAttributesType = {};
|
|
24
|
+
export type ButtonClickedConfirmAttributesType = {};
|
|
23
25
|
export type ModalDialogClosedLinkCreateAttributesType = {};
|
|
24
26
|
export type LinkCreateUnhandledErrorCaughtAttributesType = {
|
|
25
27
|
browserInfo: string;
|
|
@@ -33,10 +35,12 @@ export type ObjectCreatedLinkCreateAttributesType = {
|
|
|
33
35
|
export type ObjectCreateFailedLinkCreateAttributesType = {
|
|
34
36
|
failureType: string;
|
|
35
37
|
};
|
|
36
|
-
type AnalyticsEventAttributes = {
|
|
38
|
+
export type AnalyticsEventAttributes = {
|
|
37
39
|
'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
|
|
40
|
+
'screen.linkCreateExitWarningScreen.viewed': LinkCreateExitWarningScreenViewedAttributesType;
|
|
38
41
|
'ui.button.clicked.create': ButtonClickedCreateAttributesType;
|
|
39
42
|
'ui.button.clicked.cancel': ButtonClickedCancelAttributesType;
|
|
43
|
+
'ui.button.clicked.confirm': ButtonClickedConfirmAttributesType;
|
|
40
44
|
'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
|
|
41
45
|
'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
|
|
42
46
|
'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnalyticsEventAttributes } from './analytics.codegen';
|
|
2
|
+
type ScreenViewedEventProps = {
|
|
3
|
+
screen: keyof {
|
|
4
|
+
[Key in keyof AnalyticsEventAttributes as Key extends `screen.${infer ScreenName}.viewed` ? ScreenName : never]: any;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const ScreenViewedEvent: ({ screen }: ScreenViewedEventProps) => null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CreatePayload } from '../../common/types';
|
|
3
|
+
type EditPostCreateModalContextValue = {
|
|
4
|
+
editViewPayload?: CreatePayload | undefined;
|
|
5
|
+
setEditViewPayload: (payload?: CreatePayload) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const EditPostCreateModalProvider: ({ active, children, }: {
|
|
8
|
+
active: boolean;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}) => JSX.Element;
|
|
11
|
+
export declare const useEditPostCreateModal: () => EditPostCreateModalContextValue;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LinkCreatePlugin } from '../../common/types';
|
|
3
|
+
type LinkCreatePluginsProviderProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The list of plugins provided as a prop to Link Create component
|
|
6
|
+
*/
|
|
7
|
+
plugins: LinkCreatePlugin[];
|
|
8
|
+
/**
|
|
9
|
+
* The entity key as provided as prop to link create which controls the initially active plugin
|
|
10
|
+
*/
|
|
11
|
+
entityKey: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare const LinkCreatePluginsProvider: ({ plugins, entityKey: propEntityKey, children, }: LinkCreatePluginsProviderProps) => JSX.Element;
|
|
15
|
+
export declare const useLinkCreatePlugins: () => {
|
|
16
|
+
activePlugin: LinkCreatePlugin | null;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
|
2
2
|
export type ErrorBoundaryErrorInfo = {
|
|
3
3
|
componentStack: string;
|
|
4
4
|
};
|
|
@@ -7,12 +7,12 @@ type BaseErrorBoundaryState = {
|
|
|
7
7
|
};
|
|
8
8
|
interface BaseErrorBoundaryProps {
|
|
9
9
|
children: ReactNode;
|
|
10
|
-
|
|
10
|
+
errorComponent?: JSX.Element;
|
|
11
11
|
onError?: (error: Error, info?: ErrorBoundaryErrorInfo) => void;
|
|
12
12
|
}
|
|
13
13
|
export declare class BaseErrorBoundary extends Component<BaseErrorBoundaryProps, BaseErrorBoundaryState> {
|
|
14
14
|
constructor(props: BaseErrorBoundaryProps);
|
|
15
15
|
componentDidCatch(error: Error, info?: ErrorBoundaryErrorInfo): void;
|
|
16
|
-
render():
|
|
16
|
+
render(): ReactNode;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnalyticsEventAttributes } from '../../../common/utils/analytics/analytics.codegen';
|
|
3
|
+
export declare const Button: React.ForwardRefExoticComponent<Pick<import("@atlaskit/button").ButtonProps & React.RefAttributes<HTMLElement> & {
|
|
4
|
+
actionSubjectId: "create" | "cancel" | "confirm";
|
|
5
|
+
}, "key" | keyof import("@atlaskit/button").ButtonProps | "actionSubjectId"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* ErrorBoundaryModal props are the same as those passed to LinkCreate, which
|
|
4
|
+
* are used to control its active state
|
|
5
|
+
*/
|
|
6
|
+
type ErrorBoundaryModalProps = {
|
|
7
|
+
active?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const ErrorBoundaryModal: React.FC<ErrorBoundaryModalProps>;
|
|
11
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates Typescript types for analytics events from analytics.spec.yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::af0139619517f37a8bca32ddb6b7d6e0>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
export type PackageMetaDataType = {
|
|
@@ -18,8 +18,10 @@ export type LinkCreateAnalyticsContextType = {
|
|
|
18
18
|
appearance: 'modal' | 'popup';
|
|
19
19
|
};
|
|
20
20
|
export type LinkCreateScreenViewedAttributesType = {};
|
|
21
|
+
export type LinkCreateExitWarningScreenViewedAttributesType = {};
|
|
21
22
|
export type ButtonClickedCreateAttributesType = {};
|
|
22
23
|
export type ButtonClickedCancelAttributesType = {};
|
|
24
|
+
export type ButtonClickedConfirmAttributesType = {};
|
|
23
25
|
export type ModalDialogClosedLinkCreateAttributesType = {};
|
|
24
26
|
export type LinkCreateUnhandledErrorCaughtAttributesType = {
|
|
25
27
|
browserInfo: string;
|
|
@@ -33,10 +35,12 @@ export type ObjectCreatedLinkCreateAttributesType = {
|
|
|
33
35
|
export type ObjectCreateFailedLinkCreateAttributesType = {
|
|
34
36
|
failureType: string;
|
|
35
37
|
};
|
|
36
|
-
type AnalyticsEventAttributes = {
|
|
38
|
+
export type AnalyticsEventAttributes = {
|
|
37
39
|
'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
|
|
40
|
+
'screen.linkCreateExitWarningScreen.viewed': LinkCreateExitWarningScreenViewedAttributesType;
|
|
38
41
|
'ui.button.clicked.create': ButtonClickedCreateAttributesType;
|
|
39
42
|
'ui.button.clicked.cancel': ButtonClickedCancelAttributesType;
|
|
43
|
+
'ui.button.clicked.confirm': ButtonClickedConfirmAttributesType;
|
|
40
44
|
'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
|
|
41
45
|
'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
|
|
42
46
|
'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
|