@atlaskit/link-datasource 1.1.3 → 1.1.4

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,11 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 1.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`067fe62a1dc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/067fe62a1dc) - [ux] Updated logic for site selector to default to current site
8
+
3
9
  ## 1.1.3
4
10
 
5
11
  ### Patch Changes
@@ -8,6 +8,6 @@ var EVENT_CHANNEL = 'media';
8
8
  exports.EVENT_CHANNEL = EVENT_CHANNEL;
9
9
  var packageMetaData = {
10
10
  packageName: "@atlaskit/link-datasource",
11
- packageVersion: "1.1.3"
11
+ packageVersion: "1.1.4"
12
12
  };
13
13
  exports.packageMetaData = packageMetaData;
@@ -231,7 +231,7 @@ var analyticsContextAttributes = {
231
231
  };
232
232
  var analyticsContextData = {
233
233
  packageName: "@atlaskit/link-datasource",
234
- packageVersion: "1.1.3",
234
+ packageVersion: "1.1.4",
235
235
  source: 'datasourceConfigModal'
236
236
  };
237
237
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
@@ -146,9 +146,18 @@ var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(props) {
146
146
  var _useDatasourceAnalyti = (0, _analytics.useDatasourceAnalyticsEvents)(),
147
147
  fireEvent = _useDatasourceAnalyti.fireEvent;
148
148
  var selectedJiraSite = (0, _react.useMemo)(function () {
149
- return availableSites.find(function (jiraSite) {
150
- return jiraSite.cloudId === cloudId;
151
- }) || availableSites[0];
149
+ if (cloudId) {
150
+ // if the cloud id we're editing isn't in available sites then user is likely unauthorized for that site
151
+ // TODO: unauthorized to edit flow https://product-fabric.atlassian.net/browse/EDM-7216
152
+ return availableSites.find(function (jiraSite) {
153
+ return jiraSite.cloudId === cloudId;
154
+ }) || availableSites[0];
155
+ } else {
156
+ var currentlyLoggedInSiteUrl = window.location.origin;
157
+ return availableSites.find(function (jiraSite) {
158
+ return jiraSite.url === currentlyLoggedInSiteUrl;
159
+ }) || availableSites[0];
160
+ }
152
161
  }, [availableSites, cloudId]);
153
162
  var buttonClickedAnalyticsPayload = (0, _react.useMemo)(function () {
154
163
  return {
@@ -196,7 +205,7 @@ var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(props) {
196
205
  void fetchSiteDisplayNames();
197
206
  }, [fireEvent]);
198
207
  (0, _react.useEffect)(function () {
199
- if (!cloudId && selectedJiraSite) {
208
+ if (selectedJiraSite && (!cloudId || cloudId !== selectedJiraSite.cloudId)) {
200
209
  setCloudId(selectedJiraSite.cloudId);
201
210
  }
202
211
  }, [cloudId, selectedJiraSite]);
@@ -1,5 +1,5 @@
1
1
  export const EVENT_CHANNEL = 'media';
2
2
  export const packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.1.3"
4
+ packageVersion: "1.1.4"
5
5
  };
@@ -205,7 +205,7 @@ const analyticsContextAttributes = {
205
205
  };
206
206
  const analyticsContextData = {
207
207
  packageName: "@atlaskit/link-datasource",
208
- packageVersion: "1.1.3",
208
+ packageVersion: "1.1.4",
209
209
  source: 'datasourceConfigModal'
210
210
  };
211
211
  const contextData = {
@@ -116,7 +116,16 @@ export const PlainJiraIssuesConfigModal = props => {
116
116
  const {
117
117
  fireEvent
118
118
  } = useDatasourceAnalyticsEvents();
119
- const selectedJiraSite = useMemo(() => availableSites.find(jiraSite => jiraSite.cloudId === cloudId) || availableSites[0], [availableSites, cloudId]);
119
+ const selectedJiraSite = useMemo(() => {
120
+ if (cloudId) {
121
+ // if the cloud id we're editing isn't in available sites then user is likely unauthorized for that site
122
+ // TODO: unauthorized to edit flow https://product-fabric.atlassian.net/browse/EDM-7216
123
+ return availableSites.find(jiraSite => jiraSite.cloudId === cloudId) || availableSites[0];
124
+ } else {
125
+ const currentlyLoggedInSiteUrl = window.location.origin;
126
+ return availableSites.find(jiraSite => jiraSite.url === currentlyLoggedInSiteUrl) || availableSites[0];
127
+ }
128
+ }, [availableSites, cloudId]);
120
129
  const buttonClickedAnalyticsPayload = useMemo(() => {
121
130
  return {
122
131
  extensionKey: extensionKey,
@@ -146,7 +155,7 @@ export const PlainJiraIssuesConfigModal = props => {
146
155
  void fetchSiteDisplayNames();
147
156
  }, [fireEvent]);
148
157
  useEffect(() => {
149
- if (!cloudId && selectedJiraSite) {
158
+ if (selectedJiraSite && (!cloudId || cloudId !== selectedJiraSite.cloudId)) {
150
159
  setCloudId(selectedJiraSite.cloudId);
151
160
  }
152
161
  }, [cloudId, selectedJiraSite]);
@@ -1,5 +1,5 @@
1
1
  export var EVENT_CHANNEL = 'media';
2
2
  export var packageMetaData = {
3
3
  packageName: "@atlaskit/link-datasource",
4
- packageVersion: "1.1.3"
4
+ packageVersion: "1.1.4"
5
5
  };
@@ -222,7 +222,7 @@ var analyticsContextAttributes = {
222
222
  };
223
223
  var analyticsContextData = {
224
224
  packageName: "@atlaskit/link-datasource",
225
- packageVersion: "1.1.3",
225
+ packageVersion: "1.1.4",
226
226
  source: 'datasourceConfigModal'
227
227
  };
228
228
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
@@ -136,9 +136,18 @@ export var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(prop
136
136
  var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
137
137
  fireEvent = _useDatasourceAnalyti.fireEvent;
138
138
  var selectedJiraSite = useMemo(function () {
139
- return availableSites.find(function (jiraSite) {
140
- return jiraSite.cloudId === cloudId;
141
- }) || availableSites[0];
139
+ if (cloudId) {
140
+ // if the cloud id we're editing isn't in available sites then user is likely unauthorized for that site
141
+ // TODO: unauthorized to edit flow https://product-fabric.atlassian.net/browse/EDM-7216
142
+ return availableSites.find(function (jiraSite) {
143
+ return jiraSite.cloudId === cloudId;
144
+ }) || availableSites[0];
145
+ } else {
146
+ var currentlyLoggedInSiteUrl = window.location.origin;
147
+ return availableSites.find(function (jiraSite) {
148
+ return jiraSite.url === currentlyLoggedInSiteUrl;
149
+ }) || availableSites[0];
150
+ }
142
151
  }, [availableSites, cloudId]);
143
152
  var buttonClickedAnalyticsPayload = useMemo(function () {
144
153
  return {
@@ -186,7 +195,7 @@ export var PlainJiraIssuesConfigModal = function PlainJiraIssuesConfigModal(prop
186
195
  void fetchSiteDisplayNames();
187
196
  }, [fireEvent]);
188
197
  useEffect(function () {
189
- if (!cloudId && selectedJiraSite) {
198
+ if (selectedJiraSite && (!cloudId || cloudId !== selectedJiraSite.cloudId)) {
190
199
  setCloudId(selectedJiraSite.cloudId);
191
200
  }
192
201
  }, [cloudId, selectedJiraSite]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"