@atlaskit/smart-card 26.51.0 → 26.52.1
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 +19 -0
- package/analytics.spec.yaml +18 -0
- package/dist/cjs/extractors/flexible/actions/index.js +5 -2
- package/dist/cjs/extractors/flexible/index.js +1 -5
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
- package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +76 -0
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +8 -9
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +9 -8
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
- package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-summary-viewed/index.js +7 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +46 -26
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +0 -8
- package/dist/cjs/view/HoverCard/components/ContentContainer.js +1 -0
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -0
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/flexible/actions/index.js +6 -2
- package/dist/es2019/extractors/flexible/index.js +1 -5
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
- package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +47 -0
- package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +7 -5
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -7
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
- package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-summary-viewed/index.js +7 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +48 -22
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +0 -8
- package/dist/es2019/view/HoverCard/components/ContentContainer.js +1 -0
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +1 -0
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/flexible/actions/index.js +5 -2
- package/dist/esm/extractors/flexible/index.js +1 -5
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +0 -1
- package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +66 -0
- package/dist/esm/view/FlexibleCard/components/actions/download-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +9 -7
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -7
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
- package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-event-summary-viewed/index.js +7 -0
- package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +46 -26
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +0 -8
- package/dist/esm/view/HoverCard/components/ContentContainer.js +1 -0
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +1 -0
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/__fixtures__/dropbox-file.d.ts +3 -0
- package/dist/types/common/analytics/generated/analytics.types.d.ts +10 -4
- package/dist/types/extractors/flexible/actions/index.d.ts +1 -1
- package/dist/types/state/flexible-ui-context/types.d.ts +2 -12
- package/dist/types/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
- package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
- package/dist/types-ts4.5/__fixtures__/dropbox-file.d.ts +3 -0
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +10 -4
- package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +1 -1
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +2 -12
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/index.d.ts +4 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/download-action/types.d.ts +2 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/index.d.ts +2 -2
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/follow-action/types.d.ts +2 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
- package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +11 -2
- package/package.json +6 -6
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +0 -72
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +0 -47
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +0 -65
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/index.d.ts +0 -4
- package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/download-action/types.d.ts +0 -5
- /package/dist/cjs/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
- /package/dist/es2019/view/FlexibleCard/components/actions/{action/download-action → download-action}/types.js +0 -0
- /package/dist/{esm/view/FlexibleCard/components/actions/action/download-action → es2019/view/FlexibleCard/components/actions/follow-action}/types.js +0 -0
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
|
|
3
|
-
import React
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { ActionName } from '../../../../../constants';
|
|
5
6
|
import { messages } from '../../../../../messages';
|
|
6
|
-
import {
|
|
7
|
+
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
7
8
|
import ServerAction from '../action/server-action';
|
|
8
9
|
import UnfollowIcon from './unfollow-icon';
|
|
9
10
|
const FollowAction = props => {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var _context$actions, _context$actions2;
|
|
12
|
+
const context = useFlexibleUiContext();
|
|
13
|
+
if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
|
|
12
14
|
return null;
|
|
13
15
|
}
|
|
14
16
|
const {
|
|
15
17
|
value,
|
|
16
18
|
...data
|
|
17
|
-
} = context.
|
|
19
|
+
} = context === null || context === void 0 ? void 0 : (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction];
|
|
18
20
|
const message = value ? messages.follow : messages.unfollow;
|
|
19
21
|
const icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
|
|
20
22
|
label: "Follow"
|
|
@@ -2,6 +2,7 @@ import { ActionName } from '../../../../constants';
|
|
|
2
2
|
import { createDataAction, createUIAction } from './utils';
|
|
3
3
|
export { default as FollowAction } from './follow-action';
|
|
4
4
|
export { default as PreviewAction } from './preview-action';
|
|
5
|
+
export { default as DownloadAction } from './download-action';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a DeleteAction component. Accepts default ActionProps, but defaults
|
|
@@ -23,13 +24,6 @@ export const EditAction = createUIAction(ActionName.EditAction);
|
|
|
23
24
|
*/
|
|
24
25
|
export const ViewAction = createDataAction(ActionName.ViewAction);
|
|
25
26
|
|
|
26
|
-
/**
|
|
27
|
-
* Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
|
|
28
|
-
* to the text 'Download' inside the button.
|
|
29
|
-
* @see Action
|
|
30
|
-
*/
|
|
31
|
-
export const DownloadAction = createDataAction(ActionName.DownloadAction);
|
|
32
|
-
|
|
33
27
|
/**
|
|
34
28
|
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
35
29
|
* your own icon or text.
|
|
@@ -9,8 +9,6 @@ import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
|
9
9
|
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
10
10
|
import ViewAction from './action/view-action';
|
|
11
11
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
12
|
-
import DownloadAction from './action/download-action';
|
|
13
|
-
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
14
12
|
const actionMappings = {
|
|
15
13
|
[ActionName.CustomAction]: {
|
|
16
14
|
component: Action,
|
|
@@ -48,17 +46,6 @@ const actionMappings = {
|
|
|
48
46
|
}),
|
|
49
47
|
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
|
|
50
48
|
}
|
|
51
|
-
},
|
|
52
|
-
[ActionName.DownloadAction]: {
|
|
53
|
-
component: DownloadAction,
|
|
54
|
-
props: {
|
|
55
|
-
testId: 'smart-action-download-action',
|
|
56
|
-
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
|
|
57
|
-
icon: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
58
|
-
label: "Download"
|
|
59
|
-
}),
|
|
60
|
-
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
|
|
61
|
-
}
|
|
62
49
|
}
|
|
63
50
|
};
|
|
64
51
|
const getContextKey = name => {
|
|
@@ -73,7 +60,6 @@ const getActionData = (actionName, contextKey, context) => {
|
|
|
73
60
|
const data = context[contextKey];
|
|
74
61
|
switch (actionName) {
|
|
75
62
|
case ActionName.ViewAction:
|
|
76
|
-
case ActionName.DownloadAction:
|
|
77
63
|
return data;
|
|
78
64
|
default:
|
|
79
65
|
return undefined;
|
|
@@ -10,6 +10,13 @@ const AIEventSummaryViewed = ({
|
|
|
10
10
|
fireEvent('ui.summary.viewed', {
|
|
11
11
|
fromCache
|
|
12
12
|
});
|
|
13
|
+
if (fromCache) {
|
|
14
|
+
fireEvent('track.aiInteraction.initiated', {
|
|
15
|
+
aiFeatureName: 'Smart Links Summary',
|
|
16
|
+
proactiveAIGenerated: 1,
|
|
17
|
+
userGeneratedAI: 0
|
|
18
|
+
});
|
|
19
|
+
}
|
|
13
20
|
}, [fireEvent, fromCache]);
|
|
14
21
|
return null;
|
|
15
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useCallback, useMemo, useRef,
|
|
2
|
+
import React, { useCallback, useMemo, useRef, useEffect } from 'react';
|
|
3
3
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
4
|
import { Box, Inline } from '@atlaskit/primitives';
|
|
5
5
|
import { ActionName, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
|
|
@@ -16,16 +16,46 @@ import AISummary from '../../../../../common/ai-summary';
|
|
|
16
16
|
import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
|
|
17
17
|
import AIEventSummaryViewed from '../ai-event-summary-viewed';
|
|
18
18
|
import AIEventErrorViewed from '../ai-event-error-viewed';
|
|
19
|
+
import { di } from 'react-magnetic-di';
|
|
20
|
+
export const AISummaryBlockErrorIndicator = ({
|
|
21
|
+
showErrorIndicator,
|
|
22
|
+
error,
|
|
23
|
+
testId
|
|
24
|
+
}) => {
|
|
25
|
+
return showErrorIndicator ? /*#__PURE__*/React.createElement(Inline, {
|
|
26
|
+
grow: "fill"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
|
|
28
|
+
reason: error
|
|
29
|
+
}), /*#__PURE__*/React.createElement(AIStateIndicator, {
|
|
30
|
+
error: error,
|
|
31
|
+
state: 'error',
|
|
32
|
+
testId: testId
|
|
33
|
+
})) : null;
|
|
34
|
+
};
|
|
35
|
+
export const AISummaryBlockStatusIndicator = ({
|
|
36
|
+
showStatusIndicator,
|
|
37
|
+
metadata,
|
|
38
|
+
status,
|
|
39
|
+
testId
|
|
40
|
+
}) => {
|
|
41
|
+
const metadataElements = renderElementItems(metadata);
|
|
42
|
+
return showStatusIndicator ? /*#__PURE__*/React.createElement(AIStateIndicator, {
|
|
43
|
+
state: status,
|
|
44
|
+
testId: `${testId}-state-indicator`
|
|
45
|
+
}) : /*#__PURE__*/React.createElement(ElementGroup, {
|
|
46
|
+
width: SmartLinkWidth.FitToContent,
|
|
47
|
+
testId: `${testId}-metadata-group`
|
|
48
|
+
}, metadataElements);
|
|
49
|
+
};
|
|
19
50
|
const AISummaryBlockResolvedView = props => {
|
|
20
51
|
const {
|
|
21
52
|
actions = [],
|
|
22
|
-
metadata,
|
|
23
53
|
onActionMenuOpenChange,
|
|
24
54
|
size = SmartLinkSize.Medium,
|
|
25
55
|
testId,
|
|
26
|
-
aiSummaryMinHeight
|
|
56
|
+
aiSummaryMinHeight,
|
|
57
|
+
metadata
|
|
27
58
|
} = props;
|
|
28
|
-
const metadataElements = renderElementItems(metadata);
|
|
29
59
|
const {
|
|
30
60
|
fireEvent
|
|
31
61
|
} = useAnalyticsEvents();
|
|
@@ -48,15 +78,11 @@ const AISummaryBlockResolvedView = props => {
|
|
|
48
78
|
status === 'loading' && !!content;
|
|
49
79
|
const isSummarisedOnMountRef = useRef(status === 'done');
|
|
50
80
|
const isErroredOnMountRef = useRef(status === 'error');
|
|
51
|
-
const [showAISummaryErrorMessage, setShowAISummaryErrorMessage] = useState(false);
|
|
52
81
|
useEffect(() => {
|
|
53
82
|
// if the error was apparent on mount and the status is changed to loading we can
|
|
54
83
|
// clear the initial error on mount state
|
|
55
84
|
if (isErroredOnMountRef.current && status === 'loading') {
|
|
56
85
|
isErroredOnMountRef.current = false;
|
|
57
|
-
} else {
|
|
58
|
-
// if a new error occurs and it was not an apparent error on mount, we can show the error message
|
|
59
|
-
setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
|
|
60
86
|
}
|
|
61
87
|
}, [status]);
|
|
62
88
|
const combinedActions = useMemo(() => {
|
|
@@ -66,6 +92,11 @@ const AISummaryBlockResolvedView = props => {
|
|
|
66
92
|
name: ActionName.CustomAction,
|
|
67
93
|
onClick: () => {
|
|
68
94
|
fireEvent('ui.button.clicked.aiSummary', {});
|
|
95
|
+
fireEvent('track.aiInteraction.initiated', {
|
|
96
|
+
aiFeatureName: 'Smart Links Summary',
|
|
97
|
+
proactiveAIGenerated: 0,
|
|
98
|
+
userGeneratedAI: 1
|
|
99
|
+
});
|
|
69
100
|
summariseUrl();
|
|
70
101
|
},
|
|
71
102
|
testId: `${testId}-ai-summary-action`,
|
|
@@ -99,25 +130,20 @@ const AISummaryBlockResolvedView = props => {
|
|
|
99
130
|
alignInline: "end",
|
|
100
131
|
grow: "fill",
|
|
101
132
|
spread: "space-between"
|
|
102
|
-
}, /*#__PURE__*/React.createElement(Box, null,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, metadataElements)), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
133
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AISummaryBlockStatusIndicator, {
|
|
134
|
+
metadata: metadata,
|
|
135
|
+
showStatusIndicator: !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done'),
|
|
136
|
+
status: status,
|
|
137
|
+
testId: testId
|
|
138
|
+
})), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
109
139
|
onDropdownOpenChange: onDropdownOpenChange,
|
|
110
140
|
items: combinedActions,
|
|
111
141
|
appearance: "default",
|
|
112
142
|
size: size
|
|
113
|
-
}))),
|
|
114
|
-
|
|
115
|
-
}, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
|
|
116
|
-
reason: error
|
|
117
|
-
}), /*#__PURE__*/React.createElement(AIStateIndicator, {
|
|
143
|
+
}))), /*#__PURE__*/React.createElement(AISummaryBlockErrorIndicator, {
|
|
144
|
+
showErrorIndicator: !isErroredOnMountRef.current && status === 'error',
|
|
118
145
|
error: error,
|
|
119
|
-
state: status,
|
|
120
146
|
testId: testId
|
|
121
|
-
}))
|
|
147
|
+
}));
|
|
122
148
|
};
|
|
123
149
|
export default AISummaryBlockResolvedView;
|
|
@@ -130,14 +130,6 @@ export const filterActionItems = (items = [], context) => {
|
|
|
130
130
|
case ActionName.CustomAction:
|
|
131
131
|
// Named and custom actions that user defines.
|
|
132
132
|
return Boolean(ActionName[item.name]);
|
|
133
|
-
case ActionName.DownloadAction:
|
|
134
|
-
// Remove once DownloadAction is refactored to context.action
|
|
135
|
-
// https://product-fabric.atlassian.net/browse/EDM-9545
|
|
136
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
|
|
137
|
-
// Remove once FollowAction is refactored to context.action
|
|
138
|
-
// https://product-fabric.atlassian.net/browse/EDM-9559
|
|
139
|
-
case ActionName.FollowAction:
|
|
140
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
|
|
141
133
|
// Remove once ViewAction is retired
|
|
142
134
|
// https://product-fabric.atlassian.net/browse/EDM-9547
|
|
143
135
|
case ActionName.ViewAction:
|
|
@@ -9,6 +9,7 @@ import { hoverCardClassName } from './HoverCardContent';
|
|
|
9
9
|
import { useAISummary } from '../../../state/hooks/use-ai-summary';
|
|
10
10
|
import { useSmartCardState } from '../../../state/store';
|
|
11
11
|
import { extractAri, extractLink } from '@atlaskit/link-extractors';
|
|
12
|
+
import { di } from 'react-magnetic-di';
|
|
12
13
|
const ConnectedAIPrismContainer = ({
|
|
13
14
|
children,
|
|
14
15
|
isAIEnabled = false,
|
|
@@ -14,6 +14,7 @@ import { getCanBeDatasource } from '../../../../../state/helpers';
|
|
|
14
14
|
import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
|
|
15
15
|
import { extractAri, extractLink } from '@atlaskit/link-extractors';
|
|
16
16
|
import { SmartLinkStatus } from '../../../../../constants';
|
|
17
|
+
import { di } from 'react-magnetic-di';
|
|
17
18
|
export const toFooterActions = (cardActions, onActionClick) => {
|
|
18
19
|
const followAction = {
|
|
19
20
|
hideIcon: true,
|
|
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
|
|
|
7
7
|
import LinkWarningModal from './LinkWarningModal';
|
|
8
8
|
const PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/smart-card",
|
|
10
|
-
packageVersion: "26.
|
|
10
|
+
packageVersion: "26.52.1",
|
|
11
11
|
componentName: 'linkUrl'
|
|
12
12
|
};
|
|
13
13
|
const Link = withLinkClickedEvent('a');
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { ActionName } from '../../../constants';
|
|
3
|
+
import { extractDownloadAction } from './extract-download-action';
|
|
3
4
|
import { extractPreviewAction } from './extract-preview-action';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import extractFollowAction from './extract-follow-action';
|
|
6
|
+
var extractActions = function extractActions(response, data, actionOptions, id) {
|
|
7
|
+
var _action;
|
|
8
|
+
var action = (_action = {}, _defineProperty(_action, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_action, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_action, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _action);
|
|
6
9
|
return Object.values(action).some(function (value) {
|
|
7
10
|
return Boolean(value);
|
|
8
11
|
}) ? action : undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { extractSummary } from '../common/primitives';
|
|
2
2
|
import extractActions from './actions';
|
|
3
|
-
import extractFollowAction from './actions/extract-follow-action';
|
|
4
3
|
import { extractLinkIcon } from './icon';
|
|
5
4
|
import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
|
|
6
5
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
@@ -10,7 +9,6 @@ import extractProviderIcon from './icon/extract-provider-icon';
|
|
|
10
9
|
import extractPreview from './extract-preview';
|
|
11
10
|
import extractState from './extract-state';
|
|
12
11
|
import { extractLatestCommit } from './latest-commit';
|
|
13
|
-
import { extractDownloadAction } from './actions/extract-download-action';
|
|
14
12
|
import { extractViewAction } from './actions/extract-view-action';
|
|
15
13
|
var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
16
14
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -24,7 +22,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
|
24
22
|
var data = response.data;
|
|
25
23
|
var url = extractLink(data);
|
|
26
24
|
return {
|
|
27
|
-
actions: extractActions(response, actionOptions),
|
|
25
|
+
actions: extractActions(response, data, actionOptions, id),
|
|
28
26
|
assignedToGroup: extractPersonAssignedToAsArray(data),
|
|
29
27
|
attachmentCount: extractAttachmentCount(data),
|
|
30
28
|
authorGroup: extractPersonCreatedBy(data),
|
|
@@ -40,9 +38,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
|
|
|
40
38
|
assignedTo: extractAssignedTo(data),
|
|
41
39
|
createdOn: extractDateCreated(data),
|
|
42
40
|
dueOn: extractDueOn(data),
|
|
43
|
-
followAction: extractFollowAction(response, actionOptions, id),
|
|
44
41
|
viewAction: extractViewAction(data, actionOptions),
|
|
45
|
-
downloadAction: extractDownloadAction(data, actionOptions),
|
|
46
42
|
latestCommit: extractLatestCommit(data),
|
|
47
43
|
linkIcon: extractLinkIcon(response, renderers),
|
|
48
44
|
location: extractLocation(data),
|
|
@@ -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.
|
|
18
|
+
packageVersion: "26.52.1"
|
|
19
19
|
};
|
|
20
20
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
21
21
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -40,7 +40,6 @@ var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
|
|
|
40
40
|
};
|
|
41
41
|
}, []);
|
|
42
42
|
return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
|
|
43
|
-
showPreview: true,
|
|
44
43
|
testId: testId,
|
|
45
44
|
title: title
|
|
46
45
|
}), /*#__PURE__*/React.createElement(LockIcon, {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["onClick"];
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
7
|
+
import { downloadUrl as download } from '../../../../../utils';
|
|
8
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
9
|
+
import { ActionName } from '../../../../../constants';
|
|
10
|
+
import { messages } from '../../../../../messages';
|
|
11
|
+
import Action from '../action';
|
|
12
|
+
import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
13
|
+
import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
|
|
14
|
+
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
15
|
+
var DownloadAction = function DownloadAction(_ref) {
|
|
16
|
+
var _context$actions;
|
|
17
|
+
var onClickCallback = _ref.onClick,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
var context = useFlexibleUiContext();
|
|
20
|
+
var analytics = useFlexibleUiAnalyticsContext();
|
|
21
|
+
var invoke = useInvokeClientAction({
|
|
22
|
+
analytics: analytics
|
|
23
|
+
});
|
|
24
|
+
var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
|
|
25
|
+
var onClick = useCallback(function () {
|
|
26
|
+
if (data !== null && data !== void 0 && data.downloadUrl) {
|
|
27
|
+
invoke({
|
|
28
|
+
actionType: ActionName.DownloadAction,
|
|
29
|
+
actionFn: function () {
|
|
30
|
+
var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
31
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
|
+
while (1) switch (_context.prev = _context.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
return _context.abrupt("return", download(data === null || data === void 0 ? void 0 : data.downloadUrl));
|
|
35
|
+
case 1:
|
|
36
|
+
case "end":
|
|
37
|
+
return _context.stop();
|
|
38
|
+
}
|
|
39
|
+
}, _callee);
|
|
40
|
+
}));
|
|
41
|
+
function actionFn() {
|
|
42
|
+
return _actionFn.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
return actionFn;
|
|
45
|
+
}(),
|
|
46
|
+
// These values have already been set in analytics context.
|
|
47
|
+
// We only pass these here for ufo experience.
|
|
48
|
+
display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
|
|
49
|
+
extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
|
|
50
|
+
});
|
|
51
|
+
if (onClickCallback) {
|
|
52
|
+
onClickCallback();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [analytics, data === null || data === void 0 ? void 0 : data.downloadUrl, invoke, onClickCallback]);
|
|
56
|
+
return data ? /*#__PURE__*/React.createElement(Action, _extends({
|
|
57
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
|
|
58
|
+
icon: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
59
|
+
label: "Download"
|
|
60
|
+
}),
|
|
61
|
+
onClick: onClick,
|
|
62
|
+
testId: "smart-action-download-action",
|
|
63
|
+
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
|
|
64
|
+
}, data, props)) : null;
|
|
65
|
+
};
|
|
66
|
+
export default DownloadAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,20 +2,22 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["value"];
|
|
4
4
|
import InviteTeamIcon from '@atlaskit/icon/glyph/invite-team';
|
|
5
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
6
6
|
import { FormattedMessage } from 'react-intl-next';
|
|
7
|
+
import { ActionName } from '../../../../../constants';
|
|
7
8
|
import { messages } from '../../../../../messages';
|
|
8
|
-
import {
|
|
9
|
+
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
|
|
9
10
|
import ServerAction from '../action/server-action';
|
|
10
11
|
import UnfollowIcon from './unfollow-icon';
|
|
11
12
|
var FollowAction = function FollowAction(props) {
|
|
12
|
-
var
|
|
13
|
-
|
|
13
|
+
var _context$actions, _context$actions2;
|
|
14
|
+
var context = useFlexibleUiContext();
|
|
15
|
+
if (!context || !(context !== null && context !== void 0 && (_context$actions = context.actions) !== null && _context$actions !== void 0 && _context$actions[ActionName.FollowAction])) {
|
|
14
16
|
return null;
|
|
15
17
|
}
|
|
16
|
-
var _context$
|
|
17
|
-
value = _context$
|
|
18
|
-
data = _objectWithoutProperties(_context$
|
|
18
|
+
var _context$actions$Acti = context === null || context === void 0 || (_context$actions2 = context.actions) === null || _context$actions2 === void 0 ? void 0 : _context$actions2[ActionName.FollowAction],
|
|
19
|
+
value = _context$actions$Acti.value,
|
|
20
|
+
data = _objectWithoutProperties(_context$actions$Acti, _excluded);
|
|
19
21
|
var message = value ? messages.follow : messages.unfollow;
|
|
20
22
|
var icon = value ? /*#__PURE__*/React.createElement(InviteTeamIcon, {
|
|
21
23
|
label: "Follow"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import { ActionName } from '../../../../constants';
|
|
|
2
2
|
import { createDataAction, createUIAction } from './utils';
|
|
3
3
|
export { default as FollowAction } from './follow-action';
|
|
4
4
|
export { default as PreviewAction } from './preview-action';
|
|
5
|
+
export { default as DownloadAction } from './download-action';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Creates a DeleteAction component. Accepts default ActionProps, but defaults
|
|
@@ -23,13 +24,6 @@ export var EditAction = createUIAction(ActionName.EditAction);
|
|
|
23
24
|
*/
|
|
24
25
|
export var ViewAction = createDataAction(ActionName.ViewAction);
|
|
25
26
|
|
|
26
|
-
/**
|
|
27
|
-
* Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
|
|
28
|
-
* to the text 'Download' inside the button.
|
|
29
|
-
* @see Action
|
|
30
|
-
*/
|
|
31
|
-
export var DownloadAction = createDataAction(ActionName.DownloadAction);
|
|
32
|
-
|
|
33
27
|
/**
|
|
34
28
|
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
35
29
|
* your own icon or text.
|
|
@@ -14,8 +14,6 @@ import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
|
14
14
|
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
15
15
|
import ViewAction from './action/view-action';
|
|
16
16
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
17
|
-
import DownloadAction from './action/download-action';
|
|
18
|
-
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
19
17
|
var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, ActionName.CustomAction, {
|
|
20
18
|
component: Action,
|
|
21
19
|
props: {}
|
|
@@ -49,16 +47,6 @@ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, Act
|
|
|
49
47
|
}),
|
|
50
48
|
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
|
|
51
49
|
}
|
|
52
|
-
}), _defineProperty(_actionMappings, ActionName.DownloadAction, {
|
|
53
|
-
component: DownloadAction,
|
|
54
|
-
props: {
|
|
55
|
-
testId: 'smart-action-download-action',
|
|
56
|
-
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
|
|
57
|
-
icon: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
58
|
-
label: "Download"
|
|
59
|
-
}),
|
|
60
|
-
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
|
|
61
|
-
}
|
|
62
50
|
}), _actionMappings);
|
|
63
51
|
var getContextKey = function getContextKey(name) {
|
|
64
52
|
// Attempt to predict context prop name in advance to reduce the amount of
|
|
@@ -72,7 +60,6 @@ var getActionData = function getActionData(actionName, contextKey, context) {
|
|
|
72
60
|
var data = context[contextKey];
|
|
73
61
|
switch (actionName) {
|
|
74
62
|
case ActionName.ViewAction:
|
|
75
|
-
case ActionName.DownloadAction:
|
|
76
63
|
return data;
|
|
77
64
|
default:
|
|
78
65
|
return undefined;
|
|
@@ -9,6 +9,13 @@ var AIEventSummaryViewed = function AIEventSummaryViewed(_ref) {
|
|
|
9
9
|
fireEvent('ui.summary.viewed', {
|
|
10
10
|
fromCache: fromCache
|
|
11
11
|
});
|
|
12
|
+
if (fromCache) {
|
|
13
|
+
fireEvent('track.aiInteraction.initiated', {
|
|
14
|
+
aiFeatureName: 'Smart Links Summary',
|
|
15
|
+
proactiveAIGenerated: 1,
|
|
16
|
+
userGeneratedAI: 0
|
|
17
|
+
});
|
|
18
|
+
}
|
|
12
19
|
}, [fireEvent, fromCache]);
|
|
13
20
|
return null;
|
|
14
21
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import
|
|
4
|
-
import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
|
|
3
|
+
import React, { useCallback, useMemo, useRef, useEffect } from 'react';
|
|
5
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
6
5
|
import { Box, Inline } from '@atlaskit/primitives';
|
|
7
6
|
import { ActionName, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
|
|
@@ -18,16 +17,44 @@ import AISummary from '../../../../../common/ai-summary';
|
|
|
18
17
|
import { useAnalyticsEvents } from '../../../../../../common/analytics/generated/use-analytics-events';
|
|
19
18
|
import AIEventSummaryViewed from '../ai-event-summary-viewed';
|
|
20
19
|
import AIEventErrorViewed from '../ai-event-error-viewed';
|
|
20
|
+
import { di } from 'react-magnetic-di';
|
|
21
|
+
export var AISummaryBlockErrorIndicator = function AISummaryBlockErrorIndicator(_ref) {
|
|
22
|
+
var showErrorIndicator = _ref.showErrorIndicator,
|
|
23
|
+
error = _ref.error,
|
|
24
|
+
testId = _ref.testId;
|
|
25
|
+
return showErrorIndicator ? /*#__PURE__*/React.createElement(Inline, {
|
|
26
|
+
grow: "fill"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
|
|
28
|
+
reason: error
|
|
29
|
+
}), /*#__PURE__*/React.createElement(AIStateIndicator, {
|
|
30
|
+
error: error,
|
|
31
|
+
state: 'error',
|
|
32
|
+
testId: testId
|
|
33
|
+
})) : null;
|
|
34
|
+
};
|
|
35
|
+
export var AISummaryBlockStatusIndicator = function AISummaryBlockStatusIndicator(_ref2) {
|
|
36
|
+
var showStatusIndicator = _ref2.showStatusIndicator,
|
|
37
|
+
metadata = _ref2.metadata,
|
|
38
|
+
status = _ref2.status,
|
|
39
|
+
testId = _ref2.testId;
|
|
40
|
+
var metadataElements = renderElementItems(metadata);
|
|
41
|
+
return showStatusIndicator ? /*#__PURE__*/React.createElement(AIStateIndicator, {
|
|
42
|
+
state: status,
|
|
43
|
+
testId: "".concat(testId, "-state-indicator")
|
|
44
|
+
}) : /*#__PURE__*/React.createElement(ElementGroup, {
|
|
45
|
+
width: SmartLinkWidth.FitToContent,
|
|
46
|
+
testId: "".concat(testId, "-metadata-group")
|
|
47
|
+
}, metadataElements);
|
|
48
|
+
};
|
|
21
49
|
var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
22
50
|
var _props$actions = props.actions,
|
|
23
51
|
actions = _props$actions === void 0 ? [] : _props$actions,
|
|
24
|
-
metadata = props.metadata,
|
|
25
52
|
onActionMenuOpenChange = props.onActionMenuOpenChange,
|
|
26
53
|
_props$size = props.size,
|
|
27
54
|
size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
|
|
28
55
|
testId = props.testId,
|
|
29
|
-
aiSummaryMinHeight = props.aiSummaryMinHeight
|
|
30
|
-
|
|
56
|
+
aiSummaryMinHeight = props.aiSummaryMinHeight,
|
|
57
|
+
metadata = props.metadata;
|
|
31
58
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
32
59
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
33
60
|
var context = useFlexibleUiContext();
|
|
@@ -47,18 +74,11 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
|
47
74
|
status === 'loading' && !!content;
|
|
48
75
|
var isSummarisedOnMountRef = useRef(status === 'done');
|
|
49
76
|
var isErroredOnMountRef = useRef(status === 'error');
|
|
50
|
-
var _useState = useState(false),
|
|
51
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
-
showAISummaryErrorMessage = _useState2[0],
|
|
53
|
-
setShowAISummaryErrorMessage = _useState2[1];
|
|
54
77
|
useEffect(function () {
|
|
55
78
|
// if the error was apparent on mount and the status is changed to loading we can
|
|
56
79
|
// clear the initial error on mount state
|
|
57
80
|
if (isErroredOnMountRef.current && status === 'loading') {
|
|
58
81
|
isErroredOnMountRef.current = false;
|
|
59
|
-
} else {
|
|
60
|
-
// if a new error occurs and it was not an apparent error on mount, we can show the error message
|
|
61
|
-
setShowAISummaryErrorMessage(!isErroredOnMountRef.current && status === 'error');
|
|
62
82
|
}
|
|
63
83
|
}, [status]);
|
|
64
84
|
var combinedActions = useMemo(function () {
|
|
@@ -68,6 +88,11 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
|
68
88
|
name: ActionName.CustomAction,
|
|
69
89
|
onClick: function onClick() {
|
|
70
90
|
fireEvent('ui.button.clicked.aiSummary', {});
|
|
91
|
+
fireEvent('track.aiInteraction.initiated', {
|
|
92
|
+
aiFeatureName: 'Smart Links Summary',
|
|
93
|
+
proactiveAIGenerated: 0,
|
|
94
|
+
userGeneratedAI: 1
|
|
95
|
+
});
|
|
71
96
|
summariseUrl();
|
|
72
97
|
},
|
|
73
98
|
testId: "".concat(testId, "-ai-summary-action"),
|
|
@@ -101,25 +126,20 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
|
|
|
101
126
|
alignInline: "end",
|
|
102
127
|
grow: "fill",
|
|
103
128
|
spread: "space-between"
|
|
104
|
-
}, /*#__PURE__*/React.createElement(Box, null,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}, metadataElements)), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
129
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(AISummaryBlockStatusIndicator, {
|
|
130
|
+
metadata: metadata,
|
|
131
|
+
showStatusIndicator: !isSummarisedOnMountRef.current && (status === 'loading' || status === 'done'),
|
|
132
|
+
status: status,
|
|
133
|
+
testId: testId
|
|
134
|
+
})), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
111
135
|
onDropdownOpenChange: onDropdownOpenChange,
|
|
112
136
|
items: combinedActions,
|
|
113
137
|
appearance: "default",
|
|
114
138
|
size: size
|
|
115
|
-
}))),
|
|
116
|
-
|
|
117
|
-
}, /*#__PURE__*/React.createElement(AIEventErrorViewed, {
|
|
118
|
-
reason: error
|
|
119
|
-
}), /*#__PURE__*/React.createElement(AIStateIndicator, {
|
|
139
|
+
}))), /*#__PURE__*/React.createElement(AISummaryBlockErrorIndicator, {
|
|
140
|
+
showErrorIndicator: !isErroredOnMountRef.current && status === 'error',
|
|
120
141
|
error: error,
|
|
121
|
-
state: status,
|
|
122
142
|
testId: testId
|
|
123
|
-
}))
|
|
143
|
+
}));
|
|
124
144
|
};
|
|
125
145
|
export default AISummaryBlockResolvedView;
|
|
@@ -99,14 +99,6 @@ export var filterActionItems = function filterActionItems() {
|
|
|
99
99
|
case ActionName.CustomAction:
|
|
100
100
|
// Named and custom actions that user defines.
|
|
101
101
|
return Boolean(ActionName[item.name]);
|
|
102
|
-
case ActionName.DownloadAction:
|
|
103
|
-
// Remove once DownloadAction is refactored to context.action
|
|
104
|
-
// https://product-fabric.atlassian.net/browse/EDM-9545
|
|
105
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
|
|
106
|
-
// Remove once FollowAction is refactored to context.action
|
|
107
|
-
// https://product-fabric.atlassian.net/browse/EDM-9559
|
|
108
|
-
case ActionName.FollowAction:
|
|
109
|
-
return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
|
|
110
102
|
// Remove once ViewAction is retired
|
|
111
103
|
// https://product-fabric.atlassian.net/browse/EDM-9547
|
|
112
104
|
case ActionName.ViewAction:
|