@atlaskit/link-create 0.9.0 → 0.10.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 (40) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/analytics.spec.yaml +9 -0
  3. package/dist/cjs/common/utils/analytics/analytics.codegen.js +1 -1
  4. package/dist/cjs/controllers/callback-context/main.js +22 -3
  5. package/dist/cjs/ui/create-form/form-footer/index.js +12 -0
  6. package/dist/cjs/ui/create-form/form-footer/main.js +48 -0
  7. package/dist/cjs/ui/create-form/main.js +8 -33
  8. package/dist/cjs/ui/link-create/main.js +3 -3
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/common/utils/analytics/analytics.codegen.js +1 -1
  11. package/dist/es2019/controllers/callback-context/main.js +6 -1
  12. package/dist/es2019/ui/create-form/form-footer/index.js +1 -0
  13. package/dist/es2019/ui/create-form/form-footer/main.js +38 -0
  14. package/dist/es2019/ui/create-form/main.js +8 -30
  15. package/dist/es2019/ui/link-create/main.js +3 -3
  16. package/dist/es2019/version.json +1 -1
  17. package/dist/esm/common/utils/analytics/analytics.codegen.js +1 -1
  18. package/dist/esm/controllers/callback-context/main.js +22 -3
  19. package/dist/esm/ui/create-form/form-footer/index.js +1 -0
  20. package/dist/esm/ui/create-form/form-footer/main.js +37 -0
  21. package/dist/esm/ui/create-form/main.js +8 -30
  22. package/dist/esm/ui/link-create/main.js +3 -3
  23. package/dist/esm/version.json +1 -1
  24. package/dist/types/common/utils/analytics/analytics.codegen.d.ts +5 -1
  25. package/dist/types/controllers/callback-context/main.d.ts +1 -1
  26. package/dist/types/ui/create-form/form-footer/index.d.ts +1 -0
  27. package/dist/types/ui/create-form/form-footer/main.d.ts +9 -0
  28. package/dist/types-ts4.5/common/utils/analytics/analytics.codegen.d.ts +5 -1
  29. package/dist/types-ts4.5/controllers/callback-context/main.d.ts +1 -1
  30. package/dist/types-ts4.5/ui/create-form/form-footer/index.d.ts +1 -0
  31. package/dist/types-ts4.5/ui/create-form/form-footer/main.d.ts +9 -0
  32. package/example-helpers/mock-plugin-form.tsx +4 -3
  33. package/package.json +9 -3
  34. package/report.api.md +1 -1
  35. package/tmp/api-report-tmp.d.ts +1 -1
  36. /package/dist/cjs/ui/create-form/{messages.js → form-footer/messages.js} +0 -0
  37. /package/dist/es2019/ui/create-form/{messages.js → form-footer/messages.js} +0 -0
  38. /package/dist/esm/ui/create-form/{messages.js → form-footer/messages.js} +0 -0
  39. /package/dist/types/ui/create-form/{messages.d.ts → form-footer/messages.d.ts} +0 -0
  40. /package/dist/types-ts4.5/ui/create-form/{messages.d.ts → form-footer/messages.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/link-create
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`dc546d1044a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dc546d1044a) - Update failure handler in link-create API to take Error instead of string, and fire analytics on failure
8
+
9
+ ## 0.9.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`84b33e5a4b6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/84b33e5a4b6) - EDM-6544: minor internal refactors with no expected functional change
14
+
3
15
  ## 0.9.0
4
16
 
5
17
  ### Minor Changes
@@ -83,3 +83,12 @@ events:
83
83
  objectType:
84
84
  type: string
85
85
  description: the type of created content
86
+
87
+ - object createFailed (linkCreate):
88
+ type: track
89
+ description: fired when the object creation fails
90
+ attributes:
91
+ <<: *PackageMetaDataContext
92
+ failureType:
93
+ type: string
94
+ description: the name of the failure
@@ -11,7 +11,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  *
12
12
  * Generates Typescript types for analytics events from analytics.spec.yaml
13
13
  *
14
- * @codegen <<SignedSource::6c4bc6f47b1cf9cb3a9a70cac9a93775>>
14
+ * @codegen <<SignedSource::50073590468fe2604f65d3e0b23d517b>>
15
15
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
16
16
  */
17
17
 
@@ -18,7 +18,7 @@ var LinkCreateCallbackContext = /*#__PURE__*/_react.default.createContext({});
18
18
  var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
19
19
  var children = _ref.children,
20
20
  _onCreate = _ref.onCreate,
21
- onFailure = _ref.onFailure,
21
+ _onFailure = _ref.onFailure,
22
22
  onCancel = _ref.onCancel;
23
23
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
24
24
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
@@ -52,10 +52,29 @@ var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
52
52
  }
53
53
  return onCreate;
54
54
  }(),
55
- onFailure: onFailure,
55
+ onFailure: function () {
56
+ var _onFailure2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(error) {
57
+ return _regenerator.default.wrap(function _callee2$(_context2) {
58
+ while (1) switch (_context2.prev = _context2.next) {
59
+ case 0:
60
+ createAnalyticsEvent((0, _analytics.default)('track.object.createFailed.linkCreate', {
61
+ failureType: error.name
62
+ })).fire(_constants.ANALYTICS_CHANNEL);
63
+ _onFailure && _onFailure(error);
64
+ case 2:
65
+ case "end":
66
+ return _context2.stop();
67
+ }
68
+ }, _callee2);
69
+ }));
70
+ function onFailure(_x2) {
71
+ return _onFailure2.apply(this, arguments);
72
+ }
73
+ return onFailure;
74
+ }(),
56
75
  onCancel: onCancel
57
76
  };
58
- }, [onFailure, onCancel, createAnalyticsEvent, _onCreate]);
77
+ }, [_onFailure, onCancel, createAnalyticsEvent, _onCreate]);
59
78
  return /*#__PURE__*/_react.default.createElement(LinkCreateCallbackContext.Provider, {
60
79
  value: value
61
80
  }, children);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CreateFormFooter", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _main.CreateFormFooter;
10
+ }
11
+ });
12
+ var _main = require("./main");
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CreateFormFooter = CreateFormFooter;
9
+ var _react = require("@emotion/react");
10
+ var _reactIntlNext = require("react-intl-next");
11
+ var _button = _interopRequireWildcard(require("@atlaskit/button"));
12
+ var _loadingButton = _interopRequireDefault(require("@atlaskit/button/loading-button"));
13
+ var _form = require("@atlaskit/form");
14
+ var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
15
+ var _messages = require("./messages");
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ /** @jsx jsx */
19
+
20
+ var errorStyles = (0, _react.css)({
21
+ display: 'flex',
22
+ alignItems: 'center',
23
+ marginRight: 'auto'
24
+ });
25
+ function CreateFormFooter(_ref) {
26
+ var formErrorMessage = _ref.formErrorMessage,
27
+ handleCancel = _ref.handleCancel,
28
+ submitting = _ref.submitting,
29
+ testId = _ref.testId;
30
+ var intl = (0, _reactIntlNext.useIntl)();
31
+ return (0, _react.jsx)(_form.FormFooter, null, formErrorMessage && (0, _react.jsx)("div", {
32
+ css: errorStyles,
33
+ "data-testid": "".concat(testId, "-error")
34
+ }, (0, _react.jsx)(_error.default, {
35
+ label: formErrorMessage,
36
+ primaryColor: "var(--ds-icon-danger, #E34935)"
37
+ }), formErrorMessage), (0, _react.jsx)(_button.ButtonGroup, null, (0, _react.jsx)(_button.default, {
38
+ type: "button",
39
+ appearance: "subtle",
40
+ onClick: handleCancel,
41
+ testId: "".concat(testId, "-button-cancel")
42
+ }, intl.formatMessage(_messages.messages.close)), (0, _react.jsx)(_loadingButton.default, {
43
+ type: "submit",
44
+ appearance: "primary",
45
+ isLoading: submitting,
46
+ testId: "".concat(testId, "-button-submit")
47
+ }, intl.formatMessage(_messages.messages.create))));
48
+ }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -11,21 +10,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
11
  var _react = require("react");
13
12
  var _react2 = require("@emotion/react");
14
- var _reactIntlNext = require("react-intl-next");
15
13
  var _analyticsNext = require("@atlaskit/analytics-next");
16
- var _button = require("@atlaskit/button");
17
- var _loadingButton = _interopRequireDefault(require("@atlaskit/button/loading-button"));
18
- var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
19
- var _form = _interopRequireWildcard(require("@atlaskit/form"));
20
- var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
14
+ var _form = _interopRequireDefault(require("@atlaskit/form"));
21
15
  var _constants = require("../../common/constants");
22
16
  var _analytics = _interopRequireDefault(require("../../common/utils/analytics/analytics.codegen"));
23
17
  var _formContext = require("../../controllers/form-context");
18
+ var _formFooter = require("./form-footer");
24
19
  var _formLoader = require("./form-loader");
25
- var _messages = require("./messages");
26
20
  var _utils = require("./utils");
27
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
21
  /** @jsx jsx */
30
22
 
31
23
  var formStyles = (0, _react2.css)({
@@ -33,11 +25,6 @@ var formStyles = (0, _react2.css)({
33
25
  padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
34
26
  margin: "var(--ds-space-0, 0px)".concat(" auto")
35
27
  });
36
- var errorStyles = (0, _react2.css)({
37
- display: 'flex',
38
- alignItems: 'center',
39
- marginRight: 'auto'
40
- });
41
28
  var TEST_ID = 'link-create-form';
42
29
  exports.TEST_ID = TEST_ID;
43
30
  var CreateForm = function CreateForm(_ref) {
@@ -48,7 +35,6 @@ var CreateForm = function CreateForm(_ref) {
48
35
  onCancel = _ref.onCancel,
49
36
  isLoading = _ref.isLoading,
50
37
  hideFooter = _ref.hideFooter;
51
- var intl = (0, _reactIntlNext.useIntl)();
52
38
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
53
39
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
54
40
  var _useFormContext = (0, _formContext.useFormContext)(),
@@ -99,23 +85,12 @@ var CreateForm = function CreateForm(_ref) {
99
85
  name: "link-create-form",
100
86
  "data-testid": testId,
101
87
  css: formStyles
102
- }), (0, _react2.jsx)("div", null, children), !hideFooter && (0, _react2.jsx)(_form.FormFooter, null, formErrorMessage && (0, _react2.jsx)("div", {
103
- css: errorStyles,
104
- "data-testid": "".concat(testId, "-error")
105
- }, (0, _react2.jsx)(_error.default, {
106
- label: formErrorMessage,
107
- primaryColor: "var(--ds-icon-danger, #E34935)"
108
- }), formErrorMessage), (0, _react2.jsx)(_button.ButtonGroup, null, (0, _react2.jsx)(_standardButton.default, {
109
- type: "button",
110
- appearance: "subtle",
111
- onClick: handleCancel,
112
- testId: "".concat(testId, "-button-cancel")
113
- }, intl.formatMessage(_messages.messages.close)), (0, _react2.jsx)(_loadingButton.default, {
114
- type: "submit",
115
- appearance: "primary",
116
- isLoading: submitting,
117
- testId: "".concat(testId, "-button-submit")
118
- }, intl.formatMessage(_messages.messages.create)))));
88
+ }), (0, _react2.jsx)("div", null, children), !hideFooter && (0, _react2.jsx)(_formFooter.CreateFormFooter, {
89
+ formErrorMessage: formErrorMessage,
90
+ handleCancel: handleCancel,
91
+ submitting: submitting,
92
+ testId: testId
93
+ }));
119
94
  });
120
95
  };
121
96
  exports.CreateForm = CreateForm;
@@ -69,10 +69,10 @@ var LinkCreate = (0, _formContext.withLinkCreateFormContext)(function (_ref2) {
69
69
  return _ref3.apply(this, arguments);
70
70
  };
71
71
  }(), [onCreate, setFormErrorMessage]);
72
- var handleFailure = (0, _react.useCallback)(function (errorMessage) {
72
+ var handleFailure = (0, _react.useCallback)(function (error) {
73
73
  // Set the form error message
74
- setFormErrorMessage(errorMessage);
75
- onFailure && onFailure(errorMessage);
74
+ setFormErrorMessage(error.message);
75
+ onFailure && onFailure(error);
76
76
  }, [onFailure, setFormErrorMessage]);
77
77
  return (0, _react2.jsx)("div", {
78
78
  "data-testid": testId
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::6c4bc6f47b1cf9cb3a9a70cac9a93775>>
6
+ * @codegen <<SignedSource::50073590468fe2604f65d3e0b23d517b>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
8
8
  */
9
9
 
@@ -26,7 +26,12 @@ const LinkCreateCallbackProvider = ({
26
26
  await onCreate(result);
27
27
  }
28
28
  },
29
- onFailure,
29
+ onFailure: async error => {
30
+ createAnalyticsEvent(createEventPayload('track.object.createFailed.linkCreate', {
31
+ failureType: error.name
32
+ })).fire(ANALYTICS_CHANNEL);
33
+ onFailure && onFailure(error);
34
+ },
30
35
  onCancel
31
36
  }), [onFailure, onCancel, createAnalyticsEvent, onCreate]);
32
37
  return /*#__PURE__*/React.createElement(LinkCreateCallbackContext.Provider, {
@@ -0,0 +1 @@
1
+ export { CreateFormFooter } from './main';
@@ -0,0 +1,38 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/react';
3
+ import { useIntl } from 'react-intl-next';
4
+ import Button, { ButtonGroup } from '@atlaskit/button';
5
+ import LoadingButton from '@atlaskit/button/loading-button';
6
+ import { FormFooter } from '@atlaskit/form';
7
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
8
+ import { messages } from './messages';
9
+ const errorStyles = css({
10
+ display: 'flex',
11
+ alignItems: 'center',
12
+ marginRight: 'auto'
13
+ });
14
+ export function CreateFormFooter({
15
+ formErrorMessage,
16
+ handleCancel,
17
+ submitting,
18
+ testId
19
+ }) {
20
+ const intl = useIntl();
21
+ return jsx(FormFooter, null, formErrorMessage && jsx("div", {
22
+ css: errorStyles,
23
+ "data-testid": `${testId}-error`
24
+ }, jsx(ErrorIcon, {
25
+ label: formErrorMessage,
26
+ primaryColor: "var(--ds-icon-danger, #E34935)"
27
+ }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
28
+ type: "button",
29
+ appearance: "subtle",
30
+ onClick: handleCancel,
31
+ testId: `${testId}-button-cancel`
32
+ }, intl.formatMessage(messages.close)), jsx(LoadingButton, {
33
+ type: "submit",
34
+ appearance: "primary",
35
+ isLoading: submitting,
36
+ testId: `${testId}-button-submit`
37
+ }, intl.formatMessage(messages.create))));
38
+ }
@@ -2,29 +2,19 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { useCallback } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { useIntl } from 'react-intl-next';
6
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { ButtonGroup } from '@atlaskit/button';
8
- import LoadingButton from '@atlaskit/button/loading-button';
9
- import Button from '@atlaskit/button/standard-button';
10
- import Form, { FormFooter } from '@atlaskit/form';
11
- import ErrorIcon from '@atlaskit/icon/glyph/error';
6
+ import Form from '@atlaskit/form';
12
7
  import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
13
8
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
14
9
  import { useFormContext } from '../../controllers/form-context';
10
+ import { CreateFormFooter } from './form-footer';
15
11
  import { CreateFormLoader } from './form-loader';
16
- import { messages } from './messages';
17
12
  import { validateFormData } from './utils';
18
13
  const formStyles = css({
19
14
  maxWidth: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`,
20
15
  padding: `0 0 ${"var(--ds-space-300, 24px)"} 0`,
21
16
  margin: `${"var(--ds-space-0, 0px)"} auto`
22
17
  });
23
- const errorStyles = css({
24
- display: 'flex',
25
- alignItems: 'center',
26
- marginRight: 'auto'
27
- });
28
18
  export const TEST_ID = 'link-create-form';
29
19
  export const CreateForm = ({
30
20
  children,
@@ -34,7 +24,6 @@ export const CreateForm = ({
34
24
  isLoading,
35
25
  hideFooter
36
26
  }) => {
37
- const intl = useIntl();
38
27
  const {
39
28
  createAnalyticsEvent
40
29
  } = useAnalyticsEvents();
@@ -70,21 +59,10 @@ export const CreateForm = ({
70
59
  name: "link-create-form",
71
60
  "data-testid": testId,
72
61
  css: formStyles
73
- }), jsx("div", null, children), !hideFooter && jsx(FormFooter, null, formErrorMessage && jsx("div", {
74
- css: errorStyles,
75
- "data-testid": `${testId}-error`
76
- }, jsx(ErrorIcon, {
77
- label: formErrorMessage,
78
- primaryColor: "var(--ds-icon-danger, #E34935)"
79
- }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
80
- type: "button",
81
- appearance: "subtle",
82
- onClick: handleCancel,
83
- testId: `${testId}-button-cancel`
84
- }, intl.formatMessage(messages.close)), jsx(LoadingButton, {
85
- type: "submit",
86
- appearance: "primary",
87
- isLoading: submitting,
88
- testId: `${testId}-button-submit`
89
- }, intl.formatMessage(messages.create))))));
62
+ }), jsx("div", null, children), !hideFooter && jsx(CreateFormFooter, {
63
+ formErrorMessage: formErrorMessage,
64
+ handleCancel: handleCancel,
65
+ submitting: submitting,
66
+ testId: testId
67
+ })));
90
68
  };
@@ -37,10 +37,10 @@ const LinkCreate = withLinkCreateFormContext(({
37
37
  await onCreate(result);
38
38
  }
39
39
  }, [onCreate, setFormErrorMessage]);
40
- const handleFailure = useCallback(errorMessage => {
40
+ const handleFailure = useCallback(error => {
41
41
  // Set the form error message
42
- setFormErrorMessage(errorMessage);
43
- onFailure && onFailure(errorMessage);
42
+ setFormErrorMessage(error.message);
43
+ onFailure && onFailure(error);
44
44
  }, [onFailure, setFormErrorMessage]);
45
45
  return jsx("div", {
46
46
  "data-testid": testId
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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::6c4bc6f47b1cf9cb3a9a70cac9a93775>>
7
+ * @codegen <<SignedSource::50073590468fe2604f65d3e0b23d517b>>
8
8
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
9
9
  */
10
10
 
@@ -8,7 +8,7 @@ var LinkCreateCallbackContext = /*#__PURE__*/React.createContext({});
8
8
  var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
9
9
  var children = _ref.children,
10
10
  _onCreate = _ref.onCreate,
11
- onFailure = _ref.onFailure,
11
+ _onFailure = _ref.onFailure,
12
12
  onCancel = _ref.onCancel;
13
13
  var _useAnalyticsEvents = useAnalyticsEvents(),
14
14
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
@@ -42,10 +42,29 @@ var LinkCreateCallbackProvider = function LinkCreateCallbackProvider(_ref) {
42
42
  }
43
43
  return onCreate;
44
44
  }(),
45
- onFailure: onFailure,
45
+ onFailure: function () {
46
+ var _onFailure2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(error) {
47
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
48
+ while (1) switch (_context2.prev = _context2.next) {
49
+ case 0:
50
+ createAnalyticsEvent(createEventPayload('track.object.createFailed.linkCreate', {
51
+ failureType: error.name
52
+ })).fire(ANALYTICS_CHANNEL);
53
+ _onFailure && _onFailure(error);
54
+ case 2:
55
+ case "end":
56
+ return _context2.stop();
57
+ }
58
+ }, _callee2);
59
+ }));
60
+ function onFailure(_x2) {
61
+ return _onFailure2.apply(this, arguments);
62
+ }
63
+ return onFailure;
64
+ }(),
46
65
  onCancel: onCancel
47
66
  };
48
- }, [onFailure, onCancel, createAnalyticsEvent, _onCreate]);
67
+ }, [_onFailure, onCancel, createAnalyticsEvent, _onCreate]);
49
68
  return /*#__PURE__*/React.createElement(LinkCreateCallbackContext.Provider, {
50
69
  value: value
51
70
  }, children);
@@ -0,0 +1 @@
1
+ export { CreateFormFooter } from './main';
@@ -0,0 +1,37 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/react';
3
+ import { useIntl } from 'react-intl-next';
4
+ import Button, { ButtonGroup } from '@atlaskit/button';
5
+ import LoadingButton from '@atlaskit/button/loading-button';
6
+ import { FormFooter } from '@atlaskit/form';
7
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
8
+ import { messages } from './messages';
9
+ var errorStyles = css({
10
+ display: 'flex',
11
+ alignItems: 'center',
12
+ marginRight: 'auto'
13
+ });
14
+ export function CreateFormFooter(_ref) {
15
+ var formErrorMessage = _ref.formErrorMessage,
16
+ handleCancel = _ref.handleCancel,
17
+ submitting = _ref.submitting,
18
+ testId = _ref.testId;
19
+ var intl = useIntl();
20
+ return jsx(FormFooter, null, formErrorMessage && jsx("div", {
21
+ css: errorStyles,
22
+ "data-testid": "".concat(testId, "-error")
23
+ }, jsx(ErrorIcon, {
24
+ label: formErrorMessage,
25
+ primaryColor: "var(--ds-icon-danger, #E34935)"
26
+ }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
27
+ type: "button",
28
+ appearance: "subtle",
29
+ onClick: handleCancel,
30
+ testId: "".concat(testId, "-button-cancel")
31
+ }, intl.formatMessage(messages.close)), jsx(LoadingButton, {
32
+ type: "submit",
33
+ appearance: "primary",
34
+ isLoading: submitting,
35
+ testId: "".concat(testId, "-button-submit")
36
+ }, intl.formatMessage(messages.create))));
37
+ }
@@ -4,29 +4,19 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  /** @jsx jsx */
5
5
  import { useCallback } from 'react';
6
6
  import { css, jsx } from '@emotion/react';
7
- import { useIntl } from 'react-intl-next';
8
7
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
9
- import { ButtonGroup } from '@atlaskit/button';
10
- import LoadingButton from '@atlaskit/button/loading-button';
11
- import Button from '@atlaskit/button/standard-button';
12
- import Form, { FormFooter } from '@atlaskit/form';
13
- import ErrorIcon from '@atlaskit/icon/glyph/error';
8
+ import Form from '@atlaskit/form';
14
9
  import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
15
10
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
16
11
  import { useFormContext } from '../../controllers/form-context';
12
+ import { CreateFormFooter } from './form-footer';
17
13
  import { CreateFormLoader } from './form-loader';
18
- import { messages } from './messages';
19
14
  import { validateFormData } from './utils';
20
15
  var formStyles = css({
21
16
  maxWidth: "".concat(CREATE_FORM_MAX_WIDTH_IN_PX, "px"),
22
17
  padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
23
18
  margin: "var(--ds-space-0, 0px)".concat(" auto")
24
19
  });
25
- var errorStyles = css({
26
- display: 'flex',
27
- alignItems: 'center',
28
- marginRight: 'auto'
29
- });
30
20
  export var TEST_ID = 'link-create-form';
31
21
  export var CreateForm = function CreateForm(_ref) {
32
22
  var children = _ref.children,
@@ -36,7 +26,6 @@ export var CreateForm = function CreateForm(_ref) {
36
26
  onCancel = _ref.onCancel,
37
27
  isLoading = _ref.isLoading,
38
28
  hideFooter = _ref.hideFooter;
39
- var intl = useIntl();
40
29
  var _useAnalyticsEvents = useAnalyticsEvents(),
41
30
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
42
31
  var _useFormContext = useFormContext(),
@@ -87,22 +76,11 @@ export var CreateForm = function CreateForm(_ref) {
87
76
  name: "link-create-form",
88
77
  "data-testid": testId,
89
78
  css: formStyles
90
- }), jsx("div", null, children), !hideFooter && jsx(FormFooter, null, formErrorMessage && jsx("div", {
91
- css: errorStyles,
92
- "data-testid": "".concat(testId, "-error")
93
- }, jsx(ErrorIcon, {
94
- label: formErrorMessage,
95
- primaryColor: "var(--ds-icon-danger, #E34935)"
96
- }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
97
- type: "button",
98
- appearance: "subtle",
99
- onClick: handleCancel,
100
- testId: "".concat(testId, "-button-cancel")
101
- }, intl.formatMessage(messages.close)), jsx(LoadingButton, {
102
- type: "submit",
103
- appearance: "primary",
104
- isLoading: submitting,
105
- testId: "".concat(testId, "-button-submit")
106
- }, intl.formatMessage(messages.create)))));
79
+ }), jsx("div", null, children), !hideFooter && jsx(CreateFormFooter, {
80
+ formErrorMessage: formErrorMessage,
81
+ handleCancel: handleCancel,
82
+ submitting: submitting,
83
+ testId: testId
84
+ }));
107
85
  });
108
86
  };
@@ -58,10 +58,10 @@ var LinkCreate = withLinkCreateFormContext(function (_ref2) {
58
58
  return _ref3.apply(this, arguments);
59
59
  };
60
60
  }(), [onCreate, setFormErrorMessage]);
61
- var handleFailure = useCallback(function (errorMessage) {
61
+ var handleFailure = useCallback(function (error) {
62
62
  // Set the form error message
63
- setFormErrorMessage(errorMessage);
64
- onFailure && onFailure(errorMessage);
63
+ setFormErrorMessage(error.message);
64
+ onFailure && onFailure(error);
65
65
  }, [onFailure, setFormErrorMessage]);
66
66
  return jsx("div", {
67
67
  "data-testid": testId
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::6c4bc6f47b1cf9cb3a9a70cac9a93775>>
6
+ * @codegen <<SignedSource::50073590468fe2604f65d3e0b23d517b>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -30,6 +30,9 @@ export type ObjectCreatedLinkCreateAttributesType = {
30
30
  objectId: string;
31
31
  objectType: string;
32
32
  };
33
+ export type ObjectCreateFailedLinkCreateAttributesType = {
34
+ failureType: string;
35
+ };
33
36
  type AnalyticsEventAttributes = {
34
37
  'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
35
38
  'ui.button.clicked.create': ButtonClickedCreateAttributesType;
@@ -37,6 +40,7 @@ type AnalyticsEventAttributes = {
37
40
  'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
38
41
  'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
39
42
  'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
43
+ 'track.object.createFailed.linkCreate': ObjectCreateFailedLinkCreateAttributesType;
40
44
  };
41
45
  declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
42
46
  eventType: string;
@@ -8,7 +8,7 @@ interface LinkCreateCallbackProviderProps {
8
8
  /**
9
9
  * This callback for any errors
10
10
  */
11
- onFailure?: (errorMessage: string) => void;
11
+ onFailure?: (error: Error) => void;
12
12
  /**
13
13
  * This callback for when the form was manually discarded by user
14
14
  */
@@ -0,0 +1 @@
1
+ export { CreateFormFooter } from './main';
@@ -0,0 +1,9 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ export interface CreateFormFooterProps {
4
+ formErrorMessage: string | undefined;
5
+ handleCancel: () => void;
6
+ submitting: boolean;
7
+ testId?: string;
8
+ }
9
+ export declare function CreateFormFooter({ formErrorMessage, handleCancel, submitting, testId, }: CreateFormFooterProps): jsx.JSX.Element;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::6c4bc6f47b1cf9cb3a9a70cac9a93775>>
6
+ * @codegen <<SignedSource::50073590468fe2604f65d3e0b23d517b>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -30,6 +30,9 @@ export type ObjectCreatedLinkCreateAttributesType = {
30
30
  objectId: string;
31
31
  objectType: string;
32
32
  };
33
+ export type ObjectCreateFailedLinkCreateAttributesType = {
34
+ failureType: string;
35
+ };
33
36
  type AnalyticsEventAttributes = {
34
37
  'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
35
38
  'ui.button.clicked.create': ButtonClickedCreateAttributesType;
@@ -37,6 +40,7 @@ type AnalyticsEventAttributes = {
37
40
  'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
38
41
  'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
39
42
  'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
43
+ 'track.object.createFailed.linkCreate': ObjectCreateFailedLinkCreateAttributesType;
40
44
  };
41
45
  declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
42
46
  eventType: string;
@@ -8,7 +8,7 @@ interface LinkCreateCallbackProviderProps {
8
8
  /**
9
9
  * This callback for any errors
10
10
  */
11
- onFailure?: (errorMessage: string) => void;
11
+ onFailure?: (error: Error) => void;
12
12
  /**
13
13
  * This callback for when the form was manually discarded by user
14
14
  */
@@ -0,0 +1 @@
1
+ export { CreateFormFooter } from './main';
@@ -0,0 +1,9 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ export interface CreateFormFooterProps {
4
+ formErrorMessage: string | undefined;
5
+ handleCancel: () => void;
6
+ submitting: boolean;
7
+ testId?: string;
8
+ }
9
+ export declare function CreateFormFooter({ formErrorMessage, handleCancel, submitting, testId, }: CreateFormFooterProps): jsx.JSX.Element;
@@ -1,5 +1,7 @@
1
1
  import React, { useMemo } from 'react';
2
2
 
3
+ import { OptionsType } from '@atlaskit/select';
4
+
3
5
  import {
4
6
  AsyncSelect,
5
7
  CreateForm,
@@ -7,8 +9,7 @@ import {
7
9
  TextField,
8
10
  useLinkCreateCallback,
9
11
  Validator,
10
- } from '@atlaskit/link-create';
11
- import { OptionsType } from '@atlaskit/select';
12
+ } from '../src';
12
13
 
13
14
  interface pluginProps {
14
15
  shouldThrowError?: boolean;
@@ -54,7 +55,7 @@ export function MockPluginForm({ shouldThrowError }: pluginProps) {
54
55
  return exampleOptions;
55
56
  } catch (error) {
56
57
  if (error instanceof Error) {
57
- onFailure && onFailure(error.message);
58
+ onFailure && onFailure(error);
58
59
  }
59
60
  return [];
60
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "The driver component of meta creation flow",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/select": "^16.5.0",
45
45
  "@atlaskit/spinner": "^15.4.0",
46
46
  "@atlaskit/textfield": "^5.6.0",
47
- "@atlaskit/tokens": "^1.12.0",
47
+ "@atlaskit/tokens": "^1.13.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "@emotion/react": "^11.7.1"
50
50
  },
@@ -53,7 +53,8 @@
53
53
  "react-intl-next": "npm:react-intl@^5.18.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@atlaskit/link-test-helpers": "^4.1.0",
56
+ "@af/visual-regression": "*",
57
+ "@atlaskit/link-test-helpers": "^4.2.0",
57
58
  "@atlaskit/visual-regression": "*",
58
59
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
59
60
  "@testing-library/react": "^12.1.5",
@@ -102,5 +103,10 @@
102
103
  ]
103
104
  }
104
105
  },
106
+ "techstackIgnore": {
107
+ "stricter": [
108
+ "@atlassian/tangerine/project-structure"
109
+ ]
110
+ },
105
111
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
106
112
  }
package/report.api.md CHANGED
@@ -108,7 +108,7 @@ export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderPr
108
108
  interface LinkCreateCallbackProviderProps {
109
109
  onCancel?: () => void;
110
110
  onCreate?: (result: CreatePayload) => Promise<void> | void;
111
- onFailure?: (errorMessage: string) => void;
111
+ onFailure?: (error: Error) => void;
112
112
  }
113
113
 
114
114
  // @public (undocumented)
@@ -77,7 +77,7 @@ export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderPr
77
77
  interface LinkCreateCallbackProviderProps {
78
78
  onCancel?: () => void;
79
79
  onCreate?: (result: CreatePayload) => Promise<void> | void;
80
- onFailure?: (errorMessage: string) => void;
80
+ onFailure?: (error: Error) => void;
81
81
  }
82
82
 
83
83
  // @public (undocumented)