@atlaskit/link-picker 6.0.2 → 6.2.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 +33 -1
- package/dist/cjs/ui/link-picker/form-footer/index.js +4 -2
- package/dist/cjs/ui/link-picker/form-footer/link-picker-submit-button/index.js +4 -2
- package/dist/cjs/ui/link-picker/form-footer/link-picker-submit-button/utils.js +32 -4
- package/dist/cjs/ui/link-picker/index.js +7 -2
- package/dist/cjs/ui/main.js +1 -1
- package/dist/es2019/ui/link-picker/form-footer/index.js +3 -1
- package/dist/es2019/ui/link-picker/form-footer/link-picker-submit-button/index.js +4 -2
- package/dist/es2019/ui/link-picker/form-footer/link-picker-submit-button/utils.js +32 -4
- package/dist/es2019/ui/link-picker/index.js +6 -2
- package/dist/es2019/ui/main.js +1 -1
- package/dist/esm/ui/link-picker/form-footer/index.js +4 -2
- package/dist/esm/ui/link-picker/form-footer/link-picker-submit-button/index.js +4 -2
- package/dist/esm/ui/link-picker/form-footer/link-picker-submit-button/utils.js +32 -4
- package/dist/esm/ui/link-picker/index.js +7 -2
- package/dist/esm/ui/main.js +1 -1
- package/dist/types/common/types.d.ts +6 -0
- package/dist/types/ui/link-picker/form-footer/index.d.ts +2 -1
- package/dist/types/ui/link-picker/form-footer/link-picker-submit-button/index.d.ts +2 -1
- package/dist/types/ui/link-picker/form-footer/link-picker-submit-button/utils.d.ts +1 -1
- package/package.json +26 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @atlaskit/link-picker
|
|
2
2
|
|
|
3
|
+
## 6.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`cd097a2111788`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cd097a2111788) -
|
|
8
|
+
Republish packages depending on `@atlaskit/react-compiler-gating` so their published dependency
|
|
9
|
+
reference is updated to the renamed `@atlaskit/react-compiler-gating` scope.
|
|
10
|
+
|
|
11
|
+
The earlier rename of `@atlassian/react-compiler-gating` to `@atlaskit/react-compiler-gating` only
|
|
12
|
+
bumped the renamed package itself, so dependent packages were never republished and their
|
|
13
|
+
published versions still referenced the old `@atlassian/react-compiler-gating` name, which is not
|
|
14
|
+
available in the public npm registry. This minor bump republishes all affected packages with the
|
|
15
|
+
corrected dependency.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 6.1.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [`672d0051b370b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/672d0051b370b) -
|
|
26
|
+
Add disableManualUrlInsert prop to disable the Insert button when a URL is typed but no search
|
|
27
|
+
result is selected
|
|
28
|
+
|
|
29
|
+
Fix bug where stale search results could enable the Insert button during an in-flight request or
|
|
30
|
+
error state when disableManualUrlInsert is true. The isLoading and error guards are now checked
|
|
31
|
+
before the disableManualUrlInsert block under the add-disable-manual-url-capability-technical
|
|
32
|
+
feature gate. The disableManualUrlInsert prop is also gated at the call site in
|
|
33
|
+
LinkPickerSubmitButton for additional safety.
|
|
34
|
+
|
|
3
35
|
## 6.0.2
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -11,7 +43,7 @@
|
|
|
11
43
|
### Patch Changes
|
|
12
44
|
|
|
13
45
|
- [`ee28cf33718b0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ee28cf33718b0) -
|
|
14
|
-
Add @
|
|
46
|
+
Add @atlaskit/react-compiler-gating as a runtime dependency to enable React Compiler platform
|
|
15
47
|
gating.
|
|
16
48
|
- Updated dependencies
|
|
17
49
|
|
|
@@ -20,7 +20,7 @@ var _add = _interopRequireDefault(require("@atlaskit/icon/core/add"));
|
|
|
20
20
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
21
21
|
var _errors = require("../../../common/utils/errors");
|
|
22
22
|
var _linkPickerSubmitButton = require("./link-picker-submit-button");
|
|
23
|
-
var _excluded = ["isLoading", "isSubmitting", "error", "url", "queryState", "items", "isEditing", "onCancel", "action", "customSubmitButtonLabel", "submitMessageId", "hideSubmitButton", "className"];
|
|
23
|
+
var _excluded = ["isLoading", "isSubmitting", "error", "url", "queryState", "items", "isEditing", "onCancel", "action", "customSubmitButtonLabel", "submitMessageId", "hideSubmitButton", "disableManualUrlInsert", "className"];
|
|
24
24
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
25
25
|
var formFooterStyles = null;
|
|
26
26
|
var formFooterActionStyles = null;
|
|
@@ -56,6 +56,7 @@ var FormFooter = exports.FormFooter = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
56
56
|
customSubmitButtonLabel = _ref.customSubmitButtonLabel,
|
|
57
57
|
submitMessageId = _ref.submitMessageId,
|
|
58
58
|
hideSubmitButton = _ref.hideSubmitButton,
|
|
59
|
+
disableManualUrlInsert = _ref.disableManualUrlInsert,
|
|
59
60
|
className = _ref.className,
|
|
60
61
|
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
61
62
|
var intl = (0, _reactIntl.useIntl)();
|
|
@@ -103,6 +104,7 @@ var FormFooter = exports.FormFooter = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
103
104
|
queryState: queryState,
|
|
104
105
|
submitMessageId: submitMessageId,
|
|
105
106
|
testId: testIds.insertButton,
|
|
106
|
-
url: url
|
|
107
|
+
url: url,
|
|
108
|
+
disableManualUrlInsert: disableManualUrlInsert
|
|
107
109
|
})));
|
|
108
110
|
});
|
|
@@ -8,6 +8,7 @@ exports.messages = exports.LinkPickerSubmitButton = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
10
|
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _utils = require("./utils");
|
|
12
13
|
var messages = exports.messages = (0, _reactIntl.defineMessages)({
|
|
13
14
|
saveButton: {
|
|
@@ -31,10 +32,11 @@ var LinkPickerSubmitButton = exports.LinkPickerSubmitButton = function LinkPicke
|
|
|
31
32
|
queryState = _ref.queryState,
|
|
32
33
|
submitMessageId = _ref.submitMessageId,
|
|
33
34
|
testId = _ref.testId,
|
|
34
|
-
url = _ref.url
|
|
35
|
+
url = _ref.url,
|
|
36
|
+
disableManualUrlInsert = _ref.disableManualUrlInsert;
|
|
35
37
|
var intl = (0, _reactIntl.useIntl)();
|
|
36
38
|
var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
|
|
37
|
-
var isSubmitDisabled = (0, _utils.checkSubmitDisabled)(isLoading, isSubmitting, error, url, queryState, items);
|
|
39
|
+
var isSubmitDisabled = (0, _utils.checkSubmitDisabled)(isLoading, isSubmitting, error, url, queryState, items, (0, _platformFeatureFlags.fg)('add-disable-manual-url-capability-technical') ? disableManualUrlInsert : undefined);
|
|
38
40
|
return /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
39
41
|
type: "submit",
|
|
40
42
|
appearance: "primary",
|
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.checkSubmitDisabled = void 0;
|
|
7
7
|
var _url = require("@atlaskit/linking-common/url");
|
|
8
|
-
var
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
|
+
var checkSubmitDisabled = exports.checkSubmitDisabled = function checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items, disableManualUrlInsert) {
|
|
9
10
|
/*
|
|
10
11
|
* Enable insert when search term is a valid url and it can be normalized
|
|
11
12
|
* Need to explicitly enable it here otherwise next condition could meet
|
|
@@ -16,6 +17,33 @@ var checkSubmitDisabled = exports.checkSubmitDisabled = function checkSubmitDisa
|
|
|
16
17
|
if (isSubmitting) {
|
|
17
18
|
return true;
|
|
18
19
|
}
|
|
20
|
+
if ((0, _platformFeatureFlags.fg)('add-disable-manual-url-capability-technical')) {
|
|
21
|
+
/*
|
|
22
|
+
* Check isLoading/error before disableManualUrlInsert so that stale items
|
|
23
|
+
* from a previous search do not accidentally enable the button during an
|
|
24
|
+
* in-flight request or an error state.
|
|
25
|
+
*/
|
|
26
|
+
if (isLoading || error) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* When disableManualUrlInsert is true, disable insert unless a result has been
|
|
32
|
+
* selected from the list (i.e. items are present and queryState is set).
|
|
33
|
+
* This prevents the user from manually typing a URL to bypass the restriction.
|
|
34
|
+
*/
|
|
35
|
+
if (disableManualUrlInsert) {
|
|
36
|
+
return !(queryState && items && items.length > 0);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* Enable insert when search term is a valid url and it can be normalized.
|
|
42
|
+
* Need to explicitly enable it here otherwise next condition could meet.
|
|
43
|
+
*
|
|
44
|
+
* This should effectively be the validation function for the form, ie if the form
|
|
45
|
+
* could be submitted, then it should not be disabled.
|
|
46
|
+
*/
|
|
19
47
|
if (url && (0, _url.normalizeUrl)(url)) {
|
|
20
48
|
return false;
|
|
21
49
|
}
|
|
@@ -29,10 +57,10 @@ var checkSubmitDisabled = exports.checkSubmitDisabled = function checkSubmitDisa
|
|
|
29
57
|
}
|
|
30
58
|
|
|
31
59
|
/*
|
|
32
|
-
* Disable insert button when
|
|
33
|
-
*
|
|
60
|
+
* Disable insert button when plugin is loading or for any search error.
|
|
61
|
+
* When the gate is on, this is already handled earlier in the function.
|
|
34
62
|
*/
|
|
35
|
-
if (isLoading || error) {
|
|
63
|
+
if (!(0, _platformFeatureFlags.fg)('add-disable-manual-url-capability-technical') && (isLoading || error)) {
|
|
36
64
|
return true;
|
|
37
65
|
}
|
|
38
66
|
return false;
|
|
@@ -118,7 +118,10 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
118
118
|
submitOnInputChange = _ref$submitOnInputCha === void 0 ? false : _ref$submitOnInputCha,
|
|
119
119
|
recentSearchListSize = _ref.recentSearchListSize,
|
|
120
120
|
shouldRenderNoResultsImage = _ref.shouldRenderNoResultsImage,
|
|
121
|
-
alwaysShowTabs = _ref.alwaysShowTabs
|
|
121
|
+
alwaysShowTabs = _ref.alwaysShowTabs,
|
|
122
|
+
_ref$disableManualUrl = _ref.disableManualUrlInsert,
|
|
123
|
+
disableManualUrlInsertProp = _ref$disableManualUrl === void 0 ? false : _ref$disableManualUrl;
|
|
124
|
+
var disableManualUrlInsert = (0, _platformFeatureFlags.fg)('add-disable-manual-url-capability-technical') && disableManualUrlInsertProp;
|
|
122
125
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
123
126
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
124
127
|
var linkInputRef = _react.default.useRef(null);
|
|
@@ -494,7 +497,8 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
494
497
|
queryState: queryState,
|
|
495
498
|
submitMessageId: submitMessageId,
|
|
496
499
|
testId: testIds.insertButton,
|
|
497
|
-
url: url
|
|
500
|
+
url: url,
|
|
501
|
+
disableManualUrlInsert: disableManualUrlInsert
|
|
498
502
|
})), !!queryState && (isLoadingPlugins || isActivePlugin) && /*#__PURE__*/_react.default.createElement(_searchResults.SearchResults, {
|
|
499
503
|
activeTab: activeTab,
|
|
500
504
|
tabs: tabs,
|
|
@@ -530,6 +534,7 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
|
|
|
530
534
|
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
531
535
|
submitMessageId: submitMessageId,
|
|
532
536
|
hideSubmitButton: moveSubmitButton || submitOnInputChange,
|
|
537
|
+
disableManualUrlInsert: disableManualUrlInsert,
|
|
533
538
|
className: (0, _runtime.ax)([(!queryState || !(plugins !== null && plugins !== void 0 && plugins.length)) && "_19pkpxbi"])
|
|
534
539
|
}));
|
|
535
540
|
}));
|
package/dist/cjs/ui/main.js
CHANGED
|
@@ -26,7 +26,7 @@ var testIds = exports.testIds = {
|
|
|
26
26
|
};
|
|
27
27
|
var PACKAGE_DATA = exports.PACKAGE_DATA = {
|
|
28
28
|
packageName: "@atlaskit/link-picker" || '',
|
|
29
|
-
packageVersion: "6.0
|
|
29
|
+
packageVersion: "6.1.0" || '',
|
|
30
30
|
componentName: _constants.COMPONENT_NAME,
|
|
31
31
|
source: _constants.COMPONENT_NAME
|
|
32
32
|
};
|
|
@@ -44,6 +44,7 @@ export const FormFooter = /*#__PURE__*/memo(({
|
|
|
44
44
|
customSubmitButtonLabel,
|
|
45
45
|
submitMessageId,
|
|
46
46
|
hideSubmitButton,
|
|
47
|
+
disableManualUrlInsert,
|
|
47
48
|
className,
|
|
48
49
|
...restProps
|
|
49
50
|
}) => {
|
|
@@ -88,6 +89,7 @@ export const FormFooter = /*#__PURE__*/memo(({
|
|
|
88
89
|
queryState: queryState,
|
|
89
90
|
submitMessageId: submitMessageId,
|
|
90
91
|
testId: testIds.insertButton,
|
|
91
|
-
url: url
|
|
92
|
+
url: url,
|
|
93
|
+
disableManualUrlInsert: disableManualUrlInsert
|
|
92
94
|
})));
|
|
93
95
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { defineMessages, useIntl } from 'react-intl';
|
|
3
3
|
import Button from '@atlaskit/button/new';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { checkSubmitDisabled } from './utils';
|
|
5
6
|
export const messages = defineMessages({
|
|
6
7
|
saveButton: {
|
|
@@ -24,11 +25,12 @@ export const LinkPickerSubmitButton = ({
|
|
|
24
25
|
queryState,
|
|
25
26
|
submitMessageId,
|
|
26
27
|
testId,
|
|
27
|
-
url
|
|
28
|
+
url,
|
|
29
|
+
disableManualUrlInsert
|
|
28
30
|
}) => {
|
|
29
31
|
const intl = useIntl();
|
|
30
32
|
const insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
|
|
31
|
-
const isSubmitDisabled = checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items);
|
|
33
|
+
const isSubmitDisabled = checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items, fg('add-disable-manual-url-capability-technical') ? disableManualUrlInsert : undefined);
|
|
32
34
|
return /*#__PURE__*/React.createElement(Button, {
|
|
33
35
|
type: "submit",
|
|
34
36
|
appearance: "primary",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { normalizeUrl } from '@atlaskit/linking-common/url';
|
|
2
|
-
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
export const checkSubmitDisabled = (isLoading, isSubmitting, error, url, queryState, items, disableManualUrlInsert) => {
|
|
3
4
|
/*
|
|
4
5
|
* Enable insert when search term is a valid url and it can be normalized
|
|
5
6
|
* Need to explicitly enable it here otherwise next condition could meet
|
|
@@ -10,6 +11,33 @@ export const checkSubmitDisabled = (isLoading, isSubmitting, error, url, querySt
|
|
|
10
11
|
if (isSubmitting) {
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
14
|
+
if (fg('add-disable-manual-url-capability-technical')) {
|
|
15
|
+
/*
|
|
16
|
+
* Check isLoading/error before disableManualUrlInsert so that stale items
|
|
17
|
+
* from a previous search do not accidentally enable the button during an
|
|
18
|
+
* in-flight request or an error state.
|
|
19
|
+
*/
|
|
20
|
+
if (isLoading || error) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* When disableManualUrlInsert is true, disable insert unless a result has been
|
|
26
|
+
* selected from the list (i.e. items are present and queryState is set).
|
|
27
|
+
* This prevents the user from manually typing a URL to bypass the restriction.
|
|
28
|
+
*/
|
|
29
|
+
if (disableManualUrlInsert) {
|
|
30
|
+
return !(queryState && items && items.length > 0);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Enable insert when search term is a valid url and it can be normalized.
|
|
36
|
+
* Need to explicitly enable it here otherwise next condition could meet.
|
|
37
|
+
*
|
|
38
|
+
* This should effectively be the validation function for the form, ie if the form
|
|
39
|
+
* could be submitted, then it should not be disabled.
|
|
40
|
+
*/
|
|
13
41
|
if (url && normalizeUrl(url)) {
|
|
14
42
|
return false;
|
|
15
43
|
}
|
|
@@ -23,10 +51,10 @@ export const checkSubmitDisabled = (isLoading, isSubmitting, error, url, querySt
|
|
|
23
51
|
}
|
|
24
52
|
|
|
25
53
|
/*
|
|
26
|
-
* Disable insert button when
|
|
27
|
-
*
|
|
54
|
+
* Disable insert button when plugin is loading or for any search error.
|
|
55
|
+
* When the gate is on, this is already handled earlier in the function.
|
|
28
56
|
*/
|
|
29
|
-
if (isLoading || error) {
|
|
57
|
+
if (!fg('add-disable-manual-url-capability-technical') && (isLoading || error)) {
|
|
30
58
|
return true;
|
|
31
59
|
}
|
|
32
60
|
return false;
|
|
@@ -105,9 +105,11 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
105
105
|
submitOnInputChange = false,
|
|
106
106
|
recentSearchListSize,
|
|
107
107
|
shouldRenderNoResultsImage,
|
|
108
|
-
alwaysShowTabs
|
|
108
|
+
alwaysShowTabs,
|
|
109
|
+
disableManualUrlInsert: disableManualUrlInsertProp = false
|
|
109
110
|
}) => {
|
|
110
111
|
var _customMessages$linkH;
|
|
112
|
+
const disableManualUrlInsert = fg('add-disable-manual-url-capability-technical') && disableManualUrlInsertProp;
|
|
111
113
|
const {
|
|
112
114
|
createAnalyticsEvent
|
|
113
115
|
} = useAnalyticsEvents();
|
|
@@ -450,7 +452,8 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
450
452
|
queryState: queryState,
|
|
451
453
|
submitMessageId: submitMessageId,
|
|
452
454
|
testId: testIds.insertButton,
|
|
453
|
-
url: url
|
|
455
|
+
url: url,
|
|
456
|
+
disableManualUrlInsert: disableManualUrlInsert
|
|
454
457
|
})), !!queryState && (isLoadingPlugins || isActivePlugin) && /*#__PURE__*/React.createElement(SearchResults, {
|
|
455
458
|
activeTab: activeTab,
|
|
456
459
|
tabs: tabs,
|
|
@@ -486,6 +489,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
486
489
|
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
487
490
|
submitMessageId: submitMessageId,
|
|
488
491
|
hideSubmitButton: moveSubmitButton || submitOnInputChange,
|
|
492
|
+
disableManualUrlInsert: disableManualUrlInsert,
|
|
489
493
|
className: ax([(!queryState || !(plugins !== null && plugins !== void 0 && plugins.length)) && "_19pkpxbi"])
|
|
490
494
|
}));
|
|
491
495
|
}));
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["isLoading", "isSubmitting", "error", "url", "queryState", "items", "isEditing", "onCancel", "action", "customSubmitButtonLabel", "submitMessageId", "hideSubmitButton", "className"];
|
|
4
|
+
var _excluded = ["isLoading", "isSubmitting", "error", "url", "queryState", "items", "isEditing", "onCancel", "action", "customSubmitButtonLabel", "submitMessageId", "hideSubmitButton", "disableManualUrlInsert", "className"];
|
|
5
5
|
import "./index.compiled.css";
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { ax, ix } from "@compiled/react/runtime";
|
|
@@ -47,6 +47,7 @@ var FormFooter = /*#__PURE__*/memo(function (_ref) {
|
|
|
47
47
|
customSubmitButtonLabel = _ref.customSubmitButtonLabel,
|
|
48
48
|
submitMessageId = _ref.submitMessageId,
|
|
49
49
|
hideSubmitButton = _ref.hideSubmitButton,
|
|
50
|
+
disableManualUrlInsert = _ref.disableManualUrlInsert,
|
|
50
51
|
className = _ref.className,
|
|
51
52
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
52
53
|
var intl = useIntl();
|
|
@@ -94,7 +95,8 @@ var FormFooter = /*#__PURE__*/memo(function (_ref) {
|
|
|
94
95
|
queryState: queryState,
|
|
95
96
|
submitMessageId: submitMessageId,
|
|
96
97
|
testId: testIds.insertButton,
|
|
97
|
-
url: url
|
|
98
|
+
url: url,
|
|
99
|
+
disableManualUrlInsert: disableManualUrlInsert
|
|
98
100
|
})));
|
|
99
101
|
});
|
|
100
102
|
export { FormFooter };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { defineMessages, useIntl } from 'react-intl';
|
|
3
3
|
import Button from '@atlaskit/button/new';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { checkSubmitDisabled } from './utils';
|
|
5
6
|
export var messages = defineMessages({
|
|
6
7
|
saveButton: {
|
|
@@ -24,10 +25,11 @@ export var LinkPickerSubmitButton = function LinkPickerSubmitButton(_ref) {
|
|
|
24
25
|
queryState = _ref.queryState,
|
|
25
26
|
submitMessageId = _ref.submitMessageId,
|
|
26
27
|
testId = _ref.testId,
|
|
27
|
-
url = _ref.url
|
|
28
|
+
url = _ref.url,
|
|
29
|
+
disableManualUrlInsert = _ref.disableManualUrlInsert;
|
|
28
30
|
var intl = useIntl();
|
|
29
31
|
var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
|
|
30
|
-
var isSubmitDisabled = checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items);
|
|
32
|
+
var isSubmitDisabled = checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items, fg('add-disable-manual-url-capability-technical') ? disableManualUrlInsert : undefined);
|
|
31
33
|
return /*#__PURE__*/React.createElement(Button, {
|
|
32
34
|
type: "submit",
|
|
33
35
|
appearance: "primary",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { normalizeUrl } from '@atlaskit/linking-common/url';
|
|
2
|
-
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
export var checkSubmitDisabled = function checkSubmitDisabled(isLoading, isSubmitting, error, url, queryState, items, disableManualUrlInsert) {
|
|
3
4
|
/*
|
|
4
5
|
* Enable insert when search term is a valid url and it can be normalized
|
|
5
6
|
* Need to explicitly enable it here otherwise next condition could meet
|
|
@@ -10,6 +11,33 @@ export var checkSubmitDisabled = function checkSubmitDisabled(isLoading, isSubmi
|
|
|
10
11
|
if (isSubmitting) {
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
14
|
+
if (fg('add-disable-manual-url-capability-technical')) {
|
|
15
|
+
/*
|
|
16
|
+
* Check isLoading/error before disableManualUrlInsert so that stale items
|
|
17
|
+
* from a previous search do not accidentally enable the button during an
|
|
18
|
+
* in-flight request or an error state.
|
|
19
|
+
*/
|
|
20
|
+
if (isLoading || error) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* When disableManualUrlInsert is true, disable insert unless a result has been
|
|
26
|
+
* selected from the list (i.e. items are present and queryState is set).
|
|
27
|
+
* This prevents the user from manually typing a URL to bypass the restriction.
|
|
28
|
+
*/
|
|
29
|
+
if (disableManualUrlInsert) {
|
|
30
|
+
return !(queryState && items && items.length > 0);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Enable insert when search term is a valid url and it can be normalized.
|
|
36
|
+
* Need to explicitly enable it here otherwise next condition could meet.
|
|
37
|
+
*
|
|
38
|
+
* This should effectively be the validation function for the form, ie if the form
|
|
39
|
+
* could be submitted, then it should not be disabled.
|
|
40
|
+
*/
|
|
13
41
|
if (url && normalizeUrl(url)) {
|
|
14
42
|
return false;
|
|
15
43
|
}
|
|
@@ -23,10 +51,10 @@ export var checkSubmitDisabled = function checkSubmitDisabled(isLoading, isSubmi
|
|
|
23
51
|
}
|
|
24
52
|
|
|
25
53
|
/*
|
|
26
|
-
* Disable insert button when
|
|
27
|
-
*
|
|
54
|
+
* Disable insert button when plugin is loading or for any search error.
|
|
55
|
+
* When the gate is on, this is already handled earlier in the function.
|
|
28
56
|
*/
|
|
29
|
-
if (isLoading || error) {
|
|
57
|
+
if (!fg('add-disable-manual-url-capability-technical') && (isLoading || error)) {
|
|
30
58
|
return true;
|
|
31
59
|
}
|
|
32
60
|
return false;
|
|
@@ -110,7 +110,10 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
110
110
|
submitOnInputChange = _ref$submitOnInputCha === void 0 ? false : _ref$submitOnInputCha,
|
|
111
111
|
recentSearchListSize = _ref.recentSearchListSize,
|
|
112
112
|
shouldRenderNoResultsImage = _ref.shouldRenderNoResultsImage,
|
|
113
|
-
alwaysShowTabs = _ref.alwaysShowTabs
|
|
113
|
+
alwaysShowTabs = _ref.alwaysShowTabs,
|
|
114
|
+
_ref$disableManualUrl = _ref.disableManualUrlInsert,
|
|
115
|
+
disableManualUrlInsertProp = _ref$disableManualUrl === void 0 ? false : _ref$disableManualUrl;
|
|
116
|
+
var disableManualUrlInsert = fg('add-disable-manual-url-capability-technical') && disableManualUrlInsertProp;
|
|
114
117
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
115
118
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
116
119
|
var linkInputRef = React.useRef(null);
|
|
@@ -486,7 +489,8 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
486
489
|
queryState: queryState,
|
|
487
490
|
submitMessageId: submitMessageId,
|
|
488
491
|
testId: testIds.insertButton,
|
|
489
|
-
url: url
|
|
492
|
+
url: url,
|
|
493
|
+
disableManualUrlInsert: disableManualUrlInsert
|
|
490
494
|
})), !!queryState && (isLoadingPlugins || isActivePlugin) && /*#__PURE__*/React.createElement(SearchResults, {
|
|
491
495
|
activeTab: activeTab,
|
|
492
496
|
tabs: tabs,
|
|
@@ -522,6 +526,7 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
|
|
|
522
526
|
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
523
527
|
submitMessageId: submitMessageId,
|
|
524
528
|
hideSubmitButton: moveSubmitButton || submitOnInputChange,
|
|
529
|
+
disableManualUrlInsert: disableManualUrlInsert,
|
|
525
530
|
className: ax([(!queryState || !(plugins !== null && plugins !== void 0 && plugins.length)) && "_19pkpxbi"])
|
|
526
531
|
}));
|
|
527
532
|
}));
|
package/dist/esm/ui/main.js
CHANGED
|
@@ -184,6 +184,12 @@ export interface LinkPickerProps {
|
|
|
184
184
|
shouldRenderNoResultsImage?: boolean;
|
|
185
185
|
/** When true, tabs are displayed even if there is only one plugin. */
|
|
186
186
|
alwaysShowTabs?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* When true, disables the Insert button when the user has manually typed a URL but no search
|
|
189
|
+
* result has been selected. This prevents inserting external/manual links when only
|
|
190
|
+
* result-based links are desired.
|
|
191
|
+
*/
|
|
192
|
+
disableManualUrlInsert?: boolean;
|
|
187
193
|
}
|
|
188
194
|
type CustomLinkPickerMessages = {
|
|
189
195
|
/** Label for the link input field */
|
|
@@ -38,6 +38,7 @@ interface FormFooterProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
38
38
|
customSubmitButtonLabel?: MessageDescriptor;
|
|
39
39
|
submitMessageId?: string;
|
|
40
40
|
hideSubmitButton?: boolean;
|
|
41
|
+
disableManualUrlInsert?: boolean;
|
|
41
42
|
}
|
|
42
|
-
export declare const FormFooter: MemoExoticComponent<({ isLoading, isSubmitting, error, url, queryState, items, isEditing, onCancel, action, customSubmitButtonLabel, submitMessageId, hideSubmitButton, className, ...restProps }: FormFooterProps) => JSX.Element | null>;
|
|
43
|
+
export declare const FormFooter: MemoExoticComponent<({ isLoading, isSubmitting, error, url, queryState, items, isEditing, onCancel, action, customSubmitButtonLabel, submitMessageId, hideSubmitButton, disableManualUrlInsert, className, ...restProps }: FormFooterProps) => JSX.Element | null>;
|
|
43
44
|
export {};
|
|
@@ -12,6 +12,7 @@ type LinkPickerButtonGroupProps = {
|
|
|
12
12
|
submitMessageId?: string;
|
|
13
13
|
testId?: string;
|
|
14
14
|
url: string;
|
|
15
|
+
disableManualUrlInsert?: boolean;
|
|
15
16
|
};
|
|
16
17
|
export declare const messages: {
|
|
17
18
|
saveButton: {
|
|
@@ -25,5 +26,5 @@ export declare const messages: {
|
|
|
25
26
|
description: string;
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
|
-
export declare const LinkPickerSubmitButton: ({ isEditing, isLoading, isSubmitting, customSubmitButtonLabel, error, items, queryState, submitMessageId, testId, url, }: LinkPickerButtonGroupProps) => React.JSX.Element;
|
|
29
|
+
export declare const LinkPickerSubmitButton: ({ isEditing, isLoading, isSubmitting, customSubmitButtonLabel, error, items, queryState, submitMessageId, testId, url, disableManualUrlInsert, }: LinkPickerButtonGroupProps) => React.JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type LinkPickerState, type LinkSearchListItemData } from '../../../../common/types';
|
|
2
|
-
export declare const checkSubmitDisabled: (isLoading: boolean, isSubmitting: boolean, error: unknown | null, url: string, queryState: LinkPickerState | null, items: LinkSearchListItemData[] | null) => boolean;
|
|
2
|
+
export declare const checkSubmitDisabled: (isLoading: boolean, isSubmitting: boolean, error: unknown | null, url: string, queryState: LinkPickerState | null, items: LinkSearchListItemData[] | null, disableManualUrlInsert?: boolean) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-picker",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"react-compiler": {
|
|
12
12
|
"enabled": true,
|
|
13
13
|
"gating": {
|
|
14
|
-
"source": "@
|
|
14
|
+
"source": "@atlaskit/react-compiler-gating",
|
|
15
15
|
"importSpecifierName": "isReactCompilerActivePlatform"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"navx-4104-link-picker-a11y-focus-states": {
|
|
41
41
|
"type": "boolean"
|
|
42
|
+
},
|
|
43
|
+
"add-disable-manual-url-capability-technical": {
|
|
44
|
+
"type": "boolean"
|
|
42
45
|
}
|
|
43
46
|
},
|
|
44
47
|
"scripts": {
|
|
@@ -46,30 +49,30 @@
|
|
|
46
49
|
},
|
|
47
50
|
"dependencies": {
|
|
48
51
|
"@atlaskit/afm-i18n-platform-linking-platform-link-picker": "2.7.0",
|
|
49
|
-
"@atlaskit/analytics-next": "^12.
|
|
52
|
+
"@atlaskit/analytics-next": "^12.1.0",
|
|
50
53
|
"@atlaskit/atlassian-context": "^1.0.0",
|
|
51
|
-
"@atlaskit/button": "^24.
|
|
54
|
+
"@atlaskit/button": "^24.2.0",
|
|
52
55
|
"@atlaskit/css": "^1.0.0",
|
|
53
|
-
"@atlaskit/form": "^16.
|
|
54
|
-
"@atlaskit/frontend-utilities": "^4.
|
|
55
|
-
"@atlaskit/heading": "^6.
|
|
56
|
-
"@atlaskit/icon": "^36.
|
|
57
|
-
"@atlaskit/intl-messages-provider": "^4.
|
|
58
|
-
"@atlaskit/link": "^4.
|
|
59
|
-
"@atlaskit/link-provider": "^5.
|
|
56
|
+
"@atlaskit/form": "^16.1.0",
|
|
57
|
+
"@atlaskit/frontend-utilities": "^4.1.0",
|
|
58
|
+
"@atlaskit/heading": "^6.1.0",
|
|
59
|
+
"@atlaskit/icon": "^36.1.0",
|
|
60
|
+
"@atlaskit/intl-messages-provider": "^4.1.0",
|
|
61
|
+
"@atlaskit/link": "^4.1.0",
|
|
62
|
+
"@atlaskit/link-provider": "^5.1.0",
|
|
60
63
|
"@atlaskit/linking-common": "^11.0.0",
|
|
61
64
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
62
|
-
"@atlaskit/primitives": "^20.
|
|
63
|
-
"@atlaskit/
|
|
64
|
-
"@atlaskit/
|
|
65
|
-
"@atlaskit/
|
|
66
|
-
"@atlaskit/
|
|
67
|
-
"@atlaskit/
|
|
68
|
-
"@atlaskit/
|
|
69
|
-
"@atlaskit/
|
|
65
|
+
"@atlaskit/primitives": "^20.1.0",
|
|
66
|
+
"@atlaskit/react-compiler-gating": "^0.2.0",
|
|
67
|
+
"@atlaskit/smart-card": "^45.5.0",
|
|
68
|
+
"@atlaskit/spinner": "^20.1.0",
|
|
69
|
+
"@atlaskit/spotlight": "^2.1.0",
|
|
70
|
+
"@atlaskit/tabs": "^20.1.0",
|
|
71
|
+
"@atlaskit/textfield": "^9.1.0",
|
|
72
|
+
"@atlaskit/tokens": "^15.1.0",
|
|
73
|
+
"@atlaskit/tooltip": "^23.1.0",
|
|
70
74
|
"@atlaskit/ufo": "^1.0.0",
|
|
71
|
-
"@atlaskit/visually-hidden": "^4.
|
|
72
|
-
"@atlassian/react-compiler-gating": "^0.2.0",
|
|
75
|
+
"@atlaskit/visually-hidden": "^4.1.0",
|
|
73
76
|
"@babel/runtime": "^7.0.0",
|
|
74
77
|
"@compiled/react": "^0.20.0",
|
|
75
78
|
"@react-loosely-lazy/manifest": "^1.0.0",
|
|
@@ -87,9 +90,9 @@
|
|
|
87
90
|
"@af/analytics-codegen": "workspace:^",
|
|
88
91
|
"@af/integration-testing": "workspace:^",
|
|
89
92
|
"@af/visual-regression": "workspace:^",
|
|
90
|
-
"@atlaskit/dropdown-menu": "^17.
|
|
93
|
+
"@atlaskit/dropdown-menu": "^17.1.0",
|
|
91
94
|
"@atlaskit/link-test-helpers": "^11.0.0",
|
|
92
|
-
"@atlassian/a11y-jest-testing": "^0.
|
|
95
|
+
"@atlassian/a11y-jest-testing": "^0.13.0",
|
|
93
96
|
"@atlassian/a11y-playwright-testing": "^0.10.0",
|
|
94
97
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|
|
95
98
|
"@atlassian/structured-docs-types": "workspace:^",
|