@atlaskit/link-create 0.9.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.9.1
4
10
 
5
11
  ### Patch 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);
@@ -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.1",
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, {
@@ -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.1",
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);
@@ -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.1",
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
  */
@@ -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
  */
@@ -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.1",
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",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@af/visual-regression": "*",
57
- "@atlaskit/link-test-helpers": "^4.1.0",
57
+ "@atlaskit/link-test-helpers": "^4.2.0",
58
58
  "@atlaskit/visual-regression": "*",
59
59
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
60
60
  "@testing-library/react": "^12.1.5",
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)
@@ -0,0 +1,136 @@
1
+ ## API Report File for "@atlaskit/link-create"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ /// <reference types="react" />
8
+
9
+ import { AsyncSelectProps as AsyncSelectProps_2 } from '@atlaskit/select';
10
+ import { jsx } from '@emotion/react';
11
+ import { MemoExoticComponent } from 'react';
12
+ import { ModalDialogProps } from '@atlaskit/modal-dialog';
13
+ import { OptionType } from '@atlaskit/select';
14
+ import { default as React_2 } from 'react';
15
+ import { ReactNode } from 'react';
16
+ import { SpinnerProps } from '@atlaskit/spinner';
17
+ import { TextFieldProps as TextFieldProps_2 } from '@atlaskit/textfield';
18
+
19
+ // @public
20
+ export function AsyncSelect<T = OptionType>({ label, name, validationHelpText, isRequired, testId, validators, defaultValue, ...rest }: AsyncSelectProps<T>): jsx.JSX.Element;
21
+
22
+ // @public (undocumented)
23
+ type AsyncSelectProps<T = OptionType> = AsyncSelectProps_2<T> & {
24
+ name: string;
25
+ label: string;
26
+ validationHelpText?: string;
27
+ testId?: string;
28
+ isRequired?: boolean;
29
+ validators?: Validator[];
30
+ };
31
+
32
+ // @public (undocumented)
33
+ const ComposedLinkCreate: MemoExoticComponent<(props: LinkCreateWithModalProps) => jsx.JSX.Element>;
34
+ export default ComposedLinkCreate;
35
+
36
+ // @public (undocumented)
37
+ export const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
38
+
39
+ // @public (undocumented)
40
+ export function CreateFormLoader({ size }: Partial<SpinnerProps>): jsx.JSX.Element;
41
+
42
+ // @public (undocumented)
43
+ export interface CreateFormProps<FormData> {
44
+ // (undocumented)
45
+ children: ReactNode;
46
+ // (undocumented)
47
+ hideFooter?: boolean;
48
+ // (undocumented)
49
+ isLoading?: boolean;
50
+ // (undocumented)
51
+ onCancel?: () => void;
52
+ // (undocumented)
53
+ onSubmit: (data: FormData) => void;
54
+ // (undocumented)
55
+ testId?: string;
56
+ }
57
+
58
+ // @public
59
+ export type CreatePayload = {
60
+ url: string;
61
+ objectId: string;
62
+ objectType: string;
63
+ data?: Record<string, unknown>;
64
+ };
65
+
66
+ // @public (undocumented)
67
+ interface Group {
68
+ icon: string;
69
+ key: string;
70
+ label: string;
71
+ }
72
+
73
+ // @public (undocumented)
74
+ export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderProps>;
75
+
76
+ // @public (undocumented)
77
+ interface LinkCreateCallbackProviderProps {
78
+ onCancel?: () => void;
79
+ onCreate?: (result: CreatePayload) => Promise<void> | void;
80
+ onFailure?: (error: Error) => void;
81
+ }
82
+
83
+ // @public (undocumented)
84
+ export interface LinkCreatePlugin {
85
+ form: ReactNode;
86
+ group: Group;
87
+ icon: string;
88
+ key: string;
89
+ label: string;
90
+ }
91
+
92
+ // @public (undocumented)
93
+ export interface LinkCreateProps {
94
+ entityKey: string;
95
+ groupKey?: string;
96
+ onCancel?: () => void;
97
+ onCreate?: (payload: CreatePayload) => Promise<void> | void;
98
+ onFailure?: (error: unknown) => void;
99
+ // (undocumented)
100
+ plugins: LinkCreatePlugin[];
101
+ testId?: string;
102
+ triggeredFrom?: string;
103
+ }
104
+
105
+ // @public (undocumented)
106
+ export interface LinkCreateWithModalProps extends LinkCreateProps, Partial<Pick<ModalDialogProps, 'onCloseComplete' | 'onOpenComplete'>> {
107
+ active?: boolean;
108
+ modalTitle?: string;
109
+ }
110
+
111
+ // @public
112
+ export function TextField({ label, name, testId, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
113
+
114
+ // @public (undocumented)
115
+ type TextFieldProps = Omit<TextFieldProps_2, 'name'> & {
116
+ name: string;
117
+ label?: string;
118
+ validationHelpText?: string;
119
+ validators?: Validator[];
120
+ };
121
+
122
+ // @public (undocumented)
123
+ export const useLinkCreateCallback: () => LinkCreateCallbackProviderProps;
124
+
125
+ // @public (undocumented)
126
+ export type Validator = {
127
+ isValid: (val: unknown) => boolean;
128
+ errorMessage: string;
129
+ };
130
+
131
+ // @public
132
+ export type ValidatorMap = Record<string, Validator[]>;
133
+
134
+ // (No @packageDocumentation comment for this package)
135
+
136
+ ```