@atlaskit/smart-card 23.4.1 → 23.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/actions/flexible/AuthorizeAction.js +32 -0
- package/dist/cjs/view/BlockCard/actions/flexible/ForbiddenAction.js +32 -0
- package/dist/cjs/view/BlockCard/actions/flexible/RetryAction.js +32 -0
- package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +69 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +83 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenView.js +85 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +73 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +79 -0
- package/dist/cjs/view/BlockCard/views/flexible/types.js +5 -0
- package/dist/cjs/view/EmbedCard/components/ExpandedFrame.js +5 -1
- package/dist/cjs/view/EmbedCard/components/styled.js +8 -5
- package/dist/cjs/view/EmbedCard/views/ForbiddenView.js +2 -1
- package/dist/cjs/view/EmbedCard/views/NotFoundView.js +2 -1
- package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +2 -1
- package/dist/cjs/view/EmbedCard/views/UnresolvedView.js +2 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/index.js +9 -1
- package/dist/cjs/view/FlexibleCard/utils.js +5 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/actions/flexible/AuthorizeAction.js +16 -0
- package/dist/es2019/view/BlockCard/actions/flexible/ForbiddenAction.js +16 -0
- package/dist/es2019/view/BlockCard/actions/flexible/RetryAction.js +16 -0
- package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +56 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +55 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +57 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +54 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +53 -0
- package/dist/es2019/view/BlockCard/views/flexible/types.js +1 -0
- package/dist/es2019/view/EmbedCard/components/ExpandedFrame.js +4 -1
- package/dist/es2019/view/EmbedCard/components/styled.js +4 -1
- package/dist/es2019/view/EmbedCard/views/ForbiddenView.js +2 -1
- package/dist/es2019/view/EmbedCard/views/NotFoundView.js +2 -1
- package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +2 -1
- package/dist/es2019/view/EmbedCard/views/UnresolvedView.js +2 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/index.js +2 -1
- package/dist/es2019/view/FlexibleCard/utils.js +4 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/actions/flexible/AuthorizeAction.js +18 -0
- package/dist/esm/view/BlockCard/actions/flexible/ForbiddenAction.js +18 -0
- package/dist/esm/view/BlockCard/actions/flexible/RetryAction.js +18 -0
- package/dist/esm/view/BlockCard/components/flexible/footer/index.js +54 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +57 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +59 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +54 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +56 -0
- package/dist/esm/view/BlockCard/views/flexible/types.js +1 -0
- package/dist/esm/view/EmbedCard/components/ExpandedFrame.js +5 -1
- package/dist/esm/view/EmbedCard/components/styled.js +8 -5
- package/dist/esm/view/EmbedCard/views/ForbiddenView.js +2 -1
- package/dist/esm/view/EmbedCard/views/NotFoundView.js +2 -1
- package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +2 -1
- package/dist/esm/view/EmbedCard/views/UnresolvedView.js +2 -2
- package/dist/esm/view/FlexibleCard/components/blocks/index.js +2 -1
- package/dist/esm/view/FlexibleCard/utils.js +4 -1
- package/dist/types/view/BlockCard/actions/flexible/AuthorizeAction.d.ts +8 -0
- package/dist/types/view/BlockCard/actions/flexible/ForbiddenAction.d.ts +8 -0
- package/dist/types/view/BlockCard/actions/flexible/RetryAction.d.ts +8 -0
- package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +12 -0
- package/dist/types/view/BlockCard/views/flexible/FlexibleErroredView.d.ts +10 -0
- package/dist/types/view/BlockCard/views/flexible/FlexibleForbiddenView.d.ts +11 -0
- package/dist/types/view/BlockCard/views/flexible/FlexibleNotFoundView.d.ts +10 -0
- package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +11 -0
- package/dist/types/view/BlockCard/views/flexible/types.d.ts +56 -0
- package/dist/types/view/EmbedCard/components/ExpandedFrame.d.ts +2 -0
- package/dist/types/view/EmbedCard/components/styled.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -23,6 +23,8 @@ var _utils = require("../../utils");
|
|
|
23
23
|
|
|
24
24
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
25
25
|
|
|
26
|
+
var _extractProviderIcon = _interopRequireDefault(require("../../extractors/flexible/icon/extract-provider-icon"));
|
|
27
|
+
|
|
26
28
|
var getContextByStatus = function getContextByStatus(url, status, details, renderers) {
|
|
27
29
|
switch (status) {
|
|
28
30
|
case _constants.SmartLinkStatus.Pending:
|
|
@@ -42,10 +44,12 @@ var getContextByStatus = function getContextByStatus(url, status, details, rende
|
|
|
42
44
|
case _constants.SmartLinkStatus.Fallback:
|
|
43
45
|
default:
|
|
44
46
|
var linkIcon = (0, _icon.extractErrorIcon)(details, status);
|
|
47
|
+
var provider = (0, _extractProviderIcon.default)(details === null || details === void 0 ? void 0 : details.data);
|
|
45
48
|
return {
|
|
46
49
|
linkIcon: linkIcon,
|
|
47
50
|
title: url,
|
|
48
|
-
url: url
|
|
51
|
+
url: url,
|
|
52
|
+
provider: provider
|
|
49
53
|
};
|
|
50
54
|
}
|
|
51
55
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
import { ActionName } from '../../../../constants';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a CustomActionItem with a "Connect" default message
|
|
7
|
+
*
|
|
8
|
+
* @see CustomActionItem
|
|
9
|
+
* @param onAuthorize a function that will be called on the click of the button
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const AuthorizeAction = onAuthorize => ({
|
|
13
|
+
name: ActionName.CustomAction,
|
|
14
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.connect_link_account_card),
|
|
15
|
+
onClick: onAuthorize
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
import { ActionName } from '../../../../constants';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a CustomActionItem with a "Try Another Account" default message
|
|
7
|
+
*
|
|
8
|
+
* @see CustomActionItem
|
|
9
|
+
* @param onAuthorize a function that will be called on the click of the button
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const ForbiddenAction = onAuthorize => ({
|
|
13
|
+
name: ActionName.CustomAction,
|
|
14
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.try_another_account),
|
|
15
|
+
onClick: onAuthorize
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
import { ActionName } from '../../../../constants';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a CustomActionItem with a "Retry" default message
|
|
7
|
+
*
|
|
8
|
+
* @see CustomActionItem
|
|
9
|
+
* @param onRetry a function that will be called on the click of the "Retry" button
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const RetryAction = onRetry => ({
|
|
13
|
+
name: ActionName.CustomAction,
|
|
14
|
+
onClick: onRetry,
|
|
15
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.try_again)
|
|
16
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { Provider } from '../../../../FlexibleCard/components/elements';
|
|
4
|
+
import ElementGroup from '../../../../FlexibleCard/components/blocks/element-group';
|
|
5
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
6
|
+
import ActionGroup from '../../../../FlexibleCard/components/blocks/action-group';
|
|
7
|
+
|
|
8
|
+
const getActionGroupStyles = size => {
|
|
9
|
+
if (size === SmartLinkSize.XLarge) {
|
|
10
|
+
// The biggest height of the action button exceeds the max line-height
|
|
11
|
+
// of the elements causing the action on the block with x-large size to
|
|
12
|
+
// get cut at the bottom.
|
|
13
|
+
return css`
|
|
14
|
+
max-height: 2rem;
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const providerStyles = css`
|
|
20
|
+
span:first-child {
|
|
21
|
+
margin-right: 0.375rem;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
/**
|
|
25
|
+
* This Components is a footer that is used in a Block Card with Flexible UI.
|
|
26
|
+
* It contains a provider icon if provider is present and an actions list if one is passed.
|
|
27
|
+
* To be shown as a part of Flexible UI, needs to be wrapped inside of a CustomBlock
|
|
28
|
+
*
|
|
29
|
+
* @see CustomBlock
|
|
30
|
+
* @param props are the data required for the block, such as actions to be displayed.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const Footer = props => {
|
|
34
|
+
const {
|
|
35
|
+
actions,
|
|
36
|
+
size = SmartLinkSize.Medium,
|
|
37
|
+
testId = 'smart-block-card-footer'
|
|
38
|
+
} = props;
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
"data-testid": testId
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Provider, {
|
|
42
|
+
testId: `${testId}-provider`,
|
|
43
|
+
overrideCss: providerStyles
|
|
44
|
+
}), actions && actions.length > 0 ? /*#__PURE__*/React.createElement(ElementGroup, {
|
|
45
|
+
testId: "smart-element-group-actions",
|
|
46
|
+
align: SmartLinkAlignment.Right,
|
|
47
|
+
direction: SmartLinkDirection.Horizontal,
|
|
48
|
+
overrideCss: getActionGroupStyles(size),
|
|
49
|
+
width: SmartLinkWidth.Flexible
|
|
50
|
+
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
51
|
+
items: actions,
|
|
52
|
+
appearance: "default"
|
|
53
|
+
})) : null);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default Footer;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
3
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { R300 } from '@atlaskit/theme/colors';
|
|
7
|
+
import WarningIcon from '@atlaskit/icon/glyph/warning';
|
|
8
|
+
import Footer from '../../components/flexible/footer';
|
|
9
|
+
import { RetryAction } from '../../actions/flexible/RetryAction';
|
|
10
|
+
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
11
|
+
import Text from '../../../FlexibleCard/components/elements/text';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This view represents a Block Card with an 'Errored' status.
|
|
15
|
+
*
|
|
16
|
+
* @see SmartLinkStatus
|
|
17
|
+
* @see FlexibleCardProps
|
|
18
|
+
*/
|
|
19
|
+
const FlexibleErroredView = ({
|
|
20
|
+
cardState,
|
|
21
|
+
onAuthorize,
|
|
22
|
+
onError,
|
|
23
|
+
ui,
|
|
24
|
+
url,
|
|
25
|
+
onClick,
|
|
26
|
+
testId = 'smart-block-errored-view'
|
|
27
|
+
}) => {
|
|
28
|
+
const status = cardState.status;
|
|
29
|
+
const actions = useMemo(() => onAuthorize ? [RetryAction(onAuthorize)] : [], [onAuthorize]);
|
|
30
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
31
|
+
cardState: cardState,
|
|
32
|
+
onAuthorize: onAuthorize,
|
|
33
|
+
onClick: onClick,
|
|
34
|
+
onError: onError,
|
|
35
|
+
testId: testId,
|
|
36
|
+
ui: ui,
|
|
37
|
+
url: url
|
|
38
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
39
|
+
hideRetry: true
|
|
40
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
|
|
41
|
+
label: "errored-warning-icon",
|
|
42
|
+
size: "small",
|
|
43
|
+
primaryColor: token('color.icon.warning', R300),
|
|
44
|
+
testId: `${testId}-warning-icon`
|
|
45
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
46
|
+
message: {
|
|
47
|
+
descriptor: messages.could_not_load_link
|
|
48
|
+
}
|
|
49
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
|
|
50
|
+
actions: actions,
|
|
51
|
+
status: status
|
|
52
|
+
})));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default FlexibleErroredView;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
3
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
|
+
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { R300 } from '@atlaskit/theme/colors';
|
|
7
|
+
import { messages } from '../../../../messages';
|
|
8
|
+
import LockIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
9
|
+
import Footer from '../../components/flexible/footer';
|
|
10
|
+
import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
|
|
11
|
+
import Text from '../../../FlexibleCard/components/elements/text';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This view represent a Block Card with the 'Forbidden' status.
|
|
15
|
+
* It should have a "Try another account" button that will allow a user to connect another account and view the block card.
|
|
16
|
+
*
|
|
17
|
+
* @see SmartLinkStatus
|
|
18
|
+
* @see FlexibleCardProps
|
|
19
|
+
*/
|
|
20
|
+
const FlexibleForbiddenView = ({
|
|
21
|
+
cardState,
|
|
22
|
+
onAuthorize,
|
|
23
|
+
onClick,
|
|
24
|
+
onError,
|
|
25
|
+
testId = 'smart-block-forbidden-view',
|
|
26
|
+
ui,
|
|
27
|
+
url
|
|
28
|
+
}) => {
|
|
29
|
+
const status = cardState.status;
|
|
30
|
+
const actions = useMemo(() => onAuthorize ? [ForbiddenAction(onAuthorize)] : [], [onAuthorize]);
|
|
31
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
32
|
+
appearance: "block",
|
|
33
|
+
cardState: cardState,
|
|
34
|
+
onAuthorize: onAuthorize,
|
|
35
|
+
onClick: onClick,
|
|
36
|
+
onError: onError,
|
|
37
|
+
testId: testId,
|
|
38
|
+
ui: ui,
|
|
39
|
+
url: url
|
|
40
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
41
|
+
hideRetry: true
|
|
42
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
43
|
+
label: "forbidden-lock-icon",
|
|
44
|
+
size: "small",
|
|
45
|
+
primaryColor: token('color.icon.danger', R300),
|
|
46
|
+
testId: `${testId}-lock-icon`
|
|
47
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
48
|
+
message: {
|
|
49
|
+
descriptor: messages.invalid_permissions_description
|
|
50
|
+
}
|
|
51
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
|
|
52
|
+
actions: actions,
|
|
53
|
+
status: status
|
|
54
|
+
})));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default FlexibleForbiddenView;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
3
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
import WarningIcon from '@atlaskit/icon/glyph/warning';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
7
|
+
import { R300 } from '@atlaskit/theme/colors';
|
|
8
|
+
import Footer from '../../components/flexible/footer';
|
|
9
|
+
import Text from '../../../FlexibleCard/components/elements/text';
|
|
10
|
+
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This view represents a Block Card with a 'Not_Found' status.
|
|
14
|
+
*
|
|
15
|
+
* @see SmartLinkStatus
|
|
16
|
+
* @see FlexibleCardProps
|
|
17
|
+
*/
|
|
18
|
+
const FlexibleNotFoundView = ({
|
|
19
|
+
cardState,
|
|
20
|
+
onAuthorize,
|
|
21
|
+
onError,
|
|
22
|
+
ui,
|
|
23
|
+
url,
|
|
24
|
+
onClick,
|
|
25
|
+
testId = 'smart-block-not-found-view'
|
|
26
|
+
}) => {
|
|
27
|
+
const status = cardState.status;
|
|
28
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
29
|
+
appearance: "block",
|
|
30
|
+
cardState: cardState,
|
|
31
|
+
onAuthorize: onAuthorize,
|
|
32
|
+
onClick: onClick,
|
|
33
|
+
onError: onError,
|
|
34
|
+
testId: testId,
|
|
35
|
+
ui: ui,
|
|
36
|
+
url: url
|
|
37
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
38
|
+
hideRetry: true
|
|
39
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
|
|
40
|
+
label: "not-found-warning-icon",
|
|
41
|
+
size: "small",
|
|
42
|
+
primaryColor: token('color.icon.warning', R300),
|
|
43
|
+
testId: `${testId}-warning-icon`
|
|
44
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
45
|
+
message: {
|
|
46
|
+
descriptor: messages.not_found_description
|
|
47
|
+
},
|
|
48
|
+
testId: testId
|
|
49
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
|
|
50
|
+
status: status
|
|
51
|
+
})));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default FlexibleNotFoundView;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
3
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
import Text from '../../../FlexibleCard/components/elements/text';
|
|
6
|
+
import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
|
|
7
|
+
import Footer from '../../components/flexible/footer';
|
|
8
|
+
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This view represents a Block card that has an 'Unauthorized' status .
|
|
12
|
+
* It should have a "Connect" button that will allow a user to connect their account and view the block card.
|
|
13
|
+
*
|
|
14
|
+
* @see SmartLinkStatus
|
|
15
|
+
* @see UnauthorisedViewProps
|
|
16
|
+
*/
|
|
17
|
+
const FlexibleUnauthorisedView = ({
|
|
18
|
+
cardState,
|
|
19
|
+
providerName = '',
|
|
20
|
+
onAuthorize,
|
|
21
|
+
onClick,
|
|
22
|
+
onError,
|
|
23
|
+
testId = 'smart-block-unauthorized-view',
|
|
24
|
+
ui,
|
|
25
|
+
url
|
|
26
|
+
}) => {
|
|
27
|
+
const status = cardState.status;
|
|
28
|
+
const actions = useMemo(() => onAuthorize ? [AuthorizeAction(onAuthorize)] : [], [onAuthorize]);
|
|
29
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
30
|
+
appearance: "block",
|
|
31
|
+
cardState: cardState,
|
|
32
|
+
onAuthorize: onAuthorize,
|
|
33
|
+
onClick: onClick,
|
|
34
|
+
onError: onError,
|
|
35
|
+
testId: testId,
|
|
36
|
+
ui: ui,
|
|
37
|
+
url: url
|
|
38
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
39
|
+
hideRetry: true
|
|
40
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Text, {
|
|
41
|
+
message: {
|
|
42
|
+
descriptor: messages.connect_link_account_card_description,
|
|
43
|
+
values: {
|
|
44
|
+
context: providerName
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
|
|
48
|
+
actions: actions,
|
|
49
|
+
status: status
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default FlexibleUnauthorisedView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,7 +14,8 @@ export const ExpandedFrame = ({
|
|
|
14
14
|
minWidth,
|
|
15
15
|
maxWidth,
|
|
16
16
|
testId = 'expanded-frame',
|
|
17
|
-
inheritDimensions
|
|
17
|
+
inheritDimensions,
|
|
18
|
+
allowScrollBar = false
|
|
18
19
|
}) => {
|
|
19
20
|
const isInteractive = () => !isPlaceholder && (Boolean(href) || Boolean(onClick));
|
|
20
21
|
|
|
@@ -32,6 +33,8 @@ export const ExpandedFrame = ({
|
|
|
32
33
|
}, text)));
|
|
33
34
|
|
|
34
35
|
const renderContent = () => /*#__PURE__*/React.createElement(Content, {
|
|
36
|
+
"data-testid": "embed-content-wrapper",
|
|
37
|
+
allowScrollBar: allowScrollBar,
|
|
35
38
|
isInteractive: isInteractive()
|
|
36
39
|
}, children);
|
|
37
40
|
|
|
@@ -196,7 +196,6 @@ export const Content = styled.div`
|
|
|
196
196
|
z-index: 1;
|
|
197
197
|
width: 100%;
|
|
198
198
|
top: ${gridSize(4)};
|
|
199
|
-
overflow: hidden;
|
|
200
199
|
height: calc(100% - ${gridSize(4)});
|
|
201
200
|
transition: box-shadow 0.3s;
|
|
202
201
|
|
|
@@ -224,6 +223,10 @@ export const Content = styled.div`
|
|
|
224
223
|
return '';
|
|
225
224
|
}
|
|
226
225
|
}};
|
|
226
|
+
|
|
227
|
+
${({
|
|
228
|
+
allowScrollBar
|
|
229
|
+
}) => allowScrollBar ? 'overflow: auto;' : 'overflow: hidden;'}
|
|
227
230
|
`;
|
|
228
231
|
export const Image = styled.img`
|
|
229
232
|
${({
|
|
@@ -55,7 +55,8 @@ export const EmbedCardForbiddenView = ({
|
|
|
55
55
|
isSelected: isSelected,
|
|
56
56
|
inheritDimensions: inheritDimensions,
|
|
57
57
|
onClick: onClick,
|
|
58
|
-
testId: testId
|
|
58
|
+
testId: testId,
|
|
59
|
+
allowScrollBar: true
|
|
59
60
|
}, /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
|
|
60
61
|
image: LockImage,
|
|
61
62
|
title: "invalid_permissions",
|
|
@@ -22,7 +22,8 @@ export const EmbedCardNotFoundView = ({
|
|
|
22
22
|
isSelected: isSelected,
|
|
23
23
|
inheritDimensions: inheritDimensions,
|
|
24
24
|
onClick: onClick,
|
|
25
|
-
testId: testId
|
|
25
|
+
testId: testId,
|
|
26
|
+
allowScrollBar: true
|
|
26
27
|
}, /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
|
|
27
28
|
image: NotFoundImage,
|
|
28
29
|
title: "not_found_title",
|
|
@@ -29,7 +29,8 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
29
29
|
isSelected: isSelected,
|
|
30
30
|
inheritDimensions: inheritDimensions,
|
|
31
31
|
onClick: onClick,
|
|
32
|
-
testId: testId
|
|
32
|
+
testId: testId,
|
|
33
|
+
allowScrollBar: true
|
|
33
34
|
}, /*#__PURE__*/React.createElement(EmbedCardUnresolvedView, {
|
|
34
35
|
image: (_context$image = context === null || context === void 0 ? void 0 : context.image) !== null && _context$image !== void 0 ? _context$image : UnauthorisedImage,
|
|
35
36
|
title: "connect_link_account_card_name",
|
|
@@ -38,7 +38,7 @@ export const EmbedCardUnresolvedView = ({
|
|
|
38
38
|
css: {
|
|
39
39
|
fontSize: gridSize(2.5),
|
|
40
40
|
marginBottom: gridSize(1.5),
|
|
41
|
-
|
|
41
|
+
maxWidth: gridSize(50),
|
|
42
42
|
textAlign: 'center'
|
|
43
43
|
},
|
|
44
44
|
"data-testid": `${testId}-unresolved-title`
|
|
@@ -51,7 +51,7 @@ export const EmbedCardUnresolvedView = ({
|
|
|
51
51
|
fontSize: fontSize(),
|
|
52
52
|
marginBottom: gridSize(2.5),
|
|
53
53
|
textAlign: 'center',
|
|
54
|
-
|
|
54
|
+
maxWidth: gridSize(50),
|
|
55
55
|
lineHeight: gridSize(3)
|
|
56
56
|
},
|
|
57
57
|
"data-testid": `${testId}-unresolved-description`
|
|
@@ -2,4 +2,5 @@ export { default as FooterBlock } from './footer-block';
|
|
|
2
2
|
export { default as MetadataBlock } from './metadata-block';
|
|
3
3
|
export { default as PreviewBlock } from './preview-block';
|
|
4
4
|
export { default as SnippetBlock } from './snippet-block';
|
|
5
|
-
export { default as TitleBlock } from './title-block';
|
|
5
|
+
export { default as TitleBlock } from './title-block';
|
|
6
|
+
export { default as CustomBlock } from './block';
|
|
@@ -6,6 +6,7 @@ import extractFlexibleLinkContext from '../../extractors/flexible';
|
|
|
6
6
|
import { extractErrorIcon } from '../../extractors/flexible/icon';
|
|
7
7
|
import { handleOnClick } from '../../utils';
|
|
8
8
|
import { extractProvider } from '@atlaskit/linking-common/extractors';
|
|
9
|
+
import extractProviderIcon from '../../extractors/flexible/icon/extract-provider-icon';
|
|
9
10
|
export const getContextByStatus = (url, status, details, renderers) => {
|
|
10
11
|
switch (status) {
|
|
11
12
|
case SmartLinkStatus.Pending:
|
|
@@ -25,10 +26,12 @@ export const getContextByStatus = (url, status, details, renderers) => {
|
|
|
25
26
|
case SmartLinkStatus.Fallback:
|
|
26
27
|
default:
|
|
27
28
|
const linkIcon = extractErrorIcon(details, status);
|
|
29
|
+
const provider = extractProviderIcon(details === null || details === void 0 ? void 0 : details.data);
|
|
28
30
|
return {
|
|
29
31
|
linkIcon,
|
|
30
32
|
title: url,
|
|
31
|
-
url
|
|
33
|
+
url,
|
|
34
|
+
provider
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
import { ActionName } from '../../../../constants';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a CustomActionItem with a "Connect" default message
|
|
7
|
+
*
|
|
8
|
+
* @see CustomActionItem
|
|
9
|
+
* @param onAuthorize a function that will be called on the click of the button
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export var AuthorizeAction = function AuthorizeAction(onAuthorize) {
|
|
13
|
+
return {
|
|
14
|
+
name: ActionName.CustomAction,
|
|
15
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.connect_link_account_card),
|
|
16
|
+
onClick: onAuthorize
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
import { ActionName } from '../../../../constants';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a CustomActionItem with a "Try Another Account" default message
|
|
7
|
+
*
|
|
8
|
+
* @see CustomActionItem
|
|
9
|
+
* @param onAuthorize a function that will be called on the click of the button
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export var ForbiddenAction = function ForbiddenAction(onAuthorize) {
|
|
13
|
+
return {
|
|
14
|
+
name: ActionName.CustomAction,
|
|
15
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.try_another_account),
|
|
16
|
+
onClick: onAuthorize
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
import { ActionName } from '../../../../constants';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a CustomActionItem with a "Retry" default message
|
|
7
|
+
*
|
|
8
|
+
* @see CustomActionItem
|
|
9
|
+
* @param onRetry a function that will be called on the click of the "Retry" button
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export var RetryAction = function RetryAction(onRetry) {
|
|
13
|
+
return {
|
|
14
|
+
name: ActionName.CustomAction,
|
|
15
|
+
onClick: onRetry,
|
|
16
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.try_again)
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { css } from '@emotion/react';
|
|
7
|
+
import { Provider } from '../../../../FlexibleCard/components/elements';
|
|
8
|
+
import ElementGroup from '../../../../FlexibleCard/components/blocks/element-group';
|
|
9
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
10
|
+
import ActionGroup from '../../../../FlexibleCard/components/blocks/action-group';
|
|
11
|
+
|
|
12
|
+
var getActionGroupStyles = function getActionGroupStyles(size) {
|
|
13
|
+
if (size === SmartLinkSize.XLarge) {
|
|
14
|
+
// The biggest height of the action button exceeds the max line-height
|
|
15
|
+
// of the elements causing the action on the block with x-large size to
|
|
16
|
+
// get cut at the bottom.
|
|
17
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-height: 2rem;\n "])));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var providerStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n span:first-child {\n margin-right: 0.375rem;\n }\n"])));
|
|
22
|
+
/**
|
|
23
|
+
* This Components is a footer that is used in a Block Card with Flexible UI.
|
|
24
|
+
* It contains a provider icon if provider is present and an actions list if one is passed.
|
|
25
|
+
* To be shown as a part of Flexible UI, needs to be wrapped inside of a CustomBlock
|
|
26
|
+
*
|
|
27
|
+
* @see CustomBlock
|
|
28
|
+
* @param props are the data required for the block, such as actions to be displayed.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var Footer = function Footer(props) {
|
|
32
|
+
var actions = props.actions,
|
|
33
|
+
_props$size = props.size,
|
|
34
|
+
size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
|
|
35
|
+
_props$testId = props.testId,
|
|
36
|
+
testId = _props$testId === void 0 ? 'smart-block-card-footer' : _props$testId;
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
"data-testid": testId
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Provider, {
|
|
40
|
+
testId: "".concat(testId, "-provider"),
|
|
41
|
+
overrideCss: providerStyles
|
|
42
|
+
}), actions && actions.length > 0 ? /*#__PURE__*/React.createElement(ElementGroup, {
|
|
43
|
+
testId: "smart-element-group-actions",
|
|
44
|
+
align: SmartLinkAlignment.Right,
|
|
45
|
+
direction: SmartLinkDirection.Horizontal,
|
|
46
|
+
overrideCss: getActionGroupStyles(size),
|
|
47
|
+
width: SmartLinkWidth.Flexible
|
|
48
|
+
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
49
|
+
items: actions,
|
|
50
|
+
appearance: "default"
|
|
51
|
+
})) : null);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default Footer;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
3
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
|
+
import { messages } from '../../../../messages';
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { R300 } from '@atlaskit/theme/colors';
|
|
7
|
+
import WarningIcon from '@atlaskit/icon/glyph/warning';
|
|
8
|
+
import Footer from '../../components/flexible/footer';
|
|
9
|
+
import { RetryAction } from '../../actions/flexible/RetryAction';
|
|
10
|
+
import { CustomBlock } from '../../../FlexibleCard/components/blocks';
|
|
11
|
+
import Text from '../../../FlexibleCard/components/elements/text';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This view represents a Block Card with an 'Errored' status.
|
|
15
|
+
*
|
|
16
|
+
* @see SmartLinkStatus
|
|
17
|
+
* @see FlexibleCardProps
|
|
18
|
+
*/
|
|
19
|
+
var FlexibleErroredView = function FlexibleErroredView(_ref) {
|
|
20
|
+
var cardState = _ref.cardState,
|
|
21
|
+
onAuthorize = _ref.onAuthorize,
|
|
22
|
+
onError = _ref.onError,
|
|
23
|
+
ui = _ref.ui,
|
|
24
|
+
url = _ref.url,
|
|
25
|
+
onClick = _ref.onClick,
|
|
26
|
+
_ref$testId = _ref.testId,
|
|
27
|
+
testId = _ref$testId === void 0 ? 'smart-block-errored-view' : _ref$testId;
|
|
28
|
+
var status = cardState.status;
|
|
29
|
+
var actions = useMemo(function () {
|
|
30
|
+
return onAuthorize ? [RetryAction(onAuthorize)] : [];
|
|
31
|
+
}, [onAuthorize]);
|
|
32
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
33
|
+
cardState: cardState,
|
|
34
|
+
onAuthorize: onAuthorize,
|
|
35
|
+
onClick: onClick,
|
|
36
|
+
onError: onError,
|
|
37
|
+
testId: testId,
|
|
38
|
+
ui: ui,
|
|
39
|
+
url: url
|
|
40
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
41
|
+
hideRetry: true
|
|
42
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(WarningIcon, {
|
|
43
|
+
label: "errored-warning-icon",
|
|
44
|
+
size: "small",
|
|
45
|
+
primaryColor: token('color.icon.warning', R300),
|
|
46
|
+
testId: "".concat(testId, "-warning-icon")
|
|
47
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
48
|
+
message: {
|
|
49
|
+
descriptor: messages.could_not_load_link
|
|
50
|
+
}
|
|
51
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
|
|
52
|
+
actions: actions,
|
|
53
|
+
status: status
|
|
54
|
+
})));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default FlexibleErroredView;
|