@atlaskit/smart-card 19.1.22 → 19.1.23

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,12 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 19.1.23
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f538640e3a5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f538640e3a5) - fix: Previously the .reload() action would not propagate changes through to the smart-card state in some scenarios. This has been amended by making it an explicit Redux action.
8
+ - Updated dependencies
9
+
3
10
  ## 19.1.22
4
11
 
5
12
  ### Patch Changes
@@ -92,6 +92,7 @@ var useSmartCardActions = function useSmartCardActions(id, url, analytics) {
92
92
  }
93
93
  }, [hasData, status, dispatch, details]);
94
94
  var handleResolvedLinkResponse = (0, _react.useCallback)(function (resourceUrl, response) {
95
+ var isReloading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
95
96
  var hostname = new URL(resourceUrl).hostname;
96
97
  var nextStatus = response ? (0, _helpers.getStatus)(response) : 'fatal'; // If we require authorization & do not have an authFlow available,
97
98
  // throw an error and render as a normal blue link.
@@ -108,9 +109,15 @@ var useSmartCardActions = function useSmartCardActions(id, url, analytics) {
108
109
  } // Dispatch Analytics and resolved card action - including unauthorized states.
109
110
 
110
111
 
111
- dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
112
- url: resourceUrl
113
- }, response));
112
+ if (isReloading) {
113
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RELOADING, {
114
+ url: resourceUrl
115
+ }, response));
116
+ } else {
117
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_RESOLVED, {
118
+ url: resourceUrl
119
+ }, response));
120
+ }
114
121
  }, [dispatch, handleResolvedLinkError, hasAuthFlowSupported]);
115
122
  var resolve = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
116
123
  var resourceUrl,
@@ -129,7 +136,7 @@ var useSmartCardActions = function useSmartCardActions(id, url, analytics) {
129
136
  }
130
137
 
131
138
  return _context.abrupt("return", connections.client.fetchData(resourceUrl).then(function (response) {
132
- return handleResolvedLinkResponse(resourceUrl, response);
139
+ return handleResolvedLinkResponse(resourceUrl, response, isReloading);
133
140
  }).catch(function (error) {
134
141
  return handleResolvedLinkError(resourceUrl, error);
135
142
  }));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.22",
3
+ "version": "19.1.23",
4
4
  "sideEffects": false
5
5
  }
@@ -2,7 +2,7 @@ import { useMemo, useCallback } from 'react';
2
2
  import { auth } from '@atlaskit/outbound-auth-flow-client';
3
3
  import { APIError } from '@atlaskit/linking-common';
4
4
  import { useSmartLinkContext } from '@atlaskit/link-provider';
5
- import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, cardAction } from '@atlaskit/linking-common';
5
+ import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, cardAction } from '@atlaskit/linking-common';
6
6
  import { getDefinitionId, getByDefinitionId, getServices, getStatus, getExtensionKey } from '../helpers';
7
7
  import { ERROR_MESSAGE_OAUTH, ERROR_MESSAGE_FATAL } from './constants';
8
8
  import * as measure from '../../utils/performance';
@@ -65,7 +65,7 @@ export const useSmartCardActions = (id, url, analytics) => {
65
65
  }
66
66
  }
67
67
  }, [hasData, status, dispatch, details]);
68
- const handleResolvedLinkResponse = useCallback((resourceUrl, response) => {
68
+ const handleResolvedLinkResponse = useCallback((resourceUrl, response, isReloading = false) => {
69
69
  const hostname = new URL(resourceUrl).hostname;
70
70
  const nextStatus = response ? getStatus(response) : 'fatal'; // If we require authorization & do not have an authFlow available,
71
71
  // throw an error and render as a normal blue link.
@@ -82,16 +82,22 @@ export const useSmartCardActions = (id, url, analytics) => {
82
82
  } // Dispatch Analytics and resolved card action - including unauthorized states.
83
83
 
84
84
 
85
- dispatch(cardAction(ACTION_RESOLVED, {
86
- url: resourceUrl
87
- }, response));
85
+ if (isReloading) {
86
+ dispatch(cardAction(ACTION_RELOADING, {
87
+ url: resourceUrl
88
+ }, response));
89
+ } else {
90
+ dispatch(cardAction(ACTION_RESOLVED, {
91
+ url: resourceUrl
92
+ }, response));
93
+ }
88
94
  }, [dispatch, handleResolvedLinkError, hasAuthFlowSupported]);
89
95
  const resolve = useCallback(async (resourceUrl = url, isReloading = false) => {
90
96
  // Request JSON-LD data for the card from ORS, iff it has extended
91
97
  // its cache lifespan OR there is no data for it currently. Once the data
92
98
  // has come back asynchronously, dispatch the resolved action for the card.
93
99
  if (isReloading || !hasData) {
94
- return connections.client.fetchData(resourceUrl).then(response => handleResolvedLinkResponse(resourceUrl, response)).catch(error => handleResolvedLinkError(resourceUrl, error));
100
+ return connections.client.fetchData(resourceUrl).then(response => handleResolvedLinkResponse(resourceUrl, response, isReloading)).catch(error => handleResolvedLinkError(resourceUrl, error));
95
101
  } else {
96
102
  addMetadataToExperience('smart-link-rendered', id, {
97
103
  cached: true
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.22",
3
+ "version": "19.1.23",
4
4
  "sideEffects": false
5
5
  }
@@ -4,7 +4,7 @@ import { useMemo, useCallback } from 'react';
4
4
  import { auth } from '@atlaskit/outbound-auth-flow-client';
5
5
  import { APIError } from '@atlaskit/linking-common';
6
6
  import { useSmartLinkContext } from '@atlaskit/link-provider';
7
- import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, cardAction } from '@atlaskit/linking-common';
7
+ import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, cardAction } from '@atlaskit/linking-common';
8
8
  import { getDefinitionId, getByDefinitionId, getServices, getStatus, getExtensionKey } from '../helpers';
9
9
  import { ERROR_MESSAGE_OAUTH, ERROR_MESSAGE_FATAL } from './constants';
10
10
  import * as measure from '../../utils/performance';
@@ -67,6 +67,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
67
67
  }
68
68
  }, [hasData, status, dispatch, details]);
69
69
  var handleResolvedLinkResponse = useCallback(function (resourceUrl, response) {
70
+ var isReloading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
70
71
  var hostname = new URL(resourceUrl).hostname;
71
72
  var nextStatus = response ? getStatus(response) : 'fatal'; // If we require authorization & do not have an authFlow available,
72
73
  // throw an error and render as a normal blue link.
@@ -83,9 +84,15 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
83
84
  } // Dispatch Analytics and resolved card action - including unauthorized states.
84
85
 
85
86
 
86
- dispatch(cardAction(ACTION_RESOLVED, {
87
- url: resourceUrl
88
- }, response));
87
+ if (isReloading) {
88
+ dispatch(cardAction(ACTION_RELOADING, {
89
+ url: resourceUrl
90
+ }, response));
91
+ } else {
92
+ dispatch(cardAction(ACTION_RESOLVED, {
93
+ url: resourceUrl
94
+ }, response));
95
+ }
89
96
  }, [dispatch, handleResolvedLinkError, hasAuthFlowSupported]);
90
97
  var resolve = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
91
98
  var resourceUrl,
@@ -104,7 +111,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
104
111
  }
105
112
 
106
113
  return _context.abrupt("return", connections.client.fetchData(resourceUrl).then(function (response) {
107
- return handleResolvedLinkResponse(resourceUrl, response);
114
+ return handleResolvedLinkResponse(resourceUrl, response, isReloading);
108
115
  }).catch(function (error) {
109
116
  return handleResolvedLinkError(resourceUrl, error);
110
117
  }));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.22",
3
+ "version": "19.1.23",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.22",
3
+ "version": "19.1.23",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -58,7 +58,7 @@
58
58
  "uuid": "^3.1.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atlaskit/link-provider": "^1.0.3",
61
+ "@atlaskit/link-provider": "^1.0.4",
62
62
  "react": "^16.8.0",
63
63
  "react-dom": "^16.8.0",
64
64
  "react-intl-next": "npm:react-intl@^5.18.1"