@atlaskit/smart-card 23.4.0 → 23.4.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/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/FlexibleCard/components/blocks/index.js +9 -1
- package/dist/cjs/view/FlexibleCard/utils.js +5 -1
- package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +8 -1
- package/dist/cjs/view/InlineCard/index.js +1 -0
- 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/FlexibleCard/components/blocks/index.js +2 -1
- package/dist/es2019/view/FlexibleCard/utils.js +4 -1
- package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +7 -1
- package/dist/es2019/view/InlineCard/index.js +1 -0
- 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/FlexibleCard/components/blocks/index.js +2 -1
- package/dist/esm/view/FlexibleCard/utils.js +4 -1
- package/dist/esm/view/InlineCard/UnauthorisedView/index.js +7 -1
- package/dist/esm/view/InlineCard/index.js +1 -0
- 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/FlexibleCard/components/blocks/index.d.ts +1 -0
- package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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 {};
|
|
@@ -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
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import Button from '@atlaskit/button/custom-theme-button';
|
|
3
4
|
import LockIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
@@ -30,6 +31,7 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
30
31
|
|
|
31
32
|
_defineProperty(this, "renderMessage", () => {
|
|
32
33
|
const {
|
|
34
|
+
context,
|
|
33
35
|
onAuthorise,
|
|
34
36
|
url
|
|
35
37
|
} = this.props;
|
|
@@ -40,7 +42,11 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
40
42
|
component: IconStyledButton,
|
|
41
43
|
onClick: this.handleConnectAccount,
|
|
42
44
|
testId: "button-connect-account"
|
|
43
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.
|
|
45
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_link_account_card_name, {
|
|
46
|
+
values: {
|
|
47
|
+
context
|
|
48
|
+
}
|
|
49
|
+
}))));
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
|
|
@@ -75,6 +75,7 @@ export const InlineCard = ({
|
|
|
75
75
|
const provider = extractProvider(cardDetails);
|
|
76
76
|
return /*#__PURE__*/React.createElement(InlineCardUnauthorizedView, {
|
|
77
77
|
icon: provider && provider.icon,
|
|
78
|
+
context: provider && provider.text,
|
|
78
79
|
url: url,
|
|
79
80
|
isSelected: isSelected,
|
|
80
81
|
onClick: handleFrameClick,
|
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;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
|
|
21
|
+
var cardState = _ref.cardState,
|
|
22
|
+
onAuthorize = _ref.onAuthorize,
|
|
23
|
+
onClick = _ref.onClick,
|
|
24
|
+
onError = _ref.onError,
|
|
25
|
+
_ref$testId = _ref.testId,
|
|
26
|
+
testId = _ref$testId === void 0 ? 'smart-block-forbidden-view' : _ref$testId,
|
|
27
|
+
ui = _ref.ui,
|
|
28
|
+
url = _ref.url;
|
|
29
|
+
var status = cardState.status;
|
|
30
|
+
var actions = useMemo(function () {
|
|
31
|
+
return onAuthorize ? [ForbiddenAction(onAuthorize)] : [];
|
|
32
|
+
}, [onAuthorize]);
|
|
33
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
34
|
+
appearance: "block",
|
|
35
|
+
cardState: cardState,
|
|
36
|
+
onAuthorize: onAuthorize,
|
|
37
|
+
onClick: onClick,
|
|
38
|
+
onError: onError,
|
|
39
|
+
testId: testId,
|
|
40
|
+
ui: ui,
|
|
41
|
+
url: url
|
|
42
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
43
|
+
hideRetry: true
|
|
44
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
45
|
+
label: "forbidden-lock-icon",
|
|
46
|
+
size: "small",
|
|
47
|
+
primaryColor: token('color.icon.danger', R300),
|
|
48
|
+
testId: "".concat(testId, "-lock-icon")
|
|
49
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
50
|
+
message: {
|
|
51
|
+
descriptor: messages.invalid_permissions_description
|
|
52
|
+
}
|
|
53
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
|
|
54
|
+
actions: actions,
|
|
55
|
+
status: status
|
|
56
|
+
})));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
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
|
+
var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
|
|
19
|
+
var cardState = _ref.cardState,
|
|
20
|
+
onAuthorize = _ref.onAuthorize,
|
|
21
|
+
onError = _ref.onError,
|
|
22
|
+
ui = _ref.ui,
|
|
23
|
+
url = _ref.url,
|
|
24
|
+
onClick = _ref.onClick,
|
|
25
|
+
_ref$testId = _ref.testId,
|
|
26
|
+
testId = _ref$testId === void 0 ? 'smart-block-not-found-view' : _ref$testId;
|
|
27
|
+
var 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: "".concat(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;
|