@atlaskit/link-create 0.3.1 → 0.3.3

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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/common/constants.js +4 -2
  3. package/dist/cjs/controllers/form-context/main.js +17 -5
  4. package/dist/cjs/ui/create-form/main.js +29 -17
  5. package/dist/cjs/ui/create-form/messages.js +20 -0
  6. package/dist/cjs/ui/create-form/textfield/main.js +4 -3
  7. package/dist/cjs/ui/error-boundary/error-boundary-ui/error-svg/index.js +46 -44
  8. package/dist/cjs/ui/error-boundary/error-boundary-ui/messages.js +1 -1
  9. package/dist/cjs/ui/main.js +23 -5
  10. package/dist/cjs/ui/messages.js +15 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/common/constants.js +2 -1
  13. package/dist/es2019/controllers/form-context/main.js +11 -2
  14. package/dist/es2019/ui/create-form/main.js +32 -16
  15. package/dist/es2019/ui/create-form/messages.js +13 -0
  16. package/dist/es2019/ui/create-form/textfield/main.js +4 -3
  17. package/dist/es2019/ui/error-boundary/error-boundary-ui/error-svg/index.js +46 -44
  18. package/dist/es2019/ui/error-boundary/error-boundary-ui/messages.js +1 -1
  19. package/dist/es2019/ui/main.js +20 -5
  20. package/dist/es2019/ui/messages.js +8 -0
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/common/constants.js +2 -1
  23. package/dist/esm/controllers/form-context/main.js +17 -5
  24. package/dist/esm/ui/create-form/main.js +32 -20
  25. package/dist/esm/ui/create-form/messages.js +13 -0
  26. package/dist/esm/ui/create-form/textfield/main.js +4 -3
  27. package/dist/esm/ui/error-boundary/error-boundary-ui/error-svg/index.js +46 -44
  28. package/dist/esm/ui/error-boundary/error-boundary-ui/messages.js +1 -1
  29. package/dist/esm/ui/main.js +23 -5
  30. package/dist/esm/ui/messages.js +8 -0
  31. package/dist/esm/version.json +1 -1
  32. package/dist/types/common/constants.d.ts +1 -0
  33. package/dist/types/controllers/callback-context/main.d.ts +1 -1
  34. package/dist/types/controllers/form-context/main.d.ts +2 -0
  35. package/dist/types/ui/create-form/main.d.ts +3 -3
  36. package/dist/types/ui/create-form/messages.d.ts +12 -0
  37. package/dist/types/ui/create-form/textfield/main.d.ts +1 -1
  38. package/dist/types/ui/create-form/textfield/types.d.ts +2 -0
  39. package/dist/types/ui/messages.d.ts +7 -0
  40. package/package.json +6 -4
  41. package/report.api.md +15 -4
  42. package/tmp/api-report-tmp.d.ts +10 -5
  43. package/dist/cjs/ui/create-form/styled.js +0 -13
  44. package/dist/cjs/ui/error-boundary/error-boundary-ui/error-svg/styled.js +0 -13
  45. package/dist/es2019/ui/create-form/styled.js +0 -7
  46. package/dist/es2019/ui/error-boundary/error-boundary-ui/error-svg/styled.js +0 -7
  47. package/dist/esm/ui/create-form/styled.js +0 -5
  48. package/dist/esm/ui/error-boundary/error-boundary-ui/error-svg/styled.js +0 -5
  49. package/dist/types/ui/create-form/styled.d.ts +0 -1
  50. package/dist/types/ui/error-boundary/error-boundary-ui/error-svg/styled.d.ts +0 -1
@@ -1,52 +1,54 @@
1
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
1
2
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { errorStyles } from './styled';
3
+ import { css, jsx } from '@emotion/react';
4
+ const WIDTH = 82;
5
+ const errorStyles = css({
6
+ width: `${WIDTH}px`,
7
+ margin: `0 auto ${"var(--ds-space-300, 24px)"}`,
8
+ display: `block`
9
+ });
10
+ const id = 'link-create-error-svg';
4
11
  const ErrorSVG = () => jsx("svg", {
12
+ height: "90",
13
+ viewBox: "0 0 164 212",
14
+ fill: "none",
5
15
  xmlns: "http://www.w3.org/2000/svg",
6
- viewBox: "0 0 82 110"
7
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
8
- ,
9
16
  css: errorStyles
10
- }, jsx("defs", null, jsx("linearGradient", {
11
- id: "a",
12
- x1: "81.992%",
13
- x2: "-1.724%",
14
- y1: "43.911%",
15
- y2: "87.726%"
16
- }, jsx("stop", {
17
- offset: "0%",
18
- stopColor: "#FFD740"
19
- }), jsx("stop", {
20
- offset: "100%",
21
- stopColor: "#FFAB00"
22
- }))), jsx("g", {
23
- fill: "none",
24
- fillRule: "evenodd"
25
17
  }, jsx("path", {
26
- fill: "url(#a)",
27
- fillRule: "nonzero",
28
- d: "M47.39 40.58l33.22 57.54a7.585 7.585 0 0 1-6.57 11.38H7.6a7.585 7.585 0 0 1-6.57-11.38l33.22-57.54a7.585 7.585 0 0 1 13.14 0z"
29
- }), jsx("path", {
30
- fill: "#253858",
31
- fillRule: "nonzero",
32
- d: "M43.61 82.355l1.44-22.175a4.59 4.59 0 0 0-4.58-4.89 4.59 4.59 0 0 0-4.58 4.89l1.44 22.175a3.15 3.15 0 0 0 3.14 2.945 3.15 3.15 0 0 0 3.14-2.945zM35.69 94.125a4.765 4.765 0 0 0 5.195 4.79 4.84 4.84 0 0 0-.45-9.66 4.82 4.82 0 0 0-4.745 4.87z"
33
- }), jsx("path", {
34
- fill: "#FFC400",
35
- fillRule: "nonzero",
36
- d: "M45.85 14.085L42.145.725a.305.305 0 0 0-.595.025L39.22 13.3l-2.9-.54a.305.305 0 0 0-.35.38l3.705 13.36a.305.305 0 0 0 .595 0l2.33-12.55 2.9.515a.305.305 0 0 0 .35-.38z"
18
+ d: "m95.43 74.16 66.44 115.08c5.84 10.12-1.46 22.76-13.14 22.76H15.85c-11.68 0-18.98-12.65-13.14-22.76L69.15 74.16c5.84-10.12 20.44-10.12 26.28 0Zm-7.56 83.55 2.88-44.35c.34-5.29-3.86-9.78-9.16-9.78-5.31 0-9.51 4.48-9.16 9.78l2.88 44.35a6.3 6.3 0 0 0 6.28 5.89c3.31 0 6.06-2.58 6.28-5.89Zm-15.84 23.54c0 5.66 4.76 10.1 10.39 9.58 4.85-.45 8.73-4.5 8.83-9.37.11-5.45-4.31-9.94-9.73-9.94-5.23-.01-9.49 4.37-9.49 9.73Z",
19
+ fill: `url(#${id})`
37
20
  }), jsx("path", {
38
- fill: "#FFAB00",
39
- fillRule: "nonzero",
40
- d: "M32.56 21.405l-5.44-4.275a.135.135 0 0 0-.205.165L29.68 23l-1.33.655a.135.135 0 0 0 0 .225l5.435 4.275a.135.135 0 0 0 .205-.165l-2.785-5.715 1.33-.645a.135.135 0 0 0 .025-.225z"
21
+ opacity: ".6",
22
+ d: "M93.35 27.17 85.94.45c-.17-.62-1.07-.58-1.19.05l-4.66 25.1-5.8-1.08a.612.612 0 0 0-.7.76L81 52c.17.62 1.07.58 1.19-.05l4.66-25.1 5.8 1.08c.45.08.82-.33.7-.76ZM66.77 41.81 55.9 33.26c-.22-.18-.53.07-.41.33l5.53 11.43-2.66 1.29c-.18.09-.2.33-.05.45l10.87 8.55c.22.18.53-.07.41-.33l-5.53-11.43 2.66-1.29c.17-.08.2-.33.05-.45Z",
23
+ fill: "#C1C7D0"
41
24
  }), jsx("path", {
42
- stroke: "#344563",
43
- strokeLinecap: "round",
44
- strokeWidth: "2",
45
- d: "M57.575 18.8c-.585.795-5.5-2.8-6.08-2-.58.8 4.33 4.395 3.75 5.195-.58.8-5.5-2.8-6.085-2-.585.8 4.33 4.395 3.745 5.195-.585.8-5.5-2.8-6.085-2-.585.8 4.33 4.395 3.745 5.195"
46
- }), jsx("path", {
47
- stroke: "#5E6C84",
48
- strokeLinecap: "round",
49
- strokeWidth: "2",
50
- d: "M59.96 32.595c-.73.665-3.525-2.39-4.255-1.72-.73.67 2.065 3.725 1.335 4.39-.73.665-3.525-2.39-4.255-1.72-.34.31.08 1.135.555 2M22.4 32.5c.91.385 2.5-3.435 3.43-3.05.93.385-.695 4.2.215 4.585.91.385 2.5-3.435 3.43-3.05.425.18.305 1.095.145 2.065"
51
- })));
25
+ opacity: ".6",
26
+ d: "M102.78 56.75a.993.993 0 0 1-.92-1.38c-.24-.77-2.29-2.85-3.54-4.11-2.97-3.01-4.93-5-3.84-6.49 1.09-1.48 3.58-.22 7.35 1.7 1.32.67 3.35 1.7 4.45 2.03-.64-.95-2.24-2.58-3.28-3.63-2.97-3.01-4.93-5-3.84-6.49 1.08-1.48 3.58-.22 7.34 1.7 1.32.67 3.34 1.7 4.45 2.03-.64-.95-2.24-2.57-3.28-3.62-2.97-3.01-4.93-5-3.84-6.49 1.08-1.48 3.57-.22 7.34 1.7 1.58.8 4.18 2.13 4.98 2.13a1.005 1.005 0 0 1 1.46 1.36c-1.09 1.48-3.57.22-7.34-1.7-1.32-.67-3.34-1.7-4.44-2.03.64.95 2.24 2.57 3.28 3.62 2.97 3.01 4.93 5 3.84 6.49-1.08 1.48-3.57.22-7.34-1.7-1.32-.67-3.35-1.7-4.45-2.03.64.95 2.24 2.57 3.28 3.63 2.97 3.01 4.93 5 3.84 6.49-1.09 1.48-3.58.22-7.35-1.7-1.32-.67-3.35-1.71-4.45-2.03.64.95 2.24 2.58 3.28 3.63 2.97 3.01 4.93 5 3.84 6.49-.21.26-.51.4-.82.4Zm5.56 14.32c-.35 0-.69-.19-.88-.52-1.04-1.88-2.22-4.02-.91-5.21 1.31-1.2 3.34.18 5.49 1.63.87.59 2.26 1.53 2.93 1.71-.12-.68-.93-2.15-1.45-3.07-1.26-2.27-2.45-4.41-1.14-5.61 1.31-1.2 3.34.18 5.49 1.63.96.65 2.54 1.72 3.1 1.74a1 1 0 0 1 1.27 1.54c-1.31 1.2-3.34-.17-5.49-1.63-.87-.59-2.26-1.53-2.93-1.71.12.68.93 2.15 1.45 3.07 1.26 2.27 2.45 4.41 1.14 5.61-1.31 1.2-3.34-.18-5.49-1.63-.87-.59-2.26-1.53-2.93-1.71.12.68.93 2.14 1.22 2.67.27.48.09 1.09-.39 1.36-.15.09-.32.13-.48.13Zm-54.32-2.89c-.22 0-.44-.04-.67-.14-1.64-.69-1.24-3.11-.81-5.67.17-1.04.45-2.7.33-3.38-.57.39-1.56 1.75-2.18 2.6-1.53 2.09-2.99 4.07-4.62 3.38a.991.991 0 0 1-.53-1.31c.2-.48.73-.72 1.21-.57.52-.21 1.65-1.75 2.34-2.68 1.53-2.09 2.98-4.08 4.62-3.38 1.64.69 1.24 3.11.81 5.67-.17 1.04-.45 2.7-.33 3.38.57-.39 1.56-1.75 2.18-2.6 1.53-2.09 2.98-4.08 4.62-3.38 1.63.69 1.24 3.09.89 5.21-.09.54-.6.91-1.15.83-.54-.09-.92-.6-.83-1.15.1-.59.37-2.24.26-2.92-.57.39-1.56 1.75-2.18 2.6-1.33 1.79-2.59 3.51-3.96 3.51Z",
27
+ fill: "#B3BAC5"
28
+ }), jsx("defs", null, jsx("linearGradient", {
29
+ id: id,
30
+ x1: "26.169",
31
+ y1: "228.621",
32
+ x2: "138.408",
33
+ y2: "116.382",
34
+ gradientUnits: "userSpaceOnUse"
35
+ }, jsx("stop", {
36
+ stopColor: "#C1C7D0"
37
+ }), jsx("stop", {
38
+ offset: ".297",
39
+ stopColor: "#C6CBD4",
40
+ stopOpacity: ".881"
41
+ }), jsx("stop", {
42
+ offset: ".63",
43
+ stopColor: "#D3D7DE",
44
+ stopOpacity: ".748"
45
+ }), jsx("stop", {
46
+ offset: ".98",
47
+ stopColor: "#E9EBEF",
48
+ stopOpacity: ".608"
49
+ }), jsx("stop", {
50
+ offset: "1",
51
+ stopColor: "#EBECF0",
52
+ stopOpacity: ".6"
53
+ }))));
52
54
  export default ErrorSVG;
@@ -7,7 +7,7 @@ export default defineMessages({
7
7
  },
8
8
  description: {
9
9
  id: 'link-create.unknown-error.description',
10
- defaultMessage: '<a>Contact Support</a> if refreshing doesn’t fix things.',
10
+ defaultMessage: 'Refresh the page, or contact <a>Atlassian Support</a> if this keeps happening.',
11
11
  description: 'Description when an unknown error occurs'
12
12
  }
13
13
  });
@@ -1,15 +1,19 @@
1
1
  /** @jsx jsx */
2
2
  import { memo, useCallback } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
+ import { useIntl } from 'react-intl-next';
4
5
  import { AnalyticsContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
5
6
  import Modal, { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
6
7
  import { ANALYTICS_CHANNEL, COMPONENT_NAME } from '../common/constants';
7
8
  import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
8
9
  import createEventPayload from '../common/utils/analytics/analytics.codegen';
9
10
  import { LinkCreateCallbackProvider } from '../controllers/callback-context';
11
+ import { FormContextProvider, useFormContext } from '../controllers/form-context';
10
12
  import { name as packageName, version as packageVersion } from '../version.json';
11
13
  import { ErrorBoundary } from './error-boundary';
12
- const LinkCreate = ({
14
+ import { messages } from './messages';
15
+ const withFormContext = Component => props => jsx(FormContextProvider, null, jsx(Component, props));
16
+ const LinkCreate = withFormContext(({
13
17
  plugins,
14
18
  entityKey,
15
19
  onCreate,
@@ -17,18 +21,28 @@ const LinkCreate = ({
17
21
  onCancel
18
22
  }) => {
19
23
  const chosenOne = plugins.find(plugin => plugin.key === entityKey);
24
+ const {
25
+ setFormErrorMessage
26
+ } = useFormContext();
20
27
  if (!chosenOne) {
21
28
  throw new Error('Make sure you specified a valid entityKey');
22
29
  }
23
30
  const handleCreate = useCallback(result => {
31
+ // Reset the form error message
32
+ setFormErrorMessage(undefined);
24
33
  onCreate && onCreate(result.url);
25
- }, [onCreate]);
34
+ }, [onCreate, setFormErrorMessage]);
35
+ const handleFailure = useCallback(errorMessage => {
36
+ // Set the form error message
37
+ setFormErrorMessage(errorMessage);
38
+ onFailure && onFailure(errorMessage);
39
+ }, [onFailure, setFormErrorMessage]);
26
40
  return jsx(LinkCreateCallbackProvider, {
27
41
  onCreate: handleCreate,
28
- onFailure: onFailure,
42
+ onFailure: handleFailure,
29
43
  onCancel: onCancel
30
44
  }, chosenOne.form);
31
- };
45
+ });
32
46
  const LinkCreateWithModal = props => {
33
47
  const {
34
48
  testId,
@@ -38,6 +52,7 @@ const LinkCreateWithModal = props => {
38
52
  const {
39
53
  createAnalyticsEvent
40
54
  } = useAnalyticsEvents();
55
+ const intl = useIntl();
41
56
  const handleOpenComplete = useCallback(() => {
42
57
  createAnalyticsEvent(createEventPayload('screen.linkCreateScreen.viewed', {})).fire(ANALYTICS_CHANNEL);
43
58
  }, [createAnalyticsEvent]);
@@ -50,7 +65,7 @@ const LinkCreateWithModal = props => {
50
65
  shouldScrollInViewport: true,
51
66
  onOpenComplete: handleOpenComplete,
52
67
  onCloseComplete: handleCloseComplete
53
- }, jsx(ModalHeader, null, jsx(ModalTitle, null, "Create New")), jsx(ModalBody, null, jsx(ErrorBoundary, null, jsx(LinkCreate, props)))));
68
+ }, jsx(ModalHeader, null, jsx(ModalTitle, null, intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(ErrorBoundary, null, jsx(FormContextProvider, null, jsx(LinkCreate, props))))));
54
69
  };
55
70
  const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(({
56
71
  ...props
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export const messages = defineMessages({
3
+ heading: {
4
+ id: 'linkCreate.modal.heading',
5
+ defaultMessage: 'Create new',
6
+ description: 'Header for the create modal'
7
+ }
8
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,3 @@
1
1
  export var ANALYTICS_CHANNEL = 'media';
2
- export var COMPONENT_NAME = 'linkCreate';
2
+ export var COMPONENT_NAME = 'linkCreate';
3
+ export var CREATE_FORM_MAX_WIDTH_IN_PX = '600';
@@ -7,14 +7,19 @@ export var FormContext = /*#__PURE__*/createContext({
7
7
  assignValidator: function assignValidator() {},
8
8
  getValidators: function getValidators() {
9
9
  return {};
10
- }
10
+ },
11
+ setFormErrorMessage: function setFormErrorMessage() {}
11
12
  });
12
13
  var FormContextProvider = function FormContextProvider(_ref) {
13
14
  var children = _ref.children;
14
- var _useState = useState({}),
15
+ var _useState = useState(),
15
16
  _useState2 = _slicedToArray(_useState, 2),
16
- validators = _useState2[0],
17
- setValidators = _useState2[1];
17
+ error = _useState2[0],
18
+ setError = _useState2[1];
19
+ var _useState3 = useState({}),
20
+ _useState4 = _slicedToArray(_useState3, 2),
21
+ validators = _useState4[0],
22
+ setValidators = _useState4[1];
18
23
 
19
24
  // Use useCallback to prevent infinite useEffect calls
20
25
  var assignValidator = useCallback(function (name, fieldValidators) {
@@ -27,10 +32,17 @@ var FormContextProvider = function FormContextProvider(_ref) {
27
32
  var getValidators = useCallback(function () {
28
33
  return validators;
29
34
  }, [validators]);
35
+
36
+ // Callback to reset error state
37
+ var setFormErrorMessage = useCallback(function (errorMessage) {
38
+ return setError(errorMessage);
39
+ }, [setError]);
30
40
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
31
41
  value: {
32
42
  assignValidator: assignValidator,
33
- getValidators: getValidators
43
+ getValidators: getValidators,
44
+ setFormErrorMessage: setFormErrorMessage,
45
+ formErrorMessage: error
34
46
  }
35
47
  }, children);
36
48
  };
@@ -3,23 +3,30 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
4
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
5
5
  /** @jsx jsx */
6
- import React, { useCallback } from 'react';
7
- import { jsx } from '@emotion/react';
6
+ import { useCallback } from 'react';
7
+ import { css, jsx } from '@emotion/react';
8
+ import { useIntl } from 'react-intl-next';
8
9
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
9
10
  import LoadingButton from '@atlaskit/button/loading-button';
10
11
  import Button from '@atlaskit/button/standard-button';
11
12
  import Form, { FormFooter, FormSection } from '@atlaskit/form';
12
- import { ANALYTICS_CHANNEL } from '../../common/constants';
13
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
14
+ import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
13
15
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
14
- import { FormContextProvider, useFormContext } from '../../controllers/form-context';
15
- import { formStyles } from './styled';
16
+ import { useFormContext } from '../../controllers/form-context';
17
+ import { messages } from './messages';
16
18
  import { validateFormData } from './utils';
17
- var withFormContext = function withFormContext(Component) {
18
- return function (props) {
19
- return jsx(FormContextProvider, null, jsx(Component, props));
20
- };
21
- };
22
- var CreateFormWithoutContext = function CreateFormWithoutContext(_ref) {
19
+ var formStyles = css({
20
+ maxWidth: "".concat(CREATE_FORM_MAX_WIDTH_IN_PX, "px"),
21
+ padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
22
+ margin: "var(--ds-space-0, 0px)".concat(" auto")
23
+ });
24
+ var errorStyles = css({
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ marginRight: 'auto'
28
+ });
29
+ export var CreateForm = function CreateForm(_ref) {
23
30
  var children = _ref.children,
24
31
  testId = _ref.testId,
25
32
  onCancel = _ref.onCancel,
@@ -27,7 +34,9 @@ var CreateFormWithoutContext = function CreateFormWithoutContext(_ref) {
27
34
  var _useAnalyticsEvents = useAnalyticsEvents(),
28
35
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
29
36
  var _useFormContext = useFormContext(),
30
- getValidators = _useFormContext.getValidators;
37
+ getValidators = _useFormContext.getValidators,
38
+ formErrorMessage = _useFormContext.formErrorMessage;
39
+ var intl = useIntl();
31
40
  var handleSubmit = useCallback( /*#__PURE__*/function () {
32
41
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
33
42
  var validators, errors;
@@ -70,20 +79,23 @@ var CreateFormWithoutContext = function CreateFormWithoutContext(_ref) {
70
79
  formProps = _ref3.formProps;
71
80
  return jsx("form", _extends({}, formProps, {
72
81
  name: "confluence-creation-form",
73
- "data-testid": testId
74
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
75
- ,
82
+ "data-testid": testId,
76
83
  css: formStyles
77
- }), jsx(FormSection, null, children), jsx(FormFooter, null, jsx(Button, {
84
+ }), jsx(FormSection, null, children), jsx(FormFooter, null, formErrorMessage && jsx("div", {
85
+ css: errorStyles,
86
+ "data-testid": "link-create-confluence-form-error"
87
+ }, jsx(ErrorIcon, {
88
+ label: formErrorMessage,
89
+ primaryColor: "var(--ds-icon-danger, #E34935)"
90
+ }), formErrorMessage), jsx(Button, {
78
91
  appearance: "subtle",
79
92
  onClick: handleCancel,
80
93
  testId: 'cancel-button'
81
- }, "Cancel"), jsx(LoadingButton, {
94
+ }, intl.formatMessage(messages.cancel)), jsx(LoadingButton, {
82
95
  appearance: "primary",
83
96
  type: "submit",
84
97
  isLoading: submitting,
85
98
  testId: 'create-button'
86
- }, "Create")));
99
+ }, intl.formatMessage(messages.create))));
87
100
  });
88
- };
89
- export var CreateForm = withFormContext(CreateFormWithoutContext);
101
+ };
@@ -0,0 +1,13 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ cancel: {
4
+ id: 'linkCreate.createForm.button.cancel',
5
+ defaultMessage: 'Cancel',
6
+ description: 'Button to cancel and dismiss link create'
7
+ },
8
+ create: {
9
+ id: 'linkCreate.createForm.button.create',
10
+ defaultMessage: 'Create',
11
+ description: 'Button to submit the form and Create object'
12
+ }
13
+ });
@@ -11,14 +11,14 @@ import { useFormContext } from '../../../controllers/form-context';
11
11
  * the handleSubmit function passed to the form <Form> that have a key matching the `name`
12
12
  * of this text field are shown above the field.
13
13
  */
14
-
15
14
  export function TextField(_ref) {
16
15
  var label = _ref.label,
17
16
  name = _ref.name,
18
17
  validationHelpText = _ref.validationHelpText,
19
18
  isRequired = _ref.isRequired,
20
19
  testId = _ref.testId,
21
- validators = _ref.validators;
20
+ validators = _ref.validators,
21
+ placeholder = _ref.placeholder;
22
22
  var _useFormContext = useFormContext(),
23
23
  assignValidator = _useFormContext.assignValidator;
24
24
  useEffect(function () {
@@ -35,7 +35,8 @@ export function TextField(_ref) {
35
35
  var fieldProps = _ref2.fieldProps,
36
36
  error = _ref2.error;
37
37
  return jsx(Fragment, null, jsx(AkTextfield, _extends({}, fieldProps, {
38
- testId: testId
38
+ testId: testId,
39
+ placeholder: placeholder
39
40
  })), !error && jsx(HelperMessage, null, validationHelpText), error && jsx(ErrorMessage, null, error));
40
41
  });
41
42
  }
@@ -1,54 +1,56 @@
1
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
1
2
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { errorStyles } from './styled';
3
+ import { css, jsx } from '@emotion/react';
4
+ var WIDTH = 82;
5
+ var errorStyles = css({
6
+ width: "".concat(WIDTH, "px"),
7
+ margin: "0 auto ".concat("var(--ds-space-300, 24px)"),
8
+ display: "block"
9
+ });
10
+ var id = 'link-create-error-svg';
4
11
  var ErrorSVG = function ErrorSVG() {
5
12
  return jsx("svg", {
13
+ height: "90",
14
+ viewBox: "0 0 164 212",
15
+ fill: "none",
6
16
  xmlns: "http://www.w3.org/2000/svg",
7
- viewBox: "0 0 82 110"
8
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
9
- ,
10
17
  css: errorStyles
11
- }, jsx("defs", null, jsx("linearGradient", {
12
- id: "a",
13
- x1: "81.992%",
14
- x2: "-1.724%",
15
- y1: "43.911%",
16
- y2: "87.726%"
17
- }, jsx("stop", {
18
- offset: "0%",
19
- stopColor: "#FFD740"
20
- }), jsx("stop", {
21
- offset: "100%",
22
- stopColor: "#FFAB00"
23
- }))), jsx("g", {
24
- fill: "none",
25
- fillRule: "evenodd"
26
18
  }, jsx("path", {
27
- fill: "url(#a)",
28
- fillRule: "nonzero",
29
- d: "M47.39 40.58l33.22 57.54a7.585 7.585 0 0 1-6.57 11.38H7.6a7.585 7.585 0 0 1-6.57-11.38l33.22-57.54a7.585 7.585 0 0 1 13.14 0z"
30
- }), jsx("path", {
31
- fill: "#253858",
32
- fillRule: "nonzero",
33
- d: "M43.61 82.355l1.44-22.175a4.59 4.59 0 0 0-4.58-4.89 4.59 4.59 0 0 0-4.58 4.89l1.44 22.175a3.15 3.15 0 0 0 3.14 2.945 3.15 3.15 0 0 0 3.14-2.945zM35.69 94.125a4.765 4.765 0 0 0 5.195 4.79 4.84 4.84 0 0 0-.45-9.66 4.82 4.82 0 0 0-4.745 4.87z"
34
- }), jsx("path", {
35
- fill: "#FFC400",
36
- fillRule: "nonzero",
37
- d: "M45.85 14.085L42.145.725a.305.305 0 0 0-.595.025L39.22 13.3l-2.9-.54a.305.305 0 0 0-.35.38l3.705 13.36a.305.305 0 0 0 .595 0l2.33-12.55 2.9.515a.305.305 0 0 0 .35-.38z"
19
+ d: "m95.43 74.16 66.44 115.08c5.84 10.12-1.46 22.76-13.14 22.76H15.85c-11.68 0-18.98-12.65-13.14-22.76L69.15 74.16c5.84-10.12 20.44-10.12 26.28 0Zm-7.56 83.55 2.88-44.35c.34-5.29-3.86-9.78-9.16-9.78-5.31 0-9.51 4.48-9.16 9.78l2.88 44.35a6.3 6.3 0 0 0 6.28 5.89c3.31 0 6.06-2.58 6.28-5.89Zm-15.84 23.54c0 5.66 4.76 10.1 10.39 9.58 4.85-.45 8.73-4.5 8.83-9.37.11-5.45-4.31-9.94-9.73-9.94-5.23-.01-9.49 4.37-9.49 9.73Z",
20
+ fill: "url(#".concat(id, ")")
38
21
  }), jsx("path", {
39
- fill: "#FFAB00",
40
- fillRule: "nonzero",
41
- d: "M32.56 21.405l-5.44-4.275a.135.135 0 0 0-.205.165L29.68 23l-1.33.655a.135.135 0 0 0 0 .225l5.435 4.275a.135.135 0 0 0 .205-.165l-2.785-5.715 1.33-.645a.135.135 0 0 0 .025-.225z"
22
+ opacity: ".6",
23
+ d: "M93.35 27.17 85.94.45c-.17-.62-1.07-.58-1.19.05l-4.66 25.1-5.8-1.08a.612.612 0 0 0-.7.76L81 52c.17.62 1.07.58 1.19-.05l4.66-25.1 5.8 1.08c.45.08.82-.33.7-.76ZM66.77 41.81 55.9 33.26c-.22-.18-.53.07-.41.33l5.53 11.43-2.66 1.29c-.18.09-.2.33-.05.45l10.87 8.55c.22.18.53-.07.41-.33l-5.53-11.43 2.66-1.29c.17-.08.2-.33.05-.45Z",
24
+ fill: "#C1C7D0"
42
25
  }), jsx("path", {
43
- stroke: "#344563",
44
- strokeLinecap: "round",
45
- strokeWidth: "2",
46
- d: "M57.575 18.8c-.585.795-5.5-2.8-6.08-2-.58.8 4.33 4.395 3.75 5.195-.58.8-5.5-2.8-6.085-2-.585.8 4.33 4.395 3.745 5.195-.585.8-5.5-2.8-6.085-2-.585.8 4.33 4.395 3.745 5.195"
47
- }), jsx("path", {
48
- stroke: "#5E6C84",
49
- strokeLinecap: "round",
50
- strokeWidth: "2",
51
- d: "M59.96 32.595c-.73.665-3.525-2.39-4.255-1.72-.73.67 2.065 3.725 1.335 4.39-.73.665-3.525-2.39-4.255-1.72-.34.31.08 1.135.555 2M22.4 32.5c.91.385 2.5-3.435 3.43-3.05.93.385-.695 4.2.215 4.585.91.385 2.5-3.435 3.43-3.05.425.18.305 1.095.145 2.065"
52
- })));
26
+ opacity: ".6",
27
+ d: "M102.78 56.75a.993.993 0 0 1-.92-1.38c-.24-.77-2.29-2.85-3.54-4.11-2.97-3.01-4.93-5-3.84-6.49 1.09-1.48 3.58-.22 7.35 1.7 1.32.67 3.35 1.7 4.45 2.03-.64-.95-2.24-2.58-3.28-3.63-2.97-3.01-4.93-5-3.84-6.49 1.08-1.48 3.58-.22 7.34 1.7 1.32.67 3.34 1.7 4.45 2.03-.64-.95-2.24-2.57-3.28-3.62-2.97-3.01-4.93-5-3.84-6.49 1.08-1.48 3.57-.22 7.34 1.7 1.58.8 4.18 2.13 4.98 2.13a1.005 1.005 0 0 1 1.46 1.36c-1.09 1.48-3.57.22-7.34-1.7-1.32-.67-3.34-1.7-4.44-2.03.64.95 2.24 2.57 3.28 3.62 2.97 3.01 4.93 5 3.84 6.49-1.08 1.48-3.57.22-7.34-1.7-1.32-.67-3.35-1.7-4.45-2.03.64.95 2.24 2.57 3.28 3.63 2.97 3.01 4.93 5 3.84 6.49-1.09 1.48-3.58.22-7.35-1.7-1.32-.67-3.35-1.71-4.45-2.03.64.95 2.24 2.58 3.28 3.63 2.97 3.01 4.93 5 3.84 6.49-.21.26-.51.4-.82.4Zm5.56 14.32c-.35 0-.69-.19-.88-.52-1.04-1.88-2.22-4.02-.91-5.21 1.31-1.2 3.34.18 5.49 1.63.87.59 2.26 1.53 2.93 1.71-.12-.68-.93-2.15-1.45-3.07-1.26-2.27-2.45-4.41-1.14-5.61 1.31-1.2 3.34.18 5.49 1.63.96.65 2.54 1.72 3.1 1.74a1 1 0 0 1 1.27 1.54c-1.31 1.2-3.34-.17-5.49-1.63-.87-.59-2.26-1.53-2.93-1.71.12.68.93 2.15 1.45 3.07 1.26 2.27 2.45 4.41 1.14 5.61-1.31 1.2-3.34-.18-5.49-1.63-.87-.59-2.26-1.53-2.93-1.71.12.68.93 2.14 1.22 2.67.27.48.09 1.09-.39 1.36-.15.09-.32.13-.48.13Zm-54.32-2.89c-.22 0-.44-.04-.67-.14-1.64-.69-1.24-3.11-.81-5.67.17-1.04.45-2.7.33-3.38-.57.39-1.56 1.75-2.18 2.6-1.53 2.09-2.99 4.07-4.62 3.38a.991.991 0 0 1-.53-1.31c.2-.48.73-.72 1.21-.57.52-.21 1.65-1.75 2.34-2.68 1.53-2.09 2.98-4.08 4.62-3.38 1.64.69 1.24 3.11.81 5.67-.17 1.04-.45 2.7-.33 3.38.57-.39 1.56-1.75 2.18-2.6 1.53-2.09 2.98-4.08 4.62-3.38 1.63.69 1.24 3.09.89 5.21-.09.54-.6.91-1.15.83-.54-.09-.92-.6-.83-1.15.1-.59.37-2.24.26-2.92-.57.39-1.56 1.75-2.18 2.6-1.33 1.79-2.59 3.51-3.96 3.51Z",
28
+ fill: "#B3BAC5"
29
+ }), jsx("defs", null, jsx("linearGradient", {
30
+ id: id,
31
+ x1: "26.169",
32
+ y1: "228.621",
33
+ x2: "138.408",
34
+ y2: "116.382",
35
+ gradientUnits: "userSpaceOnUse"
36
+ }, jsx("stop", {
37
+ stopColor: "#C1C7D0"
38
+ }), jsx("stop", {
39
+ offset: ".297",
40
+ stopColor: "#C6CBD4",
41
+ stopOpacity: ".881"
42
+ }), jsx("stop", {
43
+ offset: ".63",
44
+ stopColor: "#D3D7DE",
45
+ stopOpacity: ".748"
46
+ }), jsx("stop", {
47
+ offset: ".98",
48
+ stopColor: "#E9EBEF",
49
+ stopOpacity: ".608"
50
+ }), jsx("stop", {
51
+ offset: "1",
52
+ stopColor: "#EBECF0",
53
+ stopOpacity: ".6"
54
+ }))));
53
55
  };
54
56
  export default ErrorSVG;
@@ -7,7 +7,7 @@ export default defineMessages({
7
7
  },
8
8
  description: {
9
9
  id: 'link-create.unknown-error.description',
10
- defaultMessage: '<a>Contact Support</a> if refreshing doesn’t fix things.',
10
+ defaultMessage: 'Refresh the page, or contact <a>Atlassian Support</a> if this keeps happening.',
11
11
  description: 'Description when an unknown error occurs'
12
12
  }
13
13
  });
@@ -2,15 +2,23 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { memo, useCallback } from 'react';
4
4
  import { jsx } from '@emotion/react';
5
+ import { useIntl } from 'react-intl-next';
5
6
  import { AnalyticsContext, useAnalyticsEvents } from '@atlaskit/analytics-next';
6
7
  import Modal, { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
7
8
  import { ANALYTICS_CHANNEL, COMPONENT_NAME } from '../common/constants';
8
9
  import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
9
10
  import createEventPayload from '../common/utils/analytics/analytics.codegen';
10
11
  import { LinkCreateCallbackProvider } from '../controllers/callback-context';
12
+ import { FormContextProvider, useFormContext } from '../controllers/form-context';
11
13
  import { name as packageName, version as packageVersion } from '../version.json';
12
14
  import { ErrorBoundary } from './error-boundary';
13
- var LinkCreate = function LinkCreate(_ref) {
15
+ import { messages } from './messages';
16
+ var withFormContext = function withFormContext(Component) {
17
+ return function (props) {
18
+ return jsx(FormContextProvider, null, jsx(Component, props));
19
+ };
20
+ };
21
+ var LinkCreate = withFormContext(function (_ref) {
14
22
  var plugins = _ref.plugins,
15
23
  entityKey = _ref.entityKey,
16
24
  onCreate = _ref.onCreate,
@@ -19,24 +27,34 @@ var LinkCreate = function LinkCreate(_ref) {
19
27
  var chosenOne = plugins.find(function (plugin) {
20
28
  return plugin.key === entityKey;
21
29
  });
30
+ var _useFormContext = useFormContext(),
31
+ setFormErrorMessage = _useFormContext.setFormErrorMessage;
22
32
  if (!chosenOne) {
23
33
  throw new Error('Make sure you specified a valid entityKey');
24
34
  }
25
35
  var handleCreate = useCallback(function (result) {
36
+ // Reset the form error message
37
+ setFormErrorMessage(undefined);
26
38
  onCreate && onCreate(result.url);
27
- }, [onCreate]);
39
+ }, [onCreate, setFormErrorMessage]);
40
+ var handleFailure = useCallback(function (errorMessage) {
41
+ // Set the form error message
42
+ setFormErrorMessage(errorMessage);
43
+ onFailure && onFailure(errorMessage);
44
+ }, [onFailure, setFormErrorMessage]);
28
45
  return jsx(LinkCreateCallbackProvider, {
29
46
  onCreate: handleCreate,
30
- onFailure: onFailure,
47
+ onFailure: handleFailure,
31
48
  onCancel: onCancel
32
49
  }, chosenOne.form);
33
- };
50
+ });
34
51
  var LinkCreateWithModal = function LinkCreateWithModal(props) {
35
52
  var testId = props.testId,
36
53
  onCancel = props.onCancel,
37
54
  active = props.active;
38
55
  var _useAnalyticsEvents = useAnalyticsEvents(),
39
56
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
57
+ var intl = useIntl();
40
58
  var handleOpenComplete = useCallback(function () {
41
59
  createAnalyticsEvent(createEventPayload('screen.linkCreateScreen.viewed', {})).fire(ANALYTICS_CHANNEL);
42
60
  }, [createAnalyticsEvent]);
@@ -49,7 +67,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(props) {
49
67
  shouldScrollInViewport: true,
50
68
  onOpenComplete: handleOpenComplete,
51
69
  onCloseComplete: handleCloseComplete
52
- }, jsx(ModalHeader, null, jsx(ModalTitle, null, "Create New")), jsx(ModalBody, null, jsx(ErrorBoundary, null, jsx(LinkCreate, props)))));
70
+ }, jsx(ModalHeader, null, jsx(ModalTitle, null, intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(ErrorBoundary, null, jsx(FormContextProvider, null, jsx(LinkCreate, props))))));
53
71
  };
54
72
  var LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(function (_ref2) {
55
73
  var props = _extends({}, _ref2);
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ heading: {
4
+ id: 'linkCreate.modal.heading',
5
+ defaultMessage: 'Create new',
6
+ description: 'Header for the create modal'
7
+ }
8
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,3 @@
1
1
  export declare const ANALYTICS_CHANNEL = "media";
2
2
  export declare const COMPONENT_NAME = "linkCreate";
3
+ export declare const CREATE_FORM_MAX_WIDTH_IN_PX = "600";
@@ -11,7 +11,7 @@ interface LinkCreateCallbackProviderProps {
11
11
  /**
12
12
  * This callback for any errors
13
13
  */
14
- onFailure?: (error: unknown) => void;
14
+ onFailure?: (errorMessage: string) => void;
15
15
  /**
16
16
  * This callback for when the form was manually discarded by user
17
17
  */
@@ -3,6 +3,8 @@ import { Validator, ValidatorMap } from '../../common/types';
3
3
  interface FormContextType {
4
4
  assignValidator: (name: string, validators: Validator[]) => void;
5
5
  getValidators: () => ValidatorMap;
6
+ setFormErrorMessage: (errorMessage?: string) => void;
7
+ formErrorMessage?: string;
6
8
  }
7
9
  export declare const FormContext: React.Context<FormContextType>;
8
10
  declare const FormContextProvider: React.FC<{}>;