@atlaskit/smart-card 26.34.0 → 26.34.2
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 +12 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/mocks.js +6 -1
- package/dist/cjs/view/BlockCard/actions/flexible/ForbiddenAction.js +4 -5
- package/dist/cjs/view/BlockCard/index.js +5 -2
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenView.js +43 -17
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +103 -0
- package/dist/cjs/view/BlockCard/views/flexible/styled.js +4 -3
- package/dist/cjs/view/EmbedCard/index.js +15 -1
- package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +4 -0
- package/dist/cjs/view/EmbedCard/views/forbidden-view/index.js +4 -4
- package/dist/cjs/view/EmbedCard/views/unauthorized-view/index.js +100 -0
- package/dist/cjs/view/EmbedCard/views/unauthorized-view/types.js +5 -0
- package/dist/cjs/view/HoverCard/components/views/forbidden/index.js +2 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/mocks.js +5 -0
- package/dist/es2019/view/BlockCard/actions/flexible/ForbiddenAction.js +4 -5
- package/dist/es2019/view/BlockCard/index.js +5 -2
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +44 -17
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +95 -0
- package/dist/es2019/view/BlockCard/views/flexible/styled.js +4 -1
- package/dist/es2019/view/EmbedCard/index.js +15 -1
- package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +4 -0
- package/dist/es2019/view/EmbedCard/views/forbidden-view/index.js +3 -3
- package/dist/es2019/view/EmbedCard/views/unauthorized-view/index.js +88 -0
- package/dist/es2019/view/EmbedCard/views/unauthorized-view/types.js +1 -0
- package/dist/es2019/view/HoverCard/components/views/forbidden/index.js +2 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/mocks.js +5 -0
- package/dist/esm/view/BlockCard/actions/flexible/ForbiddenAction.js +4 -5
- package/dist/esm/view/BlockCard/index.js +5 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +43 -17
- package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.js +94 -0
- package/dist/esm/view/BlockCard/views/flexible/styled.js +3 -2
- package/dist/esm/view/EmbedCard/index.js +15 -1
- package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +4 -0
- package/dist/esm/view/EmbedCard/views/forbidden-view/index.js +4 -4
- package/dist/esm/view/EmbedCard/views/unauthorized-view/index.js +90 -0
- package/dist/esm/view/EmbedCard/views/unauthorized-view/types.js +1 -0
- package/dist/esm/view/HoverCard/components/views/forbidden/index.js +2 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/utils/mocks.d.ts +5 -0
- package/dist/types/view/BlockCard/actions/flexible/ForbiddenAction.d.ts +2 -1
- package/dist/types/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.d.ts +8 -0
- package/dist/types/view/BlockCard/views/flexible/styled.d.ts +1 -0
- package/dist/types/view/EmbedCard/views/UnauthorisedView.d.ts +4 -0
- package/dist/types/view/EmbedCard/views/forbidden-view/types.d.ts +1 -1
- package/dist/types/view/EmbedCard/views/unauthorized-view/index.d.ts +4 -0
- package/dist/types/view/EmbedCard/views/unauthorized-view/types.d.ts +9 -0
- package/dist/types/view/FlexibleCard/components/types.d.ts +2 -1
- package/dist/types-ts4.5/utils/mocks.d.ts +5 -0
- package/dist/types-ts4.5/view/BlockCard/actions/flexible/ForbiddenAction.d.ts +2 -1
- package/dist/types-ts4.5/view/BlockCard/views/flexible/FlexibleForbiddenViewOld.d.ts +8 -0
- package/dist/types-ts4.5/view/BlockCard/views/flexible/styled.d.ts +1 -0
- package/dist/types-ts4.5/view/EmbedCard/views/UnauthorisedView.d.ts +4 -0
- package/dist/types-ts4.5/view/EmbedCard/views/forbidden-view/types.d.ts +1 -1
- package/dist/types-ts4.5/view/EmbedCard/views/unauthorized-view/index.d.ts +4 -0
- package/dist/types-ts4.5/view/EmbedCard/views/unauthorized-view/types.d.ts +9 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import FlexibleCard from '../../../FlexibleCard';
|
|
4
|
-
import TitleBlock from '../../../FlexibleCard/components/blocks
|
|
5
|
-
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
4
|
+
import { CustomBlock, PreviewBlock, TitleBlock } from '../../../FlexibleCard/components/blocks';
|
|
6
5
|
import { R300 } from '@atlaskit/theme/colors';
|
|
7
6
|
import { messages } from '../../../../messages';
|
|
8
|
-
import LockIcon from '@atlaskit/icon/glyph/lock
|
|
7
|
+
import LockIcon from '@atlaskit/icon/glyph/lock';
|
|
9
8
|
import BlockCardFooter from '../../components/flexible/footer';
|
|
10
9
|
import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
|
|
11
10
|
import Text from '../../../FlexibleCard/components/elements/text';
|
|
11
|
+
import { MediaPlacement, SmartLinkSize } from '../../../../constants';
|
|
12
12
|
import { getForbiddenJsonLd } from '../../../../utils/jsonld';
|
|
13
13
|
import { extractProvider } from '@atlaskit/link-extractors';
|
|
14
|
-
import { extractRequestAccessContext } from '../../../../extractors/common/context';
|
|
15
14
|
import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
|
|
15
|
+
import { extractRequestAccessContextImproved } from '../../../../extractors/common/context/extractAccessContext';
|
|
16
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
17
|
+
import { forbiddenViewTitleStyle } from './styled';
|
|
18
|
+
import extractHostname from '../../../../extractors/common/hostname/extractHostname';
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* This view represent a Block Card with the 'Forbidden' status.
|
|
@@ -37,12 +40,25 @@ const FlexibleForbiddenView = ({
|
|
|
37
40
|
const cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
|
|
38
41
|
const provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
|
|
39
42
|
const providerName = (provider === null || provider === void 0 ? void 0 : provider.text) || '';
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const messageContext = useMemo(() => {
|
|
44
|
+
const hostname = /*#__PURE__*/React.createElement("b", null, extractHostname(url));
|
|
45
|
+
return {
|
|
46
|
+
product: providerName,
|
|
47
|
+
hostname
|
|
48
|
+
};
|
|
49
|
+
}, [providerName, url]);
|
|
50
|
+
const requestAccessContext = useMemo(() => {
|
|
51
|
+
return extractRequestAccessContextImproved({
|
|
52
|
+
jsonLd: cardMetadata,
|
|
53
|
+
url,
|
|
54
|
+
product: providerName
|
|
55
|
+
});
|
|
56
|
+
}, [cardMetadata, providerName, url]);
|
|
45
57
|
const descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
|
|
58
|
+
const {
|
|
59
|
+
titleMessageKey,
|
|
60
|
+
buttonDisabled
|
|
61
|
+
} = requestAccessContext !== null && requestAccessContext !== void 0 ? requestAccessContext : {};
|
|
46
62
|
const actions = useMemo(() => {
|
|
47
63
|
let actionFromAccessContext = [];
|
|
48
64
|
const tryAnotherAccountAction = onAuthorize ? [ForbiddenAction(onAuthorize, 'try_another_account')] : [];
|
|
@@ -51,10 +67,10 @@ const FlexibleForbiddenView = ({
|
|
|
51
67
|
action,
|
|
52
68
|
callToActionMessageKey
|
|
53
69
|
} = requestAccessContext;
|
|
54
|
-
actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey,
|
|
70
|
+
actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, messageContext, buttonDisabled)] : [];
|
|
55
71
|
}
|
|
56
72
|
return [...tryAnotherAccountAction, ...actionFromAccessContext];
|
|
57
|
-
}, [onAuthorize, requestAccessContext,
|
|
73
|
+
}, [onAuthorize, requestAccessContext, messageContext, buttonDisabled]);
|
|
58
74
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
59
75
|
appearance: "block",
|
|
60
76
|
cardState: cardState,
|
|
@@ -63,10 +79,19 @@ const FlexibleForbiddenView = ({
|
|
|
63
79
|
onError: onError,
|
|
64
80
|
testId: testId,
|
|
65
81
|
ui: {
|
|
66
|
-
hideElevation: true
|
|
82
|
+
hideElevation: true,
|
|
83
|
+
size: SmartLinkSize.Medium
|
|
67
84
|
},
|
|
68
85
|
url: url
|
|
69
|
-
}, /*#__PURE__*/React.createElement(
|
|
86
|
+
}, titleMessageKey ? /*#__PURE__*/React.createElement(CustomBlock, {
|
|
87
|
+
overrideCss: forbiddenViewTitleStyle,
|
|
88
|
+
testId: `${testId}-title`
|
|
89
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
90
|
+
target: anchorTarget,
|
|
91
|
+
href: url
|
|
92
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[titleMessageKey], {
|
|
93
|
+
values: messageContext
|
|
94
|
+
})))) : /*#__PURE__*/React.createElement(TitleBlock, _extends({
|
|
70
95
|
hideRetry: true,
|
|
71
96
|
anchorTarget: anchorTarget
|
|
72
97
|
}, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
@@ -75,13 +100,15 @@ const FlexibleForbiddenView = ({
|
|
|
75
100
|
primaryColor: `var(--ds-icon-danger, ${R300})`,
|
|
76
101
|
testId: `${testId}-lock-icon`
|
|
77
102
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
103
|
+
maxLines: 2,
|
|
78
104
|
message: {
|
|
79
105
|
descriptor: messages[descriptiveMessageKey],
|
|
80
|
-
values:
|
|
81
|
-
context: providerName
|
|
82
|
-
}
|
|
106
|
+
values: messageContext
|
|
83
107
|
}
|
|
84
|
-
})), /*#__PURE__*/React.createElement(
|
|
108
|
+
})), /*#__PURE__*/React.createElement(PreviewBlock, {
|
|
109
|
+
placement: MediaPlacement.Right,
|
|
110
|
+
ignoreContainerPadding: true
|
|
111
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
85
112
|
actions: actions,
|
|
86
113
|
status: status
|
|
87
114
|
})));
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
4
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
5
|
+
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
6
|
+
import { R300 } from '@atlaskit/theme/colors';
|
|
7
|
+
import { messages } from '../../../../messages';
|
|
8
|
+
import LockIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
9
|
+
import BlockCardFooter from '../../components/flexible/footer';
|
|
10
|
+
import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
|
|
11
|
+
import Text from '../../../FlexibleCard/components/elements/text';
|
|
12
|
+
import { getForbiddenJsonLd } from '../../../../utils/jsonld';
|
|
13
|
+
import { extractProvider } from '@atlaskit/link-extractors';
|
|
14
|
+
import { extractRequestAccessContext } from '../../../../extractors/common/context';
|
|
15
|
+
import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
* @deprecated {@link https://product-fabric.atlassian.net/browse/EDM-7977 Internal documentation for deprecation (no external access)}
|
|
20
|
+
* @deprecated Replaced by FlexibleForbiddenView
|
|
21
|
+
*/
|
|
22
|
+
const FlexibleForbiddenView = ({
|
|
23
|
+
anchorTarget,
|
|
24
|
+
cardState,
|
|
25
|
+
onAuthorize,
|
|
26
|
+
onClick,
|
|
27
|
+
onError,
|
|
28
|
+
testId = 'smart-block-forbidden-view',
|
|
29
|
+
url,
|
|
30
|
+
titleBlockProps
|
|
31
|
+
}) => {
|
|
32
|
+
var _details$meta;
|
|
33
|
+
const status = cardState.status;
|
|
34
|
+
const details = cardState === null || cardState === void 0 ? void 0 : cardState.details;
|
|
35
|
+
const cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
|
|
36
|
+
const provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
|
|
37
|
+
const providerName = (provider === null || provider === void 0 ? void 0 : provider.text) || '';
|
|
38
|
+
const requestAccessContext = extractRequestAccessContext({
|
|
39
|
+
jsonLd: cardMetadata,
|
|
40
|
+
url,
|
|
41
|
+
context: providerName
|
|
42
|
+
});
|
|
43
|
+
const descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
|
|
44
|
+
const actions = useMemo(() => {
|
|
45
|
+
let actionFromAccessContext = [];
|
|
46
|
+
const tryAnotherAccountAction = onAuthorize ? [ForbiddenAction(onAuthorize, 'try_another_account')] : [];
|
|
47
|
+
if (requestAccessContext) {
|
|
48
|
+
const {
|
|
49
|
+
action,
|
|
50
|
+
callToActionMessageKey
|
|
51
|
+
} = requestAccessContext;
|
|
52
|
+
actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, {
|
|
53
|
+
context: providerName
|
|
54
|
+
})] : [];
|
|
55
|
+
}
|
|
56
|
+
return [...tryAnotherAccountAction, ...actionFromAccessContext];
|
|
57
|
+
}, [onAuthorize, requestAccessContext, providerName]);
|
|
58
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
59
|
+
appearance: "block",
|
|
60
|
+
cardState: cardState,
|
|
61
|
+
onAuthorize: onAuthorize,
|
|
62
|
+
onClick: onClick,
|
|
63
|
+
onError: onError,
|
|
64
|
+
testId: testId,
|
|
65
|
+
ui: {
|
|
66
|
+
hideElevation: true
|
|
67
|
+
},
|
|
68
|
+
url: url
|
|
69
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, _extends({
|
|
70
|
+
hideRetry: true,
|
|
71
|
+
anchorTarget: anchorTarget
|
|
72
|
+
}, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
73
|
+
label: "forbidden-lock-icon",
|
|
74
|
+
size: "small",
|
|
75
|
+
primaryColor: `var(--ds-icon-danger, ${R300})`,
|
|
76
|
+
testId: `${testId}-lock-icon`
|
|
77
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
78
|
+
message: {
|
|
79
|
+
descriptor: messages[descriptiveMessageKey],
|
|
80
|
+
values: {
|
|
81
|
+
context: providerName
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
85
|
+
actions: actions,
|
|
86
|
+
status: status
|
|
87
|
+
})));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @private
|
|
92
|
+
* @deprecated {@link https://product-fabric.atlassian.net/browse/EDM-7977 Internal documentation for deprecation (no external access)}
|
|
93
|
+
* @deprecated Replaced by FlexibleForbiddenView
|
|
94
|
+
*/
|
|
95
|
+
export default withFlexibleUIBlockCardStyle(FlexibleForbiddenView);
|
|
@@ -44,4 +44,7 @@ const refreshedFlexibleBlockCardStyle = css`
|
|
|
44
44
|
border: 1px solid ${`var(--ds-border, ${N40})`};
|
|
45
45
|
}
|
|
46
46
|
`;
|
|
47
|
-
export const flexibleBlockCardStyle = getBooleanFF('platform.linking-platform.smart-card.show-smart-links-refreshed-design') ? refreshedFlexibleBlockCardStyle : flexibleBlockCardElevationStyle;
|
|
47
|
+
export const flexibleBlockCardStyle = getBooleanFF('platform.linking-platform.smart-card.show-smart-links-refreshed-design') ? refreshedFlexibleBlockCardStyle : flexibleBlockCardElevationStyle;
|
|
48
|
+
export const forbiddenViewTitleStyle = css`
|
|
49
|
+
font-weight: 600;
|
|
50
|
+
`;
|
|
@@ -17,6 +17,7 @@ import { EmbedCardUnauthorisedView } from './views/UnauthorisedView';
|
|
|
17
17
|
import { EmbedCardErroredView } from './views/ErroredView';
|
|
18
18
|
import ForbiddenView from './views/forbidden-view';
|
|
19
19
|
import NotFoundView from './views/not-found-view';
|
|
20
|
+
import UnauthorizedView from './views/unauthorized-view';
|
|
20
21
|
export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
21
22
|
url,
|
|
22
23
|
cardState: {
|
|
@@ -105,6 +106,19 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
const unauthorisedViewProps = extractEmbedProps(data, meta, platform);
|
|
109
|
+
if (getBooleanFF('platform.linking-platform.smart-card.cross-join')) {
|
|
110
|
+
return /*#__PURE__*/React.createElement(UnauthorizedView, {
|
|
111
|
+
analytics: analytics,
|
|
112
|
+
context: unauthorisedViewProps.context,
|
|
113
|
+
extensionKey: extensionKey,
|
|
114
|
+
inheritDimensions: inheritDimensions,
|
|
115
|
+
isSelected: isSelected,
|
|
116
|
+
onAuthorize: handleAuthorize,
|
|
117
|
+
onClick: handleFrameClick,
|
|
118
|
+
testId: testId,
|
|
119
|
+
url: unauthorisedViewProps.link
|
|
120
|
+
});
|
|
121
|
+
}
|
|
108
122
|
return /*#__PURE__*/React.createElement(EmbedCardUnauthorisedView, _extends({}, unauthorisedViewProps, {
|
|
109
123
|
isSelected: isSelected,
|
|
110
124
|
onAuthorise: handleAuthorize,
|
|
@@ -144,7 +158,7 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
144
158
|
context: forbiddenViewProps.context,
|
|
145
159
|
inheritDimensions: inheritDimensions,
|
|
146
160
|
isSelected: isSelected,
|
|
147
|
-
|
|
161
|
+
onAuthorize: handleAuthorize,
|
|
148
162
|
onClick: handleFrameClick,
|
|
149
163
|
accessContext: accessContext,
|
|
150
164
|
url: forbiddenViewProps.link
|
|
@@ -5,6 +5,10 @@ import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
|
5
5
|
import { ImageIcon } from '../components/ImageIcon';
|
|
6
6
|
import UnauthorisedViewContent from '../../common/UnauthorisedViewContent';
|
|
7
7
|
import { getUnresolvedEmbedCardImage } from '../utils';
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated {@link https://product-fabric.atlassian.net/browse/EDM-7977 Internal documentation for deprecation (no external access)}\
|
|
10
|
+
* @deprecated Replaced by unauthorized-view
|
|
11
|
+
*/
|
|
8
12
|
export const EmbedCardUnauthorisedView = ({
|
|
9
13
|
analytics,
|
|
10
14
|
link,
|
|
@@ -9,7 +9,7 @@ import UnresolvedView from '../unresolved-view';
|
|
|
9
9
|
import { getUnresolvedEmbedCardImage } from '../../utils';
|
|
10
10
|
const ForbiddenView = ({
|
|
11
11
|
context,
|
|
12
|
-
|
|
12
|
+
onAuthorize,
|
|
13
13
|
accessContext,
|
|
14
14
|
testId = 'embed-card-forbidden-view',
|
|
15
15
|
...unresolvedViewProps
|
|
@@ -44,7 +44,7 @@ const ForbiddenView = ({
|
|
|
44
44
|
*/
|
|
45
45
|
const button = useMemo(() => {
|
|
46
46
|
var _action$promise;
|
|
47
|
-
const onEmbedCardClick = (_action$promise = action === null || action === void 0 ? void 0 : action.promise) !== null && _action$promise !== void 0 ? _action$promise :
|
|
47
|
+
const onEmbedCardClick = (_action$promise = action === null || action === void 0 ? void 0 : action.promise) !== null && _action$promise !== void 0 ? _action$promise : onAuthorize;
|
|
48
48
|
if (!onEmbedCardClick) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
@@ -56,7 +56,7 @@ const ForbiddenView = ({
|
|
|
56
56
|
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, toMessage(messages.try_another_account, callToActionMessageKey), {
|
|
57
57
|
values: values
|
|
58
58
|
})));
|
|
59
|
-
}, [accessType, action === null || action === void 0 ? void 0 : action.id, action === null || action === void 0 ? void 0 : action.promise, callToActionMessageKey,
|
|
59
|
+
}, [accessType, action === null || action === void 0 ? void 0 : action.id, action === null || action === void 0 ? void 0 : action.promise, callToActionMessageKey, onAuthorize, values]);
|
|
60
60
|
return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, unresolvedViewProps, {
|
|
61
61
|
icon: icon,
|
|
62
62
|
image: image !== null && image !== void 0 ? image : getUnresolvedEmbedCardImage('forbidden'),
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import Button from '@atlaskit/button';
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
4
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { di } from 'react-magnetic-di';
|
|
6
|
+
import { messages } from '../../../../messages';
|
|
7
|
+
import UnauthorisedViewContent from '../../../common/UnauthorisedViewContent';
|
|
8
|
+
import { getUnresolvedEmbedCardImage } from '../../utils';
|
|
9
|
+
import UnresolvedView from '../unresolved-view';
|
|
10
|
+
const UnauthorizedView = ({
|
|
11
|
+
analytics,
|
|
12
|
+
context,
|
|
13
|
+
extensionKey,
|
|
14
|
+
onAuthorize,
|
|
15
|
+
testId = 'embed-card-unauthorized-view',
|
|
16
|
+
...unresolvedViewProps
|
|
17
|
+
}) => {
|
|
18
|
+
var _context$image;
|
|
19
|
+
const handleOnAuthorizeClick = useCallback(() => {
|
|
20
|
+
if (onAuthorize) {
|
|
21
|
+
analytics.track.appAccountAuthStarted({
|
|
22
|
+
extensionKey
|
|
23
|
+
});
|
|
24
|
+
onAuthorize();
|
|
25
|
+
}
|
|
26
|
+
}, [onAuthorize, analytics.track, extensionKey]);
|
|
27
|
+
const content = useMemo(() => {
|
|
28
|
+
if (onAuthorize) {
|
|
29
|
+
var _context$text;
|
|
30
|
+
// Our title and button messages always expect the product name to be present
|
|
31
|
+
// while the description support when product name is not present.
|
|
32
|
+
// To be looked at https://product-fabric.atlassian.net/browse/EDM-8173
|
|
33
|
+
const values = {
|
|
34
|
+
context: (_context$text = context === null || context === void 0 ? void 0 : context.text) !== null && _context$text !== void 0 ? _context$text : ''
|
|
35
|
+
};
|
|
36
|
+
if (values) {
|
|
37
|
+
// title: Connect your {context} account
|
|
38
|
+
// button: Connect to {context}
|
|
39
|
+
return {
|
|
40
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_link_account_card_name, {
|
|
41
|
+
values: values
|
|
42
|
+
})),
|
|
43
|
+
description: /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
44
|
+
analytics: analytics,
|
|
45
|
+
providerName: context === null || context === void 0 ? void 0 : context.text,
|
|
46
|
+
testId: testId
|
|
47
|
+
}),
|
|
48
|
+
button: /*#__PURE__*/React.createElement(Button, {
|
|
49
|
+
testId: "connect-account",
|
|
50
|
+
appearance: "primary",
|
|
51
|
+
onClick: handleOnAuthorizeClick
|
|
52
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_action, {
|
|
53
|
+
values: values
|
|
54
|
+
})))
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const values = context !== null && context !== void 0 && context.text ? {
|
|
59
|
+
context: context === null || context === void 0 ? void 0 : context.text
|
|
60
|
+
} : undefined;
|
|
61
|
+
if (values) {
|
|
62
|
+
// title: We can't display private pages from {context}
|
|
63
|
+
// description: You're trying to preview a link to a private {context} page. We recommend you review the URL or contact the page owner.
|
|
64
|
+
return {
|
|
65
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.unauthorised_account_name, {
|
|
66
|
+
values: values
|
|
67
|
+
})),
|
|
68
|
+
description: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.unauthorised_account_description, {
|
|
69
|
+
values: values
|
|
70
|
+
}))
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// title: We can't display private pages
|
|
75
|
+
// description: You're trying to preview a link to a private page. We recommend you review the URL or contact the page owner.
|
|
76
|
+
return {
|
|
77
|
+
title: /*#__PURE__*/React.createElement(FormattedMessage, messages.unauthorised_account_name_no_provider),
|
|
78
|
+
description: /*#__PURE__*/React.createElement(FormattedMessage, messages.unauthorised_account_description_no_provider)
|
|
79
|
+
};
|
|
80
|
+
}, [analytics, context === null || context === void 0 ? void 0 : context.text, handleOnAuthorizeClick, onAuthorize, testId]);
|
|
81
|
+
return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, unresolvedViewProps, content, {
|
|
82
|
+
icon: context === null || context === void 0 ? void 0 : context.icon,
|
|
83
|
+
image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : getUnresolvedEmbedCardImage('unauthorized'),
|
|
84
|
+
testId: testId,
|
|
85
|
+
text: context === null || context === void 0 ? void 0 : context.text
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
export default UnauthorizedView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,6 +9,7 @@ import { extractProvider } from '@atlaskit/link-extractors';
|
|
|
9
9
|
import { connectButtonStyles, mainTextStyles, titleBlockStyles } from './styled';
|
|
10
10
|
import { getPreviewBlockStyles } from '../../../styled';
|
|
11
11
|
import { extractRequestAccessContextImproved } from '../../../../../extractors/common/context/extractAccessContext';
|
|
12
|
+
import extractHostname from '../../../../../extractors/common/hostname/extractHostname';
|
|
12
13
|
const HoverCardForbiddenView = ({
|
|
13
14
|
flexibleCardProps,
|
|
14
15
|
testId = 'hover-card-forbidden-view'
|
|
@@ -21,7 +22,7 @@ const HoverCardForbiddenView = ({
|
|
|
21
22
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
22
23
|
const meta = (_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.meta;
|
|
23
24
|
const product = (_extractProvider$text = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text) !== null && _extractProvider$text !== void 0 ? _extractProvider$text : '';
|
|
24
|
-
const hostname = /*#__PURE__*/React.createElement("b", null,
|
|
25
|
+
const hostname = /*#__PURE__*/React.createElement("b", null, extractHostname(url));
|
|
25
26
|
const {
|
|
26
27
|
action,
|
|
27
28
|
descriptiveMessageKey,
|
|
@@ -8,7 +8,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
const PACKAGE_DATA = {
|
|
10
10
|
packageName: "@atlaskit/smart-card",
|
|
11
|
-
packageVersion: "26.34.
|
|
11
|
+
packageVersion: "26.34.2",
|
|
12
12
|
componentName: 'linkUrl'
|
|
13
13
|
};
|
|
14
14
|
const Link = withLinkClickedEvent('a');
|
|
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
15
15
|
export var context = {
|
|
16
16
|
componentName: 'smart-cards',
|
|
17
17
|
packageName: "@atlaskit/smart-card",
|
|
18
|
-
packageVersion: "26.34.
|
|
18
|
+
packageVersion: "26.34.2"
|
|
19
19
|
};
|
|
20
20
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
21
21
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
package/dist/esm/utils/mocks.js
CHANGED
|
@@ -16,6 +16,11 @@ export var mockContext = {
|
|
|
16
16
|
atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
|
|
17
17
|
schema: 'http://schema.org/'
|
|
18
18
|
};
|
|
19
|
+
export var mockGenerator = {
|
|
20
|
+
'@type': 'Application',
|
|
21
|
+
'@id': 'https://www.atlassian.com/#Jira',
|
|
22
|
+
name: 'Jira'
|
|
23
|
+
};
|
|
19
24
|
export var mockByUrl = function mockByUrl(url) {
|
|
20
25
|
return {
|
|
21
26
|
meta: {
|
|
@@ -12,15 +12,14 @@ import { messages } from '../../../../messages';
|
|
|
12
12
|
* @param content is a message key for a message to be displayed in the action
|
|
13
13
|
* @param context is a variable for a message in case a message contains a placeholder
|
|
14
14
|
*/
|
|
15
|
-
export var ForbiddenAction = function ForbiddenAction(onClick, content, context) {
|
|
15
|
+
export var ForbiddenAction = function ForbiddenAction(onClick, content, context, isDisabled) {
|
|
16
16
|
return {
|
|
17
17
|
name: ActionName.CustomAction,
|
|
18
18
|
content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[content], {
|
|
19
|
-
values:
|
|
20
|
-
context: context
|
|
21
|
-
}
|
|
19
|
+
values: context
|
|
22
20
|
})),
|
|
23
21
|
onClick: onClick,
|
|
24
|
-
testId: 'smart-action-connect-other-account'
|
|
22
|
+
testId: 'smart-action-connect-other-account',
|
|
23
|
+
isDisabled: isDisabled
|
|
25
24
|
};
|
|
26
25
|
};
|
|
@@ -20,8 +20,9 @@ import { ErroredView as BlockCardErroredView } from './views/ErroredView';
|
|
|
20
20
|
import FlexibleResolvedView from './views/flexible/FlexibleResolvedView';
|
|
21
21
|
import FlexibleUnauthorisedView from './views/flexible/FlexibleUnauthorisedView';
|
|
22
22
|
import FlexibleNotFoundView from './views/flexible/FlexibleNotFoundView';
|
|
23
|
-
import FlexibleErroredView from './views/flexible/FlexibleErroredView';
|
|
24
23
|
import FlexibleForbiddenView from './views/flexible/FlexibleForbiddenView';
|
|
24
|
+
import FlexibleForbiddenViewOld from './views/flexible/FlexibleForbiddenViewOld';
|
|
25
|
+
import FlexibleErroredView from './views/flexible/FlexibleErroredView';
|
|
25
26
|
import { jsx } from '@emotion/react';
|
|
26
27
|
import { handleClickCommon } from './utils/handlers';
|
|
27
28
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -98,7 +99,9 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
98
99
|
onAuthorize: handleAuthorize
|
|
99
100
|
}));
|
|
100
101
|
case 'forbidden':
|
|
101
|
-
return jsx(FlexibleForbiddenView, _extends({}, flexibleBlockCardProps, {
|
|
102
|
+
return getBooleanFF('platform.linking-platform.smart-card.cross-join') ? jsx(FlexibleForbiddenView, _extends({}, flexibleBlockCardProps, {
|
|
103
|
+
onAuthorize: handleAuthorize
|
|
104
|
+
})) : jsx(FlexibleForbiddenViewOld, _extends({}, flexibleBlockCardProps, {
|
|
102
105
|
onAuthorize: handleAuthorize
|
|
103
106
|
}));
|
|
104
107
|
case 'not_found':
|
|
@@ -2,18 +2,21 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
import React, { useMemo } from 'react';
|
|
4
4
|
import FlexibleCard from '../../../FlexibleCard';
|
|
5
|
-
import TitleBlock from '../../../FlexibleCard/components/blocks
|
|
6
|
-
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
5
|
+
import { CustomBlock, PreviewBlock, TitleBlock } from '../../../FlexibleCard/components/blocks';
|
|
7
6
|
import { R300 } from '@atlaskit/theme/colors';
|
|
8
7
|
import { messages } from '../../../../messages';
|
|
9
|
-
import LockIcon from '@atlaskit/icon/glyph/lock
|
|
8
|
+
import LockIcon from '@atlaskit/icon/glyph/lock';
|
|
10
9
|
import BlockCardFooter from '../../components/flexible/footer';
|
|
11
10
|
import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
|
|
12
11
|
import Text from '../../../FlexibleCard/components/elements/text';
|
|
12
|
+
import { MediaPlacement, SmartLinkSize } from '../../../../constants';
|
|
13
13
|
import { getForbiddenJsonLd } from '../../../../utils/jsonld';
|
|
14
14
|
import { extractProvider } from '@atlaskit/link-extractors';
|
|
15
|
-
import { extractRequestAccessContext } from '../../../../extractors/common/context';
|
|
16
15
|
import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
|
|
16
|
+
import { extractRequestAccessContextImproved } from '../../../../extractors/common/context/extractAccessContext';
|
|
17
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
18
|
+
import { forbiddenViewTitleStyle } from './styled';
|
|
19
|
+
import extractHostname from '../../../../extractors/common/hostname/extractHostname';
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* This view represent a Block Card with the 'Forbidden' status.
|
|
@@ -38,22 +41,34 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
|
|
|
38
41
|
var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
|
|
39
42
|
var provider = extractProvider(details === null || details === void 0 ? void 0 : details.data);
|
|
40
43
|
var providerName = (provider === null || provider === void 0 ? void 0 : provider.text) || '';
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
var messageContext = useMemo(function () {
|
|
45
|
+
var hostname = /*#__PURE__*/React.createElement("b", null, extractHostname(url));
|
|
46
|
+
return {
|
|
47
|
+
product: providerName,
|
|
48
|
+
hostname: hostname
|
|
49
|
+
};
|
|
50
|
+
}, [providerName, url]);
|
|
51
|
+
var requestAccessContext = useMemo(function () {
|
|
52
|
+
return extractRequestAccessContextImproved({
|
|
53
|
+
jsonLd: cardMetadata,
|
|
54
|
+
url: url,
|
|
55
|
+
product: providerName
|
|
56
|
+
});
|
|
57
|
+
}, [cardMetadata, providerName, url]);
|
|
46
58
|
var descriptiveMessageKey = requestAccessContext && requestAccessContext.descriptiveMessageKey ? requestAccessContext.descriptiveMessageKey : 'invalid_permissions_description';
|
|
59
|
+
var _ref2 = requestAccessContext !== null && requestAccessContext !== void 0 ? requestAccessContext : {},
|
|
60
|
+
titleMessageKey = _ref2.titleMessageKey,
|
|
61
|
+
buttonDisabled = _ref2.buttonDisabled;
|
|
47
62
|
var actions = useMemo(function () {
|
|
48
63
|
var actionFromAccessContext = [];
|
|
49
64
|
var tryAnotherAccountAction = onAuthorize ? [ForbiddenAction(onAuthorize, 'try_another_account')] : [];
|
|
50
65
|
if (requestAccessContext) {
|
|
51
66
|
var action = requestAccessContext.action,
|
|
52
67
|
callToActionMessageKey = requestAccessContext.callToActionMessageKey;
|
|
53
|
-
actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey,
|
|
68
|
+
actionFromAccessContext = action && callToActionMessageKey ? [ForbiddenAction(action.promise, callToActionMessageKey, messageContext, buttonDisabled)] : [];
|
|
54
69
|
}
|
|
55
70
|
return [].concat(tryAnotherAccountAction, _toConsumableArray(actionFromAccessContext));
|
|
56
|
-
}, [onAuthorize, requestAccessContext,
|
|
71
|
+
}, [onAuthorize, requestAccessContext, messageContext, buttonDisabled]);
|
|
57
72
|
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
58
73
|
appearance: "block",
|
|
59
74
|
cardState: cardState,
|
|
@@ -62,10 +77,19 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
|
|
|
62
77
|
onError: onError,
|
|
63
78
|
testId: testId,
|
|
64
79
|
ui: {
|
|
65
|
-
hideElevation: true
|
|
80
|
+
hideElevation: true,
|
|
81
|
+
size: SmartLinkSize.Medium
|
|
66
82
|
},
|
|
67
83
|
url: url
|
|
68
|
-
}, /*#__PURE__*/React.createElement(
|
|
84
|
+
}, titleMessageKey ? /*#__PURE__*/React.createElement(CustomBlock, {
|
|
85
|
+
overrideCss: forbiddenViewTitleStyle,
|
|
86
|
+
testId: "".concat(testId, "-title")
|
|
87
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
88
|
+
target: anchorTarget,
|
|
89
|
+
href: url
|
|
90
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages[titleMessageKey], {
|
|
91
|
+
values: messageContext
|
|
92
|
+
})))) : /*#__PURE__*/React.createElement(TitleBlock, _extends({
|
|
69
93
|
hideRetry: true,
|
|
70
94
|
anchorTarget: anchorTarget
|
|
71
95
|
}, titleBlockProps)), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
@@ -74,13 +98,15 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
|
|
|
74
98
|
primaryColor: "var(--ds-icon-danger, ".concat(R300, ")"),
|
|
75
99
|
testId: "".concat(testId, "-lock-icon")
|
|
76
100
|
}), /*#__PURE__*/React.createElement(Text, {
|
|
101
|
+
maxLines: 2,
|
|
77
102
|
message: {
|
|
78
103
|
descriptor: messages[descriptiveMessageKey],
|
|
79
|
-
values:
|
|
80
|
-
context: providerName
|
|
81
|
-
}
|
|
104
|
+
values: messageContext
|
|
82
105
|
}
|
|
83
|
-
})), /*#__PURE__*/React.createElement(
|
|
106
|
+
})), /*#__PURE__*/React.createElement(PreviewBlock, {
|
|
107
|
+
placement: MediaPlacement.Right,
|
|
108
|
+
ignoreContainerPadding: true
|
|
109
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
84
110
|
actions: actions,
|
|
85
111
|
status: status
|
|
86
112
|
})));
|