@atlaskit/smart-card 26.9.19 → 26.11.0

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`fdfe07831c7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fdfe07831c7) - - Deprecate standalone hover card `onAuthorize` prop (no implementation)
8
+ - Hide auth tooltip on unauthenticated inline link with no auth flow (new design, behind feature flag)
9
+
10
+ ## 26.10.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`fa12a765333`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa12a765333) - Cleansup a FF introduced in 26.3.5 (platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop) providing default display attribute now prefers analytics context instead of passing a dispatch function as prop.
15
+
3
16
  ## 26.9.19
4
17
 
5
18
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.9.19",
3
+ "version": "26.11.0",
4
4
  "sideEffects": false
5
5
  }
@@ -9,11 +9,9 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _uuid = _interopRequireDefault(require("uuid"));
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
- var _analytics = require("../../utils/analytics");
14
12
  var _performance = require("../../utils/performance");
15
13
  var _reactErrorBoundary = require("react-error-boundary");
16
- var _analytics2 = require("../../state/analytics");
14
+ var _analytics = require("../../state/analytics");
17
15
  var _LazyFallback = require("./component-lazy/LazyFallback");
18
16
  var _utils = require("../../utils");
19
17
  var _flexible = require("../../utils/flexible");
@@ -56,7 +54,6 @@ function CardWithURLRenderer(props) {
56
54
  embedIframeRef = props.embedIframeRef,
57
55
  embedIframeUrlType = props.embedIframeUrlType,
58
56
  inlinePreloaderStyle = props.inlinePreloaderStyle,
59
- createAnalyticsEvent = props.createAnalyticsEvent,
60
57
  children = props.children,
61
58
  ui = props.ui,
62
59
  showHoverPreview = props.showHoverPreview,
@@ -64,33 +61,7 @@ function CardWithURLRenderer(props) {
64
61
  analyticsEvents = props.analyticsEvents,
65
62
  placeholder = props.placeholder,
66
63
  fallbackComponent = props.fallbackComponent;
67
-
68
- // Wrapper around analytics.
69
- var dispatchAnalytics = (0, _react.useMemo)(function () {
70
- /**
71
- * If feature flag is on, return `undefined` for dispatch, which will be passed down
72
- * to the components as undefined and the fallback method will be used instead to dispatch
73
- * analytics events:
74
- * packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
75
- *
76
- * For FF cleanup, we should be able to remove the prop from all the places where this is
77
- * being passed down to.
78
- */
79
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
80
- return undefined;
81
- }
82
- return function (analyticsPayload) {
83
- if (analyticsPayload && analyticsPayload.attributes) {
84
- // Update if we haven't already set the display - possible
85
- // in the case of `preview` which is rendered differently.
86
- if (!analyticsPayload.attributes.display) {
87
- analyticsPayload.attributes.display = appearance;
88
- }
89
- }
90
- (0, _analytics.fireSmartLinkEvent)(analyticsPayload, createAnalyticsEvent);
91
- };
92
- }, [appearance, createAnalyticsEvent]);
93
- var analytics = (0, _analytics2.useSmartLinkAnalytics)(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
64
+ var analytics = (0, _analytics.useSmartLinkAnalytics)(url !== null && url !== void 0 ? url : '', undefined, id);
94
65
  var isFlexibleUi = (0, _flexible.isFlexibleUiCard)(children);
95
66
  var errorHandler = (0, _react.useCallback)(function (error, info) {
96
67
  var componentStack = info.componentStack;
@@ -140,7 +111,6 @@ function CardWithURLRenderer(props) {
140
111
  isSelected: isSelected,
141
112
  isFrameVisible: isFrameVisible,
142
113
  frameStyle: frameStyle,
143
- dispatchAnalytics: dispatchAnalytics,
144
114
  container: container,
145
115
  onResolve: onResolve,
146
116
  onError: onError,
@@ -166,6 +166,8 @@ var Container = function Container(_ref3) {
166
166
  var context = (0, _react.useContext)(_flexibleUiContext.FlexibleUiContext);
167
167
  var childrenOptions = getChildrenOptions(children, context);
168
168
  var canShowHoverPreview = showHoverPreview && status === 'resolved';
169
+ // `retry` object contains action that can be performed on
170
+ // unresolved link (unauthorized, forbidden, not found, etc.)
169
171
  var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
170
172
  var container = (0, _react2.jsx)("div", {
171
173
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
@@ -100,7 +100,6 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
100
100
  if (onAuthorise && showAuthTooltip) {
101
101
  return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
102
102
  url: url,
103
- onAuthorize: onAuthorise,
104
103
  id: this.props.id
105
104
  }, inlineCardUnauthenticatedView);
106
105
  }
@@ -81,6 +81,7 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
81
81
  var _this$props3 = this.props,
82
82
  url = _this$props3.url,
83
83
  icon = _this$props3.icon,
84
+ onAuthorise = _this$props3.onAuthorise,
84
85
  onClick = _this$props3.onClick,
85
86
  isSelected = _this$props3.isSelected,
86
87
  _this$props3$testId = _this$props3.testId,
@@ -98,10 +99,9 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
98
99
  onClick: onClick,
99
100
  titleColor: "var(--ds-text-subtle, ".concat(_colors.N500, ")")
100
101
  }), this.renderActionButton());
101
- if (showAuthTooltip) {
102
+ if (onAuthorise && showAuthTooltip) {
102
103
  return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
103
104
  url: url,
104
- onAuthorize: this.props.onAuthorise,
105
105
  id: this.props.id
106
106
  }, inlineCardUnauthenticatedView);
107
107
  }
@@ -1,6 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../utils/analytics';
4
+
4
5
  /**
5
6
  * Hook designed to use a handler if provided (ideally not)
6
7
  * Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.9.19",
3
+ "version": "26.11.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,5 @@
1
- import React, { lazy, useEffect, useState, Suspense, useCallback, useMemo } from 'react';
1
+ import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
2
2
  import uuid from 'uuid';
3
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
- import { fireSmartLinkEvent } from '../../utils/analytics';
5
3
  import { clearMarks, clearMeasures } from '../../utils/performance';
6
4
  import { ErrorBoundary } from 'react-error-boundary';
7
5
  import { useSmartLinkAnalytics } from '../../state/analytics';
@@ -36,7 +34,6 @@ export function CardWithURLRenderer(props) {
36
34
  embedIframeRef,
37
35
  embedIframeUrlType,
38
36
  inlinePreloaderStyle,
39
- createAnalyticsEvent,
40
37
  children,
41
38
  ui,
42
39
  showHoverPreview,
@@ -45,33 +42,7 @@ export function CardWithURLRenderer(props) {
45
42
  placeholder,
46
43
  fallbackComponent
47
44
  } = props;
48
-
49
- // Wrapper around analytics.
50
- const dispatchAnalytics = useMemo(() => {
51
- /**
52
- * If feature flag is on, return `undefined` for dispatch, which will be passed down
53
- * to the components as undefined and the fallback method will be used instead to dispatch
54
- * analytics events:
55
- * packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
56
- *
57
- * For FF cleanup, we should be able to remove the prop from all the places where this is
58
- * being passed down to.
59
- */
60
- if (getBooleanFF('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
61
- return undefined;
62
- }
63
- return analyticsPayload => {
64
- if (analyticsPayload && analyticsPayload.attributes) {
65
- // Update if we haven't already set the display - possible
66
- // in the case of `preview` which is rendered differently.
67
- if (!analyticsPayload.attributes.display) {
68
- analyticsPayload.attributes.display = appearance;
69
- }
70
- }
71
- fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
72
- };
73
- }, [appearance, createAnalyticsEvent]);
74
- const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
45
+ const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', undefined, id);
75
46
  const isFlexibleUi = isFlexibleUiCard(children);
76
47
  const errorHandler = useCallback((error, info) => {
77
48
  const {
@@ -119,7 +90,6 @@ export function CardWithURLRenderer(props) {
119
90
  isSelected,
120
91
  isFrameVisible,
121
92
  frameStyle,
122
- dispatchAnalytics,
123
93
  container,
124
94
  onResolve,
125
95
  onError,
@@ -187,6 +187,8 @@ const Container = ({
187
187
  const context = useContext(FlexibleUiContext);
188
188
  const childrenOptions = getChildrenOptions(children, context);
189
189
  const canShowHoverPreview = showHoverPreview && status === 'resolved';
190
+ // `retry` object contains action that can be performed on
191
+ // unresolved link (unauthorized, forbidden, not found, etc.)
190
192
  const canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
191
193
  const container = jsx("div", {
192
194
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
@@ -76,7 +76,6 @@ export class InlineCardUnauthorizedView extends React.Component {
76
76
  if (onAuthorise && showAuthTooltip) {
77
77
  return /*#__PURE__*/React.createElement(HoverCard, {
78
78
  url: url,
79
- onAuthorize: onAuthorise,
80
79
  id: this.props.id
81
80
  }, inlineCardUnauthenticatedView);
82
81
  }
@@ -58,6 +58,7 @@ export class InlineCardUnauthorizedView extends React.Component {
58
58
  const {
59
59
  url,
60
60
  icon,
61
+ onAuthorise,
61
62
  onClick,
62
63
  isSelected,
63
64
  testId = 'inline-card-unauthorized-view',
@@ -74,10 +75,9 @@ export class InlineCardUnauthorizedView extends React.Component {
74
75
  onClick: onClick,
75
76
  titleColor: `var(--ds-text-subtle, ${N500})`
76
77
  }), this.renderActionButton());
77
- if (showAuthTooltip) {
78
+ if (onAuthorise && showAuthTooltip) {
78
79
  return /*#__PURE__*/React.createElement(HoverCard, {
79
80
  url: url,
80
- onAuthorize: this.props.onAuthorise,
81
81
  id: this.props.id
82
82
  }, inlineCardUnauthenticatedView);
83
83
  }
@@ -1,6 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { ANALYTICS_CHANNEL } from '../../utils/analytics';
4
+
4
5
  /**
5
6
  * Hook designed to use a handler if provided (ideally not)
6
7
  * Use this for the short-term to support deprecating `analyticsHandler`s that are being provided externally,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.9.19",
3
+ "version": "26.11.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { lazy, useEffect, useState, Suspense, useCallback, useMemo } from 'react';
2
+ import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
3
3
  import uuid from 'uuid';
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
- import { fireSmartLinkEvent } from '../../utils/analytics';
6
4
  import { clearMarks, clearMeasures } from '../../utils/performance';
7
5
  import { ErrorBoundary } from 'react-error-boundary';
8
6
  import { useSmartLinkAnalytics } from '../../state/analytics';
@@ -44,7 +42,6 @@ export function CardWithURLRenderer(props) {
44
42
  embedIframeRef = props.embedIframeRef,
45
43
  embedIframeUrlType = props.embedIframeUrlType,
46
44
  inlinePreloaderStyle = props.inlinePreloaderStyle,
47
- createAnalyticsEvent = props.createAnalyticsEvent,
48
45
  children = props.children,
49
46
  ui = props.ui,
50
47
  showHoverPreview = props.showHoverPreview,
@@ -52,33 +49,7 @@ export function CardWithURLRenderer(props) {
52
49
  analyticsEvents = props.analyticsEvents,
53
50
  placeholder = props.placeholder,
54
51
  fallbackComponent = props.fallbackComponent;
55
-
56
- // Wrapper around analytics.
57
- var dispatchAnalytics = useMemo(function () {
58
- /**
59
- * If feature flag is on, return `undefined` for dispatch, which will be passed down
60
- * to the components as undefined and the fallback method will be used instead to dispatch
61
- * analytics events:
62
- * packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
63
- *
64
- * For FF cleanup, we should be able to remove the prop from all the places where this is
65
- * being passed down to.
66
- */
67
- if (getBooleanFF('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
68
- return undefined;
69
- }
70
- return function (analyticsPayload) {
71
- if (analyticsPayload && analyticsPayload.attributes) {
72
- // Update if we haven't already set the display - possible
73
- // in the case of `preview` which is rendered differently.
74
- if (!analyticsPayload.attributes.display) {
75
- analyticsPayload.attributes.display = appearance;
76
- }
77
- }
78
- fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
79
- };
80
- }, [appearance, createAnalyticsEvent]);
81
- var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
52
+ var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', undefined, id);
82
53
  var isFlexibleUi = isFlexibleUiCard(children);
83
54
  var errorHandler = useCallback(function (error, info) {
84
55
  var componentStack = info.componentStack;
@@ -128,7 +99,6 @@ export function CardWithURLRenderer(props) {
128
99
  isSelected: isSelected,
129
100
  isFrameVisible: isFrameVisible,
130
101
  frameStyle: frameStyle,
131
- dispatchAnalytics: dispatchAnalytics,
132
102
  container: container,
133
103
  onResolve: onResolve,
134
104
  onError: onError,
@@ -155,6 +155,8 @@ var Container = function Container(_ref3) {
155
155
  var context = useContext(FlexibleUiContext);
156
156
  var childrenOptions = getChildrenOptions(children, context);
157
157
  var canShowHoverPreview = showHoverPreview && status === 'resolved';
158
+ // `retry` object contains action that can be performed on
159
+ // unresolved link (unauthorized, forbidden, not found, etc.)
158
160
  var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized' && retry !== undefined;
159
161
  var container = jsx("div", {
160
162
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
@@ -93,7 +93,6 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
93
93
  if (onAuthorise && showAuthTooltip) {
94
94
  return /*#__PURE__*/React.createElement(HoverCard, {
95
95
  url: url,
96
- onAuthorize: onAuthorise,
97
96
  id: this.props.id
98
97
  }, inlineCardUnauthenticatedView);
99
98
  }
@@ -74,6 +74,7 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
74
74
  var _this$props3 = this.props,
75
75
  url = _this$props3.url,
76
76
  icon = _this$props3.icon,
77
+ onAuthorise = _this$props3.onAuthorise,
77
78
  onClick = _this$props3.onClick,
78
79
  isSelected = _this$props3.isSelected,
79
80
  _this$props3$testId = _this$props3.testId,
@@ -91,10 +92,9 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
91
92
  onClick: onClick,
92
93
  titleColor: "var(--ds-text-subtle, ".concat(N500, ")")
93
94
  }), this.renderActionButton());
94
- if (showAuthTooltip) {
95
+ if (onAuthorise && showAuthTooltip) {
95
96
  return /*#__PURE__*/React.createElement(HoverCard, {
96
97
  url: url,
97
- onAuthorize: this.props.onAuthorise,
98
98
  id: this.props.id
99
99
  }, inlineCardUnauthenticatedView);
100
100
  }
@@ -22,6 +22,7 @@ export interface HoverCardProps extends WithAnalyticsEventsProps {
22
22
  children: ReactElement;
23
23
  /**
24
24
  * Function to be called when user is authorized to view a link.
25
+ * @deprecated See EDM-7411
25
26
  */
26
27
  onAuthorize?: () => void;
27
28
  /**
@@ -22,6 +22,7 @@ export interface HoverCardProps extends WithAnalyticsEventsProps {
22
22
  children: ReactElement;
23
23
  /**
24
24
  * Function to be called when user is authorized to view a link.
25
+ * @deprecated See EDM-7411
25
26
  */
26
27
  onAuthorize?: () => void;
27
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.9.19",
3
+ "version": "26.11.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -74,7 +74,7 @@
74
74
  "@af/visual-regression": "*",
75
75
  "@atlaskit/avatar": "^21.3.0",
76
76
  "@atlaskit/css-reset": "^6.5.0",
77
- "@atlaskit/link-test-helpers": "^4.2.0",
77
+ "@atlaskit/link-test-helpers": "^5.0.0",
78
78
  "@atlaskit/lozenge": "^11.4.0",
79
79
  "@atlaskit/media-integration-test-helpers": "^3.0.0",
80
80
  "@atlaskit/media-test-helpers": "^33.0.0",
@@ -134,9 +134,6 @@
134
134
  ".": "./src/index.ts"
135
135
  },
136
136
  "platform-feature-flags": {
137
- "platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop": {
138
- "type": "boolean"
139
- },
140
137
  "platform.linking-platform.smart-card.enable-block-card-clicks-opening-in-same-tab": {
141
138
  "type": "boolean"
142
139
  },