@atlaskit/smart-card 26.9.15 → 26.9.17
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 +13 -0
- package/dist/cjs/state/helpers.js +1 -21
- package/dist/cjs/state/hooks/use-resolve/index.js +1 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +5 -2
- package/dist/cjs/view/InlineCard/Icon.js +0 -2
- package/dist/cjs/view/RedesignedInlineCard/ErroredView/index.js +90 -0
- package/dist/cjs/view/RedesignedInlineCard/ForbiddenView/index.js +129 -0
- package/dist/cjs/view/RedesignedInlineCard/Frame/index.js +63 -0
- package/dist/cjs/view/RedesignedInlineCard/Frame/styled.js +70 -0
- package/dist/cjs/view/RedesignedInlineCard/Icon.js +43 -0
- package/dist/cjs/view/RedesignedInlineCard/IconAndTitleLayout/index.js +151 -0
- package/dist/cjs/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +56 -0
- package/dist/cjs/view/RedesignedInlineCard/ResolvedView/index.js +83 -0
- package/dist/cjs/view/RedesignedInlineCard/ResolvingView/index.js +69 -0
- package/dist/cjs/view/RedesignedInlineCard/ResolvingView/styled.js +13 -0
- package/dist/cjs/view/RedesignedInlineCard/UnauthorisedView/index.js +113 -0
- package/dist/cjs/view/RedesignedInlineCard/index.js +183 -0
- package/dist/cjs/view/RedesignedInlineCard/styled.js +31 -0
- package/dist/cjs/view/RedesignedInlineCard/types.js +5 -0
- package/dist/cjs/view/RedesignedInlineCard/utils/withFrameStyleControl.js +42 -0
- package/dist/es2019/state/helpers.js +0 -22
- package/dist/es2019/state/hooks/use-resolve/index.js +1 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +5 -2
- package/dist/es2019/view/InlineCard/Icon.js +0 -2
- package/dist/es2019/view/RedesignedInlineCard/ErroredView/index.js +66 -0
- package/dist/es2019/view/RedesignedInlineCard/ForbiddenView/index.js +107 -0
- package/dist/es2019/view/RedesignedInlineCard/Frame/index.js +55 -0
- package/dist/es2019/view/RedesignedInlineCard/Frame/styled.js +107 -0
- package/dist/es2019/view/RedesignedInlineCard/Icon.js +45 -0
- package/dist/es2019/view/RedesignedInlineCard/IconAndTitleLayout/index.js +124 -0
- package/dist/es2019/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +97 -0
- package/dist/es2019/view/RedesignedInlineCard/ResolvedView/index.js +55 -0
- package/dist/es2019/view/RedesignedInlineCard/ResolvingView/index.js +44 -0
- package/dist/es2019/view/RedesignedInlineCard/ResolvingView/styled.js +6 -0
- package/dist/es2019/view/RedesignedInlineCard/UnauthorisedView/index.js +86 -0
- package/dist/es2019/view/RedesignedInlineCard/index.js +149 -0
- package/dist/es2019/view/RedesignedInlineCard/styled.js +52 -0
- package/dist/es2019/view/RedesignedInlineCard/types.js +1 -0
- package/dist/es2019/view/RedesignedInlineCard/utils/withFrameStyleControl.js +33 -0
- package/dist/esm/state/helpers.js +0 -19
- package/dist/esm/state/hooks/use-resolve/index.js +1 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +5 -2
- package/dist/esm/view/InlineCard/Icon.js +0 -2
- package/dist/esm/view/RedesignedInlineCard/ErroredView/index.js +82 -0
- package/dist/esm/view/RedesignedInlineCard/ForbiddenView/index.js +121 -0
- package/dist/esm/view/RedesignedInlineCard/Frame/index.js +53 -0
- package/dist/esm/view/RedesignedInlineCard/Frame/styled.js +61 -0
- package/dist/esm/view/RedesignedInlineCard/Icon.js +34 -0
- package/dist/esm/view/RedesignedInlineCard/IconAndTitleLayout/index.js +143 -0
- package/dist/esm/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +38 -0
- package/dist/esm/view/RedesignedInlineCard/ResolvedView/index.js +75 -0
- package/dist/esm/view/RedesignedInlineCard/ResolvingView/index.js +61 -0
- package/dist/esm/view/RedesignedInlineCard/ResolvingView/styled.js +5 -0
- package/dist/esm/view/RedesignedInlineCard/UnauthorisedView/index.js +105 -0
- package/dist/esm/view/RedesignedInlineCard/index.js +146 -0
- package/dist/esm/view/RedesignedInlineCard/styled.js +20 -0
- package/dist/esm/view/RedesignedInlineCard/types.js +1 -0
- package/dist/esm/view/RedesignedInlineCard/utils/withFrameStyleControl.js +35 -0
- package/dist/types/state/helpers.d.ts +0 -1
- package/dist/types/view/RedesignedInlineCard/ErroredView/index.d.ts +22 -0
- package/dist/types/view/RedesignedInlineCard/ForbiddenView/index.d.ts +29 -0
- package/dist/types/view/RedesignedInlineCard/Frame/index.d.ts +15 -0
- package/dist/types/view/RedesignedInlineCard/Frame/styled.d.ts +15 -0
- package/dist/types/view/RedesignedInlineCard/Icon.d.ts +12 -0
- package/dist/types/view/RedesignedInlineCard/IconAndTitleLayout/index.d.ts +28 -0
- package/dist/types/view/RedesignedInlineCard/IconAndTitleLayout/styled.d.ts +36 -0
- package/dist/types/view/RedesignedInlineCard/ResolvedView/index.d.ts +32 -0
- package/dist/types/view/RedesignedInlineCard/ResolvingView/index.d.ts +17 -0
- package/dist/types/view/RedesignedInlineCard/ResolvingView/styled.d.ts +9 -0
- package/dist/types/view/RedesignedInlineCard/UnauthorisedView/index.d.ts +32 -0
- package/dist/types/view/RedesignedInlineCard/index.d.ts +9 -0
- package/dist/types/view/RedesignedInlineCard/styled.d.ts +17 -0
- package/dist/types/view/RedesignedInlineCard/types.d.ts +25 -0
- package/dist/types/view/RedesignedInlineCard/utils/withFrameStyleControl.d.ts +9 -0
- package/dist/types-ts4.5/state/helpers.d.ts +0 -1
- package/dist/types-ts4.5/view/RedesignedInlineCard/ErroredView/index.d.ts +22 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/ForbiddenView/index.d.ts +29 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/Frame/index.d.ts +15 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/Frame/styled.d.ts +15 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/Icon.d.ts +12 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/IconAndTitleLayout/index.d.ts +28 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/IconAndTitleLayout/styled.d.ts +36 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvedView/index.d.ts +32 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvingView/index.d.ts +17 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvingView/styled.d.ts +9 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/UnauthorisedView/index.d.ts +32 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/index.d.ts +9 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/styled.d.ts +17 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/types.d.ts +25 -0
- package/dist/types-ts4.5/view/RedesignedInlineCard/utils/withFrameStyleControl.d.ts +9 -0
- package/package.json +7 -4
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.InlineCard = void 0;
|
|
8
|
+
Object.defineProperty(exports, "InlineCardErroredView", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _ErroredView.InlineCardErroredView;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "InlineCardForbiddenView", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _ForbiddenView.InlineCardForbiddenView;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "InlineCardResolvedView", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _ResolvedView.InlineCardResolvedView;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "InlineCardResolvingView", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _ResolvingView.InlineCardResolvingView;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "InlineCardUnauthorizedView", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _UnauthorisedView.InlineCardUnauthorizedView;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
39
|
+
var _react = _interopRequireDefault(require("react"));
|
|
40
|
+
var _jsonld = require("../../utils/jsonld");
|
|
41
|
+
var _inline = require("../../extractors/inline");
|
|
42
|
+
var _context = require("../../extractors/common/context");
|
|
43
|
+
var _LinkView = require("../LinkView");
|
|
44
|
+
var _ErroredView = require("./ErroredView");
|
|
45
|
+
var _ForbiddenView = require("./ForbiddenView");
|
|
46
|
+
var _ResolvedView = require("./ResolvedView");
|
|
47
|
+
var _ResolvingView = require("./ResolvingView");
|
|
48
|
+
var _UnauthorisedView = require("./UnauthorisedView");
|
|
49
|
+
var _linkExtractors = require("@atlaskit/link-extractors");
|
|
50
|
+
var _linkProvider = require("@atlaskit/link-provider");
|
|
51
|
+
var _helpers = require("../../state/helpers");
|
|
52
|
+
var InlineCard = function InlineCard(_ref) {
|
|
53
|
+
var _details$meta;
|
|
54
|
+
var analytics = _ref.analytics,
|
|
55
|
+
id = _ref.id,
|
|
56
|
+
url = _ref.url,
|
|
57
|
+
cardState = _ref.cardState,
|
|
58
|
+
handleAuthorize = _ref.handleAuthorize,
|
|
59
|
+
handleFrameClick = _ref.handleFrameClick,
|
|
60
|
+
isSelected = _ref.isSelected,
|
|
61
|
+
renderers = _ref.renderers,
|
|
62
|
+
onResolve = _ref.onResolve,
|
|
63
|
+
onError = _ref.onError,
|
|
64
|
+
testId = _ref.testId,
|
|
65
|
+
inlinePreloaderStyle = _ref.inlinePreloaderStyle,
|
|
66
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
67
|
+
showAuthTooltip = _ref.showAuthTooltip,
|
|
68
|
+
showServerActions = _ref.showServerActions;
|
|
69
|
+
var status = cardState.status,
|
|
70
|
+
details = cardState.details;
|
|
71
|
+
var cardDetails = details && details.data || (0, _jsonld.getEmptyJsonLd)();
|
|
72
|
+
var extensionKey = (0, _helpers.getExtensionKey)(details);
|
|
73
|
+
var testIdWithStatus = testId ? "".concat(testId, "-").concat(status, "-view") : undefined;
|
|
74
|
+
var showHoverPreviewFlag = (0, _linkProvider.useFeatureFlag)('showHoverPreview');
|
|
75
|
+
if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
|
|
76
|
+
showHoverPreview = Boolean(showHoverPreviewFlag);
|
|
77
|
+
}
|
|
78
|
+
switch (status) {
|
|
79
|
+
case 'pending':
|
|
80
|
+
case 'resolving':
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_ResolvingView.InlineCardResolvingView, {
|
|
82
|
+
url: url,
|
|
83
|
+
isSelected: isSelected,
|
|
84
|
+
onClick: handleFrameClick,
|
|
85
|
+
testId: testIdWithStatus,
|
|
86
|
+
inlinePreloaderStyle: inlinePreloaderStyle
|
|
87
|
+
});
|
|
88
|
+
case 'resolved':
|
|
89
|
+
var resolvedProps = (0, _inline.extractInlineProps)(cardDetails, renderers);
|
|
90
|
+
if (onResolve) {
|
|
91
|
+
onResolve({
|
|
92
|
+
url: url,
|
|
93
|
+
title: resolvedProps.title
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return /*#__PURE__*/_react.default.createElement(_ResolvedView.InlineCardResolvedView, (0, _extends2.default)({}, resolvedProps, {
|
|
97
|
+
id: id,
|
|
98
|
+
showHoverPreview: showHoverPreview,
|
|
99
|
+
showServerActions: showServerActions,
|
|
100
|
+
link: url,
|
|
101
|
+
isSelected: isSelected,
|
|
102
|
+
onClick: handleFrameClick,
|
|
103
|
+
testId: testIdWithStatus
|
|
104
|
+
}));
|
|
105
|
+
case 'unauthorized':
|
|
106
|
+
if (onError) {
|
|
107
|
+
onError({
|
|
108
|
+
url: url,
|
|
109
|
+
status: status
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
var provider = (0, _linkExtractors.extractProvider)(cardDetails);
|
|
113
|
+
return /*#__PURE__*/_react.default.createElement(_UnauthorisedView.InlineCardUnauthorizedView, {
|
|
114
|
+
icon: provider && provider.icon,
|
|
115
|
+
context: provider && provider.text,
|
|
116
|
+
url: url,
|
|
117
|
+
isSelected: isSelected,
|
|
118
|
+
onClick: handleFrameClick,
|
|
119
|
+
onAuthorise: handleAuthorize,
|
|
120
|
+
testId: testIdWithStatus,
|
|
121
|
+
showAuthTooltip: showAuthTooltip,
|
|
122
|
+
id: id,
|
|
123
|
+
analytics: analytics,
|
|
124
|
+
extensionKey: extensionKey
|
|
125
|
+
});
|
|
126
|
+
case 'forbidden':
|
|
127
|
+
if (onError) {
|
|
128
|
+
onError({
|
|
129
|
+
url: url,
|
|
130
|
+
status: status
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
var providerForbidden = (0, _linkExtractors.extractProvider)(cardDetails);
|
|
134
|
+
var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : (0, _jsonld.getForbiddenJsonLd)().meta;
|
|
135
|
+
var requestAccessContext = (0, _context.extractRequestAccessContext)({
|
|
136
|
+
jsonLd: cardMetadata,
|
|
137
|
+
url: url,
|
|
138
|
+
context: providerForbidden === null || providerForbidden === void 0 ? void 0 : providerForbidden.text
|
|
139
|
+
});
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement(_ForbiddenView.InlineCardForbiddenView, {
|
|
141
|
+
url: url,
|
|
142
|
+
icon: providerForbidden && providerForbidden.icon,
|
|
143
|
+
context: providerForbidden === null || providerForbidden === void 0 ? void 0 : providerForbidden.text,
|
|
144
|
+
isSelected: isSelected,
|
|
145
|
+
onClick: handleFrameClick,
|
|
146
|
+
onAuthorise: handleAuthorize,
|
|
147
|
+
testId: testIdWithStatus,
|
|
148
|
+
requestAccessContext: requestAccessContext
|
|
149
|
+
});
|
|
150
|
+
case 'not_found':
|
|
151
|
+
if (onError) {
|
|
152
|
+
onError({
|
|
153
|
+
url: url,
|
|
154
|
+
status: status
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
var providerNotFound = (0, _linkExtractors.extractProvider)(cardDetails);
|
|
158
|
+
return /*#__PURE__*/_react.default.createElement(_ErroredView.InlineCardErroredView, {
|
|
159
|
+
url: url,
|
|
160
|
+
icon: providerNotFound && providerNotFound.icon,
|
|
161
|
+
isSelected: isSelected,
|
|
162
|
+
message: "Can't find link",
|
|
163
|
+
onClick: handleFrameClick,
|
|
164
|
+
testId: testIdWithStatus || 'inline-card-not-found-view'
|
|
165
|
+
});
|
|
166
|
+
case 'fallback':
|
|
167
|
+
case 'errored':
|
|
168
|
+
default:
|
|
169
|
+
if (onError) {
|
|
170
|
+
onError({
|
|
171
|
+
url: url,
|
|
172
|
+
status: status
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return /*#__PURE__*/_react.default.createElement(_LinkView.CardLinkView, {
|
|
176
|
+
link: url,
|
|
177
|
+
isSelected: isSelected,
|
|
178
|
+
onClick: handleFrameClick,
|
|
179
|
+
testId: testIdWithStatus || 'inline-card-errored-view'
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
exports.InlineCard = InlineCard;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.NoLinkAppearance = exports.LowercaseAppearance = exports.LinkAppearance = exports.IconStyledButton = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
11
|
+
var _components = require("@atlaskit/theme/components");
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
13
|
+
var LINK_COLOR_DARK = '#4794FF';
|
|
14
|
+
|
|
15
|
+
// By default buttons will hide overflow and ellipsis content instead of wrapping.
|
|
16
|
+
// This basically turns the button back into inline content
|
|
17
|
+
// There is a workaround for negative token spacing suggested by the design system team. calc(${token} * -1)
|
|
18
|
+
var IconStyledButton = _styled.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n &&& {\n text-align: initial;\n display: inline;\n vertical-align: baseline;\n border-radius: ", ";\n border-top-left-radius: 0px;\n border-bottom-left-radius: 0px;\n padding: ", " ", ";\n background-clip: padding-box;\n box-decoration-break: clone;\n }\n > span {\n display: inline;\n overflow: initial;\n text-overflow: initial;\n white-space: initial;\n > span {\n overflow: initial;\n text-overflow: initial;\n white-space: initial;\n }\n }\n"])), "var(--ds-border-radius-100, 2px)", "var(--ds-space-025, 2px)", "var(--ds-space-075, 6px)");
|
|
19
|
+
exports.IconStyledButton = IconStyledButton;
|
|
20
|
+
var NoLinkAppearance = _styled.default.span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n margin-left: ", ";\n"])), (0, _components.themed)({
|
|
21
|
+
light: "var(--ds-text-subtlest, ".concat(_colors.N200, ")"),
|
|
22
|
+
dark: "var(--ds-text-subtlest, ".concat(LINK_COLOR_DARK, ")")
|
|
23
|
+
}), "var(--ds-space-050, 4px)");
|
|
24
|
+
exports.NoLinkAppearance = NoLinkAppearance;
|
|
25
|
+
var LowercaseAppearance = _styled.default.span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n text-transform: lowercase;\n"])));
|
|
26
|
+
exports.LowercaseAppearance = LowercaseAppearance;
|
|
27
|
+
var LinkAppearance = _styled.default.a(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n\n &:hover {\n text-decoration: none;\n }\n"])), (0, _components.themed)({
|
|
28
|
+
light: "var(--ds-link, ".concat(_colors.B400, ")"),
|
|
29
|
+
dark: "var(--ds-link, ".concat(LINK_COLOR_DARK, ")")
|
|
30
|
+
}));
|
|
31
|
+
exports.LinkAppearance = LinkAppearance;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _components = require("@atlaskit/theme/components");
|
|
11
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
12
|
+
/**
|
|
13
|
+
* This HOC serves as a temporary workaround for controlling the style of a parent component.
|
|
14
|
+
* We do not want the Frame to have a hover state when hovering over the action button.
|
|
15
|
+
* TODO: When Firefox begins supporting the :has()pseudo-selector (e.g "frame:has(button:hover){...}"),
|
|
16
|
+
* it should be used instead and the code should be cleaned up.
|
|
17
|
+
*/
|
|
18
|
+
var _default = function _default(Button, frameRef) {
|
|
19
|
+
return function (props) {
|
|
20
|
+
var setBorderStyle = function setBorderStyle() {
|
|
21
|
+
var borderColor = (0, _components.themed)({
|
|
22
|
+
light: "".concat("var(--ds-border-input, ".concat(_colors.N40, ")")),
|
|
23
|
+
dark: "".concat("var(--ds-border-input, ".concat(_colors.N500, ")"))
|
|
24
|
+
})();
|
|
25
|
+
var frameNode = frameRef.current;
|
|
26
|
+
if (frameNode) {
|
|
27
|
+
frameNode.style.borderColor = borderColor;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var removeBorderStyle = function removeBorderStyle() {
|
|
31
|
+
var frameNode = frameRef.current;
|
|
32
|
+
if (frameNode) {
|
|
33
|
+
frameNode.removeAttribute('style');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(Button, (0, _extends2.default)({}, props, {
|
|
37
|
+
onMouseEnter: setBorderStyle,
|
|
38
|
+
onMouseLeave: removeBorderStyle
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.default = _default;
|
|
@@ -49,28 +49,6 @@ export const isVisible = ({
|
|
|
49
49
|
visibility
|
|
50
50
|
}
|
|
51
51
|
}) => visibility === 'restricted' || visibility === 'public';
|
|
52
|
-
|
|
53
|
-
// Be aware, this is a copy of a function in link-provider/src/helpers
|
|
54
|
-
export const getStatus = ({
|
|
55
|
-
meta
|
|
56
|
-
}) => {
|
|
57
|
-
const {
|
|
58
|
-
access,
|
|
59
|
-
visibility
|
|
60
|
-
} = meta;
|
|
61
|
-
switch (access) {
|
|
62
|
-
case 'forbidden':
|
|
63
|
-
if (visibility === 'not_found') {
|
|
64
|
-
return 'not_found';
|
|
65
|
-
} else {
|
|
66
|
-
return 'forbidden';
|
|
67
|
-
}
|
|
68
|
-
case 'unauthorized':
|
|
69
|
-
return 'unauthorized';
|
|
70
|
-
default:
|
|
71
|
-
return 'resolved';
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
52
|
export const getStatusDetails = details => {
|
|
75
53
|
var _details$meta6, _details$meta6$reques;
|
|
76
54
|
return details === null || details === void 0 ? void 0 : (_details$meta6 = details.meta) === null || _details$meta6 === void 0 ? void 0 : (_details$meta6$reques = _details$meta6.requestAccess) === null || _details$meta6$reques === void 0 ? void 0 : _details$meta6$reques.accessType;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { unstable_batchedUpdates } from 'react-dom';
|
|
3
3
|
import { addMetadataToExperience } from '../../analytics';
|
|
4
|
-
import { getStatus } from '
|
|
5
|
-
import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction } from '@atlaskit/linking-common';
|
|
4
|
+
import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction, getStatus } from '@atlaskit/linking-common';
|
|
6
5
|
import { ERROR_MESSAGE_FATAL, ERROR_MESSAGE_METADATA, ERROR_MESSAGE_OAUTH } from '../../actions/constants';
|
|
7
6
|
import { getUnauthorizedJsonLd } from '../../../utils/jsonld';
|
|
8
7
|
import { SmartLinkStatus } from '../../../constants';
|
package/dist/es2019/version.json
CHANGED
|
@@ -7,6 +7,8 @@ import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceTyp
|
|
|
7
7
|
import { useSmartLink } from '../../state';
|
|
8
8
|
import { BlockCard } from '../BlockCard';
|
|
9
9
|
import { InlineCard } from '../InlineCard';
|
|
10
|
+
import { InlineCard as RedesignedInlineCard } from '../RedesignedInlineCard';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
12
|
import { EmbedCard } from '../EmbedCard';
|
|
11
13
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
12
14
|
import FlexibleCard from '../FlexibleCard';
|
|
@@ -192,7 +194,7 @@ function Component({
|
|
|
192
194
|
}
|
|
193
195
|
switch (appearance) {
|
|
194
196
|
case 'inline':
|
|
195
|
-
|
|
197
|
+
const inlineProps = {
|
|
196
198
|
analytics: analytics,
|
|
197
199
|
id: id,
|
|
198
200
|
url: url,
|
|
@@ -208,7 +210,8 @@ function Component({
|
|
|
208
210
|
showHoverPreview: showHoverPreview,
|
|
209
211
|
showAuthTooltip: showAuthTooltip,
|
|
210
212
|
showServerActions: showServerActions
|
|
211
|
-
}
|
|
213
|
+
};
|
|
214
|
+
return getBooleanFF('platform.linking-platform.smart-card.show-inline-card-refreshed-design') ? /*#__PURE__*/React.createElement(RedesignedInlineCard, inlineProps) : /*#__PURE__*/React.createElement(InlineCard, inlineProps);
|
|
212
215
|
case 'block':
|
|
213
216
|
return /*#__PURE__*/React.createElement(BlockCard, {
|
|
214
217
|
id: id,
|
|
@@ -30,9 +30,7 @@ export const Shimmer = ({
|
|
|
30
30
|
}) => {
|
|
31
31
|
const skeletonCustomStyles = {
|
|
32
32
|
position: 'absolute',
|
|
33
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
34
33
|
top: '50%',
|
|
35
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
36
34
|
left: '50%',
|
|
37
35
|
transform: 'translate(-50%, -50%)',
|
|
38
36
|
marginRight: "var(--ds-space-050, 4px)"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { R300 } from '@atlaskit/theme/colors';
|
|
4
|
+
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
5
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
6
|
+
import { Frame } from '../Frame';
|
|
7
|
+
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
8
|
+
import { AKIconWrapper } from '../Icon';
|
|
9
|
+
import { messages } from '../../../messages';
|
|
10
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
11
|
+
import { IconStyledButton } from '../styled';
|
|
12
|
+
import withFrameStyleControl from '../utils/withFrameStyleControl';
|
|
13
|
+
export class InlineCardErroredView extends React.Component {
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
16
|
+
_defineProperty(this, "frameRef", /*#__PURE__*/React.createRef());
|
|
17
|
+
_defineProperty(this, "handleRetry", event => {
|
|
18
|
+
const {
|
|
19
|
+
onRetry
|
|
20
|
+
} = this.props;
|
|
21
|
+
if (onRetry) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
onRetry();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
_defineProperty(this, "renderActionButton", () => {
|
|
28
|
+
const {
|
|
29
|
+
onRetry
|
|
30
|
+
} = this.props;
|
|
31
|
+
const ActionButton = withFrameStyleControl(Button, this.frameRef);
|
|
32
|
+
return onRetry && /*#__PURE__*/React.createElement(ActionButton, {
|
|
33
|
+
spacing: "none",
|
|
34
|
+
component: IconStyledButton,
|
|
35
|
+
onClick: this.handleRetry,
|
|
36
|
+
role: "button"
|
|
37
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.try_again));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
const {
|
|
42
|
+
url,
|
|
43
|
+
onClick,
|
|
44
|
+
isSelected,
|
|
45
|
+
testId = 'inline-card-errored-view',
|
|
46
|
+
icon,
|
|
47
|
+
message
|
|
48
|
+
} = this.props;
|
|
49
|
+
return /*#__PURE__*/React.createElement(Frame, {
|
|
50
|
+
testId: testId,
|
|
51
|
+
isSelected: isSelected,
|
|
52
|
+
ref: this.frameRef
|
|
53
|
+
}, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
|
|
54
|
+
icon: icon || /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(ErrorIcon, {
|
|
55
|
+
label: "error",
|
|
56
|
+
size: "small",
|
|
57
|
+
primaryColor: `var(--ds-icon-danger, ${R300})`,
|
|
58
|
+
testId: "errored-view-default-icon"
|
|
59
|
+
})),
|
|
60
|
+
link: url,
|
|
61
|
+
title: url,
|
|
62
|
+
onClick: onClick,
|
|
63
|
+
rightSide: message
|
|
64
|
+
}), this.renderActionButton());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { R400, N500 } from '@atlaskit/theme/colors';
|
|
5
|
+
import LockIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
6
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
7
|
+
import { Frame } from '../Frame';
|
|
8
|
+
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
9
|
+
import { AKIconWrapper } from '../Icon';
|
|
10
|
+
import { messages } from '../../../messages';
|
|
11
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
12
|
+
import { IconStyledButton } from '../styled';
|
|
13
|
+
import Lozenge from '@atlaskit/lozenge';
|
|
14
|
+
import { LozengeWrapper } from '../IconAndTitleLayout/styled';
|
|
15
|
+
import withFrameStyleControl from '../utils/withFrameStyleControl';
|
|
16
|
+
const FallbackForbiddenIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
17
|
+
label: "error",
|
|
18
|
+
size: "small",
|
|
19
|
+
primaryColor: `var(--ds-icon-danger, ${R400})`,
|
|
20
|
+
testId: "forbidden-view-fallback-icon"
|
|
21
|
+
}));
|
|
22
|
+
export class InlineCardForbiddenView extends React.Component {
|
|
23
|
+
constructor(...args) {
|
|
24
|
+
var _this$props, _this$props$requestAc;
|
|
25
|
+
super(...args);
|
|
26
|
+
_defineProperty(this, "frameRef", /*#__PURE__*/React.createRef());
|
|
27
|
+
_defineProperty(this, "state", {
|
|
28
|
+
hasRequestAccessContextMessage: !!((_this$props = this.props) !== null && _this$props !== void 0 && (_this$props$requestAc = _this$props.requestAccessContext) !== null && _this$props$requestAc !== void 0 && _this$props$requestAc.callToActionMessageKey)
|
|
29
|
+
});
|
|
30
|
+
_defineProperty(this, "handleRetry", event => {
|
|
31
|
+
const {
|
|
32
|
+
onAuthorise
|
|
33
|
+
} = this.props;
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
if (onAuthorise) {
|
|
37
|
+
onAuthorise();
|
|
38
|
+
} else {
|
|
39
|
+
var _this$props2, _this$props2$requestA, _this$props2$requestA2;
|
|
40
|
+
(_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$requestA = _this$props2.requestAccessContext) === null || _this$props2$requestA === void 0 ? void 0 : (_this$props2$requestA2 = _this$props2$requestA.action) === null || _this$props2$requestA2 === void 0 ? void 0 : _this$props2$requestA2.promise();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
_defineProperty(this, "renderForbiddenAccessMessage", () => {
|
|
44
|
+
var _this$props3, _this$props3$requestA;
|
|
45
|
+
if ((_this$props3 = this.props) !== null && _this$props3 !== void 0 && (_this$props3$requestA = _this$props3.requestAccessContext) !== null && _this$props3$requestA !== void 0 && _this$props3$requestA.callToActionMessageKey) {
|
|
46
|
+
const {
|
|
47
|
+
callToActionMessageKey
|
|
48
|
+
} = this.props.requestAccessContext;
|
|
49
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[callToActionMessageKey], {
|
|
50
|
+
values: {
|
|
51
|
+
context: this.props.context
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.invalid_permissions, formattedMessage => {
|
|
56
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formattedMessage);
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
_defineProperty(this, "renderActionButton", () => {
|
|
60
|
+
const {
|
|
61
|
+
onAuthorise
|
|
62
|
+
} = this.props;
|
|
63
|
+
const ActionButton = withFrameStyleControl(Button, this.frameRef);
|
|
64
|
+
if (this.state.hasRequestAccessContextMessage) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(ActionButton, {
|
|
66
|
+
spacing: "none",
|
|
67
|
+
onClick: this.handleRetry,
|
|
68
|
+
component: IconStyledButton,
|
|
69
|
+
testId: "button-connect-other-account",
|
|
70
|
+
role: "button"
|
|
71
|
+
}, this.renderForbiddenAccessMessage());
|
|
72
|
+
}
|
|
73
|
+
if (onAuthorise) {
|
|
74
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
75
|
+
spacing: "none",
|
|
76
|
+
onClick: this.handleRetry,
|
|
77
|
+
appearance: "subtle-link",
|
|
78
|
+
testId: "button-connect-other-account",
|
|
79
|
+
role: "button"
|
|
80
|
+
}, /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
|
|
81
|
+
appearance: 'moved'
|
|
82
|
+
}, this.renderForbiddenAccessMessage())));
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
const {
|
|
89
|
+
url,
|
|
90
|
+
icon,
|
|
91
|
+
onClick,
|
|
92
|
+
isSelected,
|
|
93
|
+
testId = 'inline-card-forbidden-view'
|
|
94
|
+
} = this.props;
|
|
95
|
+
return /*#__PURE__*/React.createElement(Frame, {
|
|
96
|
+
testId: testId,
|
|
97
|
+
isSelected: isSelected,
|
|
98
|
+
ref: this.frameRef
|
|
99
|
+
}, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
|
|
100
|
+
icon: icon ? icon : FallbackForbiddenIcon,
|
|
101
|
+
link: url,
|
|
102
|
+
title: url,
|
|
103
|
+
onClick: onClick,
|
|
104
|
+
titleColor: `var(--ds-text-subtle, ${N500})`
|
|
105
|
+
}), this.renderActionButton());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useCallback, forwardRef } from 'react';
|
|
2
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
3
|
+
import { WrapperAnchor, WrapperSpan } from './styled';
|
|
4
|
+
import { useMouseDownEvent } from '../../../state/analytics/useLinkClicked';
|
|
5
|
+
export const Frame = /*#__PURE__*/forwardRef((props, ref) => {
|
|
6
|
+
const {
|
|
7
|
+
isSelected,
|
|
8
|
+
children,
|
|
9
|
+
onClick,
|
|
10
|
+
link,
|
|
11
|
+
withoutBackground,
|
|
12
|
+
testId,
|
|
13
|
+
className
|
|
14
|
+
} = props;
|
|
15
|
+
const handleClick = useCallback(event => {
|
|
16
|
+
if (onClick) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
event.stopPropagation();
|
|
19
|
+
onClick(event);
|
|
20
|
+
}
|
|
21
|
+
}, [onClick]);
|
|
22
|
+
const handleKeyPress = useCallback(event => {
|
|
23
|
+
if (event.key !== ' ' && event.key !== 'Enter') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (onClick) {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
event.stopPropagation();
|
|
29
|
+
onClick(event);
|
|
30
|
+
}
|
|
31
|
+
}, [onClick]);
|
|
32
|
+
const handleMouseDown = useMouseDownEvent();
|
|
33
|
+
const isInteractive = Boolean(onClick);
|
|
34
|
+
|
|
35
|
+
// Depending on whenever Frame was given onClick or link itself we display span or anchor elements
|
|
36
|
+
const Wrapper = link || onClick ? WrapperAnchor : WrapperSpan;
|
|
37
|
+
|
|
38
|
+
// TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
|
|
39
|
+
// It will be worked as part of https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-154
|
|
40
|
+
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
41
|
+
theme: useGlobalTheme(),
|
|
42
|
+
href: link,
|
|
43
|
+
withoutBackground: withoutBackground,
|
|
44
|
+
isSelected: isSelected,
|
|
45
|
+
isInteractive: isInteractive,
|
|
46
|
+
tabIndex: isInteractive ? 0 : undefined,
|
|
47
|
+
role: isInteractive ? 'button' : undefined,
|
|
48
|
+
onClick: handleClick,
|
|
49
|
+
onMouseDown: handleMouseDown,
|
|
50
|
+
onKeyPress: handleKeyPress,
|
|
51
|
+
"data-testid": testId,
|
|
52
|
+
className: className,
|
|
53
|
+
ref: ref
|
|
54
|
+
}, children);
|
|
55
|
+
});
|