@atlaskit/profilecard 17.0.0 → 17.1.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 +6 -0
- package/dist/cjs/client/ProfileCardClient.js +2 -2
- package/dist/cjs/client/TeamCentralCardClient.js +106 -59
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/ProfileCardClient.js +2 -2
- package/dist/es2019/client/TeamCentralCardClient.js +101 -59
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/ProfileCardClient.js +2 -2
- package/dist/esm/client/TeamCentralCardClient.js +106 -59
- package/dist/esm/util/analytics.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/client/TeamCentralCardClient.d.ts +2 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +3 -3
- package/report.api.md +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/profilecard
|
|
2
2
|
|
|
3
|
+
## 17.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`aa321e66c2a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/aa321e66c2a) - Add cloudid as optional client prop and add workspace check for Atlas functionality
|
|
8
|
+
|
|
3
9
|
## 17.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
@@ -70,11 +70,11 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
70
70
|
}, {
|
|
71
71
|
key: "shouldShowGiveKudos",
|
|
72
72
|
value: function shouldShowGiveKudos() {
|
|
73
|
-
var _this$tcClient4, _this$tcClient5
|
|
73
|
+
var _this$tcClient4, _this$tcClient5;
|
|
74
74
|
|
|
75
75
|
// Check if the kudos feature enabled and if the user has TC
|
|
76
76
|
// if the user does not have TC the tc client will be undefined.
|
|
77
|
-
return
|
|
77
|
+
return this.getTeamCentralBaseUrl() && ((_this$tcClient4 = this.tcClient) === null || _this$tcClient4 === void 0 ? void 0 : _this$tcClient4.getFlagEnabled('team-central-kudos-enabled-m2', (_this$tcClient5 = this.tcClient) === null || _this$tcClient5 === void 0 ? void 0 : _this$tcClient5.options.productIdentifier)) || Promise.resolve(false);
|
|
78
78
|
}
|
|
79
79
|
}]);
|
|
80
80
|
return ProfileCardClient;
|
|
@@ -48,6 +48,14 @@ var buildCheckFeatureFlagQuery = function buildCheckFeatureFlagQuery(featureKey,
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
function hasTCWorkspace(config) {
|
|
52
|
+
return config.cloudId ? fetch("/gateway/api/watermelon/organization/containsAnyWorkspace?cloudId=".concat(config.cloudId)).then(function (res) {
|
|
53
|
+
return !res || res && res.ok;
|
|
54
|
+
}) : Promise.resolve(false);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var isTCReadyPromiseMap = new Map();
|
|
58
|
+
|
|
51
59
|
var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
52
60
|
(0, _inherits2.default)(TeamCentralCardClient, _CachingClient);
|
|
53
61
|
|
|
@@ -69,10 +77,27 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
69
77
|
_this.options = options;
|
|
70
78
|
_this.bypassOnFailure = false;
|
|
71
79
|
_this.featureFlagKeys = new Map();
|
|
80
|
+
_this.isTCReadyPromise = _this.createTcReadyPromise(options);
|
|
72
81
|
return _this;
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
(0, _createClass2.default)(TeamCentralCardClient, [{
|
|
85
|
+
key: "createTcReadyPromise",
|
|
86
|
+
value: function createTcReadyPromise(config) {
|
|
87
|
+
if (config.cloudId) {
|
|
88
|
+
var promise = isTCReadyPromiseMap.get(config.cloudId);
|
|
89
|
+
|
|
90
|
+
if (!promise) {
|
|
91
|
+
promise = hasTCWorkspace(config);
|
|
92
|
+
isTCReadyPromiseMap.set(config.cloudId, promise);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return promise;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return Promise.resolve(true);
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
76
101
|
key: "makeFeatureFlagCheckRequest",
|
|
77
102
|
value: function () {
|
|
78
103
|
var _makeFeatureFlagCheckRequest = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(featureKey, context) {
|
|
@@ -91,7 +116,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
91
116
|
case 2:
|
|
92
117
|
query = buildCheckFeatureFlagQuery(featureKey, context);
|
|
93
118
|
_context.next = 5;
|
|
94
|
-
return (0, _graphqlUtils.graphqlQuery)(this.options.teamCentralUrl, query);
|
|
119
|
+
return (0, _graphqlUtils.graphqlQuery)("".concat(this.options.teamCentralUrl, "?operationName=isFeatureKeyEnabled"), query);
|
|
95
120
|
|
|
96
121
|
case 5:
|
|
97
122
|
response = _context.sent;
|
|
@@ -130,7 +155,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
130
155
|
case 2:
|
|
131
156
|
query = buildReportingLinesQuery(userId);
|
|
132
157
|
_context2.next = 5;
|
|
133
|
-
return (0, _graphqlUtils.graphqlQuery)(this.options.teamCentralUrl, query);
|
|
158
|
+
return (0, _graphqlUtils.graphqlQuery)("".concat(this.options.teamCentralUrl, "?operationName=ReportingLines"), query);
|
|
134
159
|
|
|
135
160
|
case 5:
|
|
136
161
|
response = _context2.sent;
|
|
@@ -155,44 +180,58 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
155
180
|
value: function getReportingLines(userId) {
|
|
156
181
|
var _this2 = this;
|
|
157
182
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (cache) {
|
|
165
|
-
return Promise.resolve(cache);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (this.bypassOnFailure) {
|
|
169
|
-
return Promise.resolve({});
|
|
170
|
-
}
|
|
183
|
+
return this.isTCReadyPromise.then(function (workSpaceExists) {
|
|
184
|
+
if (workSpaceExists) {
|
|
185
|
+
if (!userId) {
|
|
186
|
+
return Promise.reject(new Error('userId missing'));
|
|
187
|
+
}
|
|
171
188
|
|
|
172
|
-
|
|
173
|
-
_this2.makeRequest(userId).then(function (data) {
|
|
174
|
-
var enhancedData = {
|
|
175
|
-
managers: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.managers),
|
|
176
|
-
reports: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.reports)
|
|
177
|
-
};
|
|
189
|
+
var cache = _this2.getCachedProfile(userId);
|
|
178
190
|
|
|
179
|
-
if (
|
|
180
|
-
|
|
191
|
+
if (cache) {
|
|
192
|
+
return Promise.resolve(cache);
|
|
181
193
|
}
|
|
182
194
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
186
|
-
// Trigger circuit breaker
|
|
187
|
-
_this2.bypassOnFailure = true;
|
|
195
|
+
if (_this2.bypassOnFailure) {
|
|
196
|
+
return Promise.resolve({});
|
|
188
197
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Reporting lines aren't part of the critical path of profile card.
|
|
191
|
-
* Just resolve with empty values instead of bubbling up the error.
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
198
|
|
|
195
|
-
resolve
|
|
199
|
+
return new Promise(function (resolve) {
|
|
200
|
+
_this2.makeRequest(userId).then(function (data) {
|
|
201
|
+
var enhancedData = {
|
|
202
|
+
managers: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.managers),
|
|
203
|
+
reports: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.reports)
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
if (_this2.cache) {
|
|
207
|
+
_this2.setCachedProfile(userId, enhancedData);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
resolve(enhancedData);
|
|
211
|
+
}).catch(function (error) {
|
|
212
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
213
|
+
// Trigger circuit breaker
|
|
214
|
+
_this2.bypassOnFailure = true;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Reporting lines aren't part of the critical path of profile card.
|
|
218
|
+
* Just resolve with empty values instead of bubbling up the error.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
resolve({});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return Promise.resolve({
|
|
228
|
+
managers: [],
|
|
229
|
+
reports: []
|
|
230
|
+
});
|
|
231
|
+
}, function () {
|
|
232
|
+
return Promise.resolve({
|
|
233
|
+
managers: [],
|
|
234
|
+
reports: []
|
|
196
235
|
});
|
|
197
236
|
});
|
|
198
237
|
}
|
|
@@ -201,35 +240,43 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
201
240
|
value: function getFlagEnabled(featureKey, productIdentifier) {
|
|
202
241
|
var _this3 = this;
|
|
203
242
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
210
|
-
}
|
|
243
|
+
return this.isTCReadyPromise.then(function (workSpaceExists) {
|
|
244
|
+
if (workSpaceExists) {
|
|
245
|
+
if (!featureKey) {
|
|
246
|
+
return Promise.reject(new Error('featureKey missing'));
|
|
247
|
+
}
|
|
211
248
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
249
|
+
if (_this3.featureFlagKeys.has(featureKey)) {
|
|
250
|
+
return Promise.resolve(_this3.featureFlagKeys.get(featureKey));
|
|
251
|
+
}
|
|
215
252
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
value: productIdentifier || 'unset'
|
|
219
|
-
}];
|
|
220
|
-
return new Promise(function (resolve) {
|
|
221
|
-
_this3.makeFeatureFlagCheckRequest(featureKey, context).then(function (enabled) {
|
|
222
|
-
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
223
|
-
|
|
224
|
-
resolve(enabled);
|
|
225
|
-
}).catch(function (error) {
|
|
226
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
227
|
-
// Trigger circuit breaker
|
|
228
|
-
_this3.bypassOnFailure = true;
|
|
253
|
+
if (_this3.bypassOnFailure) {
|
|
254
|
+
return Promise.resolve(false);
|
|
229
255
|
}
|
|
230
256
|
|
|
231
|
-
|
|
232
|
-
|
|
257
|
+
var context = [{
|
|
258
|
+
key: 'productIdentifier',
|
|
259
|
+
value: productIdentifier || 'unset'
|
|
260
|
+
}];
|
|
261
|
+
return new Promise(function (resolve) {
|
|
262
|
+
_this3.makeFeatureFlagCheckRequest(featureKey, context).then(function (enabled) {
|
|
263
|
+
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
264
|
+
|
|
265
|
+
resolve(enabled);
|
|
266
|
+
}).catch(function (error) {
|
|
267
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
268
|
+
// Trigger circuit breaker
|
|
269
|
+
_this3.bypassOnFailure = true;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
resolve(false);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return Promise.resolve(false);
|
|
278
|
+
}, function () {
|
|
279
|
+
return Promise.resolve(false);
|
|
233
280
|
});
|
|
234
281
|
}
|
|
235
282
|
}, {
|
|
@@ -59,7 +59,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
59
59
|
actionSubjectId: actionSubjectId,
|
|
60
60
|
attributes: _objectSpread(_objectSpread({
|
|
61
61
|
packageName: "@atlaskit/profilecard",
|
|
62
|
-
packageVersion: "17.
|
|
62
|
+
packageVersion: "17.1.0"
|
|
63
63
|
}, attributes), {}, {
|
|
64
64
|
firedAt: Math.round((0, _performance.getPageTime)())
|
|
65
65
|
})
|
package/dist/cjs/version.json
CHANGED
|
@@ -41,11 +41,11 @@ class ProfileCardClient {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
shouldShowGiveKudos() {
|
|
44
|
-
var _this$tcClient4, _this$tcClient5
|
|
44
|
+
var _this$tcClient4, _this$tcClient5;
|
|
45
45
|
|
|
46
46
|
// Check if the kudos feature enabled and if the user has TC
|
|
47
47
|
// if the user does not have TC the tc client will be undefined.
|
|
48
|
-
return
|
|
48
|
+
return this.getTeamCentralBaseUrl() && ((_this$tcClient4 = this.tcClient) === null || _this$tcClient4 === void 0 ? void 0 : _this$tcClient4.getFlagEnabled('team-central-kudos-enabled-m2', (_this$tcClient5 = this.tcClient) === null || _this$tcClient5 === void 0 ? void 0 : _this$tcClient5.options.productIdentifier)) || Promise.resolve(false);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
}
|
|
@@ -46,6 +46,14 @@ const buildCheckFeatureFlagQuery = (featureKey, context) => ({
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
function hasTCWorkspace(config) {
|
|
50
|
+
return config.cloudId ? fetch(`/gateway/api/watermelon/organization/containsAnyWorkspace?cloudId=${config.cloudId}`).then(res => {
|
|
51
|
+
return !res || res && res.ok;
|
|
52
|
+
}) : Promise.resolve(false);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let isTCReadyPromiseMap = new Map();
|
|
56
|
+
|
|
49
57
|
class TeamCentralCardClient extends CachingClient {
|
|
50
58
|
/**
|
|
51
59
|
* Simple circuit breaker to avoid making unnecessary calls to Team Central on auth failures
|
|
@@ -60,6 +68,22 @@ class TeamCentralCardClient extends CachingClient {
|
|
|
60
68
|
this.options = options;
|
|
61
69
|
this.bypassOnFailure = false;
|
|
62
70
|
this.featureFlagKeys = new Map();
|
|
71
|
+
this.isTCReadyPromise = this.createTcReadyPromise(options);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
createTcReadyPromise(config) {
|
|
75
|
+
if (config.cloudId) {
|
|
76
|
+
let promise = isTCReadyPromiseMap.get(config.cloudId);
|
|
77
|
+
|
|
78
|
+
if (!promise) {
|
|
79
|
+
promise = hasTCWorkspace(config);
|
|
80
|
+
isTCReadyPromiseMap.set(config.cloudId, promise);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return promise;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return Promise.resolve(true);
|
|
63
87
|
}
|
|
64
88
|
|
|
65
89
|
async makeFeatureFlagCheckRequest(featureKey, context) {
|
|
@@ -68,7 +92,7 @@ class TeamCentralCardClient extends CachingClient {
|
|
|
68
92
|
}
|
|
69
93
|
|
|
70
94
|
const query = buildCheckFeatureFlagQuery(featureKey, context);
|
|
71
|
-
const response = await graphqlQuery(this.options.teamCentralUrl
|
|
95
|
+
const response = await graphqlQuery(`${this.options.teamCentralUrl}?operationName=isFeatureKeyEnabled`, query);
|
|
72
96
|
return response.isFeatureEnabled.enabled;
|
|
73
97
|
}
|
|
74
98
|
|
|
@@ -78,83 +102,101 @@ class TeamCentralCardClient extends CachingClient {
|
|
|
78
102
|
}
|
|
79
103
|
|
|
80
104
|
const query = buildReportingLinesQuery(userId);
|
|
81
|
-
const response = await graphqlQuery(this.options.teamCentralUrl
|
|
105
|
+
const response = await graphqlQuery(`${this.options.teamCentralUrl}?operationName=ReportingLines`, query);
|
|
82
106
|
return response.reportingLines;
|
|
83
107
|
}
|
|
84
108
|
|
|
85
109
|
getReportingLines(userId) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (cache) {
|
|
93
|
-
return Promise.resolve(cache);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (this.bypassOnFailure) {
|
|
97
|
-
return Promise.resolve({});
|
|
98
|
-
}
|
|
110
|
+
return this.isTCReadyPromise.then(workSpaceExists => {
|
|
111
|
+
if (workSpaceExists) {
|
|
112
|
+
if (!userId) {
|
|
113
|
+
return Promise.reject(new Error('userId missing'));
|
|
114
|
+
}
|
|
99
115
|
|
|
100
|
-
|
|
101
|
-
this.makeRequest(userId).then(data => {
|
|
102
|
-
const enhancedData = {
|
|
103
|
-
managers: this.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.managers),
|
|
104
|
-
reports: this.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.reports)
|
|
105
|
-
};
|
|
116
|
+
const cache = this.getCachedProfile(userId);
|
|
106
117
|
|
|
107
|
-
if (
|
|
108
|
-
|
|
118
|
+
if (cache) {
|
|
119
|
+
return Promise.resolve(cache);
|
|
109
120
|
}
|
|
110
121
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
114
|
-
// Trigger circuit breaker
|
|
115
|
-
this.bypassOnFailure = true;
|
|
122
|
+
if (this.bypassOnFailure) {
|
|
123
|
+
return Promise.resolve({});
|
|
116
124
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Reporting lines aren't part of the critical path of profile card.
|
|
119
|
-
* Just resolve with empty values instead of bubbling up the error.
|
|
120
|
-
*/
|
|
121
125
|
|
|
126
|
+
return new Promise(resolve => {
|
|
127
|
+
this.makeRequest(userId).then(data => {
|
|
128
|
+
const enhancedData = {
|
|
129
|
+
managers: this.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.managers),
|
|
130
|
+
reports: this.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.reports)
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
if (this.cache) {
|
|
134
|
+
this.setCachedProfile(userId, enhancedData);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
resolve(enhancedData);
|
|
138
|
+
}).catch(error => {
|
|
139
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
140
|
+
// Trigger circuit breaker
|
|
141
|
+
this.bypassOnFailure = true;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Reporting lines aren't part of the critical path of profile card.
|
|
145
|
+
* Just resolve with empty values instead of bubbling up the error.
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
resolve({});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
122
153
|
|
|
123
|
-
|
|
154
|
+
return Promise.resolve({
|
|
155
|
+
managers: [],
|
|
156
|
+
reports: []
|
|
124
157
|
});
|
|
125
|
-
})
|
|
158
|
+
}, () => Promise.resolve({
|
|
159
|
+
managers: [],
|
|
160
|
+
reports: []
|
|
161
|
+
}));
|
|
126
162
|
}
|
|
127
163
|
|
|
128
164
|
getFlagEnabled(featureKey, productIdentifier) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
135
|
-
}
|
|
165
|
+
return this.isTCReadyPromise.then(workSpaceExists => {
|
|
166
|
+
if (workSpaceExists) {
|
|
167
|
+
if (!featureKey) {
|
|
168
|
+
return Promise.reject(new Error('featureKey missing'));
|
|
169
|
+
}
|
|
136
170
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
171
|
+
if (this.featureFlagKeys.has(featureKey)) {
|
|
172
|
+
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
173
|
+
}
|
|
140
174
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
value: productIdentifier || 'unset'
|
|
144
|
-
}];
|
|
145
|
-
return new Promise(resolve => {
|
|
146
|
-
this.makeFeatureFlagCheckRequest(featureKey, context).then(enabled => {
|
|
147
|
-
this.featureFlagKeys.set(featureKey, enabled);
|
|
148
|
-
resolve(enabled);
|
|
149
|
-
}).catch(error => {
|
|
150
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
151
|
-
// Trigger circuit breaker
|
|
152
|
-
this.bypassOnFailure = true;
|
|
175
|
+
if (this.bypassOnFailure) {
|
|
176
|
+
return Promise.resolve(false);
|
|
153
177
|
}
|
|
154
178
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
179
|
+
const context = [{
|
|
180
|
+
key: 'productIdentifier',
|
|
181
|
+
value: productIdentifier || 'unset'
|
|
182
|
+
}];
|
|
183
|
+
return new Promise(resolve => {
|
|
184
|
+
this.makeFeatureFlagCheckRequest(featureKey, context).then(enabled => {
|
|
185
|
+
this.featureFlagKeys.set(featureKey, enabled);
|
|
186
|
+
resolve(enabled);
|
|
187
|
+
}).catch(error => {
|
|
188
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
189
|
+
// Trigger circuit breaker
|
|
190
|
+
this.bypassOnFailure = true;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
resolve(false);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return Promise.resolve(false);
|
|
199
|
+
}, () => Promise.resolve(false));
|
|
158
200
|
}
|
|
159
201
|
|
|
160
202
|
filterReportingLinesUser(users = []) {
|
|
@@ -38,7 +38,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
38
38
|
actionSubjectId,
|
|
39
39
|
attributes: {
|
|
40
40
|
packageName: "@atlaskit/profilecard",
|
|
41
|
-
packageVersion: "17.
|
|
41
|
+
packageVersion: "17.1.0",
|
|
42
42
|
...attributes,
|
|
43
43
|
firedAt: Math.round(getPageTime())
|
|
44
44
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -58,11 +58,11 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
58
58
|
}, {
|
|
59
59
|
key: "shouldShowGiveKudos",
|
|
60
60
|
value: function shouldShowGiveKudos() {
|
|
61
|
-
var _this$tcClient4, _this$tcClient5
|
|
61
|
+
var _this$tcClient4, _this$tcClient5;
|
|
62
62
|
|
|
63
63
|
// Check if the kudos feature enabled and if the user has TC
|
|
64
64
|
// if the user does not have TC the tc client will be undefined.
|
|
65
|
-
return
|
|
65
|
+
return this.getTeamCentralBaseUrl() && ((_this$tcClient4 = this.tcClient) === null || _this$tcClient4 === void 0 ? void 0 : _this$tcClient4.getFlagEnabled('team-central-kudos-enabled-m2', (_this$tcClient5 = this.tcClient) === null || _this$tcClient5 === void 0 ? void 0 : _this$tcClient5.options.productIdentifier)) || Promise.resolve(false);
|
|
66
66
|
}
|
|
67
67
|
}]);
|
|
68
68
|
|
|
@@ -32,6 +32,14 @@ var buildCheckFeatureFlagQuery = function buildCheckFeatureFlagQuery(featureKey,
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
function hasTCWorkspace(config) {
|
|
36
|
+
return config.cloudId ? fetch("/gateway/api/watermelon/organization/containsAnyWorkspace?cloudId=".concat(config.cloudId)).then(function (res) {
|
|
37
|
+
return !res || res && res.ok;
|
|
38
|
+
}) : Promise.resolve(false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var isTCReadyPromiseMap = new Map();
|
|
42
|
+
|
|
35
43
|
var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
36
44
|
_inherits(TeamCentralCardClient, _CachingClient);
|
|
37
45
|
|
|
@@ -54,10 +62,27 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
54
62
|
_this.options = options;
|
|
55
63
|
_this.bypassOnFailure = false;
|
|
56
64
|
_this.featureFlagKeys = new Map();
|
|
65
|
+
_this.isTCReadyPromise = _this.createTcReadyPromise(options);
|
|
57
66
|
return _this;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
_createClass(TeamCentralCardClient, [{
|
|
70
|
+
key: "createTcReadyPromise",
|
|
71
|
+
value: function createTcReadyPromise(config) {
|
|
72
|
+
if (config.cloudId) {
|
|
73
|
+
var promise = isTCReadyPromiseMap.get(config.cloudId);
|
|
74
|
+
|
|
75
|
+
if (!promise) {
|
|
76
|
+
promise = hasTCWorkspace(config);
|
|
77
|
+
isTCReadyPromiseMap.set(config.cloudId, promise);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return promise;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return Promise.resolve(true);
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
61
86
|
key: "makeFeatureFlagCheckRequest",
|
|
62
87
|
value: function () {
|
|
63
88
|
var _makeFeatureFlagCheckRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(featureKey, context) {
|
|
@@ -76,7 +101,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
76
101
|
case 2:
|
|
77
102
|
query = buildCheckFeatureFlagQuery(featureKey, context);
|
|
78
103
|
_context.next = 5;
|
|
79
|
-
return graphqlQuery(this.options.teamCentralUrl, query);
|
|
104
|
+
return graphqlQuery("".concat(this.options.teamCentralUrl, "?operationName=isFeatureKeyEnabled"), query);
|
|
80
105
|
|
|
81
106
|
case 5:
|
|
82
107
|
response = _context.sent;
|
|
@@ -115,7 +140,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
115
140
|
case 2:
|
|
116
141
|
query = buildReportingLinesQuery(userId);
|
|
117
142
|
_context2.next = 5;
|
|
118
|
-
return graphqlQuery(this.options.teamCentralUrl, query);
|
|
143
|
+
return graphqlQuery("".concat(this.options.teamCentralUrl, "?operationName=ReportingLines"), query);
|
|
119
144
|
|
|
120
145
|
case 5:
|
|
121
146
|
response = _context2.sent;
|
|
@@ -140,44 +165,58 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
140
165
|
value: function getReportingLines(userId) {
|
|
141
166
|
var _this2 = this;
|
|
142
167
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (cache) {
|
|
150
|
-
return Promise.resolve(cache);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (this.bypassOnFailure) {
|
|
154
|
-
return Promise.resolve({});
|
|
155
|
-
}
|
|
168
|
+
return this.isTCReadyPromise.then(function (workSpaceExists) {
|
|
169
|
+
if (workSpaceExists) {
|
|
170
|
+
if (!userId) {
|
|
171
|
+
return Promise.reject(new Error('userId missing'));
|
|
172
|
+
}
|
|
156
173
|
|
|
157
|
-
|
|
158
|
-
_this2.makeRequest(userId).then(function (data) {
|
|
159
|
-
var enhancedData = {
|
|
160
|
-
managers: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.managers),
|
|
161
|
-
reports: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.reports)
|
|
162
|
-
};
|
|
174
|
+
var cache = _this2.getCachedProfile(userId);
|
|
163
175
|
|
|
164
|
-
if (
|
|
165
|
-
|
|
176
|
+
if (cache) {
|
|
177
|
+
return Promise.resolve(cache);
|
|
166
178
|
}
|
|
167
179
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
171
|
-
// Trigger circuit breaker
|
|
172
|
-
_this2.bypassOnFailure = true;
|
|
180
|
+
if (_this2.bypassOnFailure) {
|
|
181
|
+
return Promise.resolve({});
|
|
173
182
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Reporting lines aren't part of the critical path of profile card.
|
|
176
|
-
* Just resolve with empty values instead of bubbling up the error.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
183
|
|
|
180
|
-
resolve
|
|
184
|
+
return new Promise(function (resolve) {
|
|
185
|
+
_this2.makeRequest(userId).then(function (data) {
|
|
186
|
+
var enhancedData = {
|
|
187
|
+
managers: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.managers),
|
|
188
|
+
reports: _this2.filterReportingLinesUser(data === null || data === void 0 ? void 0 : data.reports)
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
if (_this2.cache) {
|
|
192
|
+
_this2.setCachedProfile(userId, enhancedData);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
resolve(enhancedData);
|
|
196
|
+
}).catch(function (error) {
|
|
197
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
198
|
+
// Trigger circuit breaker
|
|
199
|
+
_this2.bypassOnFailure = true;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Reporting lines aren't part of the critical path of profile card.
|
|
203
|
+
* Just resolve with empty values instead of bubbling up the error.
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
resolve({});
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return Promise.resolve({
|
|
213
|
+
managers: [],
|
|
214
|
+
reports: []
|
|
215
|
+
});
|
|
216
|
+
}, function () {
|
|
217
|
+
return Promise.resolve({
|
|
218
|
+
managers: [],
|
|
219
|
+
reports: []
|
|
181
220
|
});
|
|
182
221
|
});
|
|
183
222
|
}
|
|
@@ -186,35 +225,43 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
186
225
|
value: function getFlagEnabled(featureKey, productIdentifier) {
|
|
187
226
|
var _this3 = this;
|
|
188
227
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
195
|
-
}
|
|
228
|
+
return this.isTCReadyPromise.then(function (workSpaceExists) {
|
|
229
|
+
if (workSpaceExists) {
|
|
230
|
+
if (!featureKey) {
|
|
231
|
+
return Promise.reject(new Error('featureKey missing'));
|
|
232
|
+
}
|
|
196
233
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
234
|
+
if (_this3.featureFlagKeys.has(featureKey)) {
|
|
235
|
+
return Promise.resolve(_this3.featureFlagKeys.get(featureKey));
|
|
236
|
+
}
|
|
200
237
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
value: productIdentifier || 'unset'
|
|
204
|
-
}];
|
|
205
|
-
return new Promise(function (resolve) {
|
|
206
|
-
_this3.makeFeatureFlagCheckRequest(featureKey, context).then(function (enabled) {
|
|
207
|
-
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
208
|
-
|
|
209
|
-
resolve(enabled);
|
|
210
|
-
}).catch(function (error) {
|
|
211
|
-
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
212
|
-
// Trigger circuit breaker
|
|
213
|
-
_this3.bypassOnFailure = true;
|
|
238
|
+
if (_this3.bypassOnFailure) {
|
|
239
|
+
return Promise.resolve(false);
|
|
214
240
|
}
|
|
215
241
|
|
|
216
|
-
|
|
217
|
-
|
|
242
|
+
var context = [{
|
|
243
|
+
key: 'productIdentifier',
|
|
244
|
+
value: productIdentifier || 'unset'
|
|
245
|
+
}];
|
|
246
|
+
return new Promise(function (resolve) {
|
|
247
|
+
_this3.makeFeatureFlagCheckRequest(featureKey, context).then(function (enabled) {
|
|
248
|
+
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
249
|
+
|
|
250
|
+
resolve(enabled);
|
|
251
|
+
}).catch(function (error) {
|
|
252
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
253
|
+
// Trigger circuit breaker
|
|
254
|
+
_this3.bypassOnFailure = true;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
resolve(false);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return Promise.resolve(false);
|
|
263
|
+
}, function () {
|
|
264
|
+
return Promise.resolve(false);
|
|
218
265
|
});
|
|
219
266
|
}
|
|
220
267
|
}, {
|
|
@@ -48,7 +48,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
48
48
|
actionSubjectId: actionSubjectId,
|
|
49
49
|
attributes: _objectSpread(_objectSpread({
|
|
50
50
|
packageName: "@atlaskit/profilecard",
|
|
51
|
-
packageVersion: "17.
|
|
51
|
+
packageVersion: "17.1.0"
|
|
52
52
|
}, attributes), {}, {
|
|
53
53
|
firedAt: Math.round(getPageTime())
|
|
54
54
|
})
|
package/dist/esm/version.json
CHANGED
|
@@ -19,7 +19,9 @@ declare class TeamCentralCardClient extends CachingClient<TeamCentralReportingLi
|
|
|
19
19
|
*/
|
|
20
20
|
bypassOnFailure: boolean;
|
|
21
21
|
featureFlagKeys: Map<string, boolean>;
|
|
22
|
+
isTCReadyPromise: Promise<boolean>;
|
|
22
23
|
constructor(options: TeamCentralCardClientOptions);
|
|
24
|
+
createTcReadyPromise(config: ProfileClientOptions): Promise<boolean>;
|
|
23
25
|
makeFeatureFlagCheckRequest(featureKey: string, context?: FeatureFlagExtraContext[]): Promise<boolean>;
|
|
24
26
|
makeRequest(userId: string): Promise<TeamCentralReportingLinesData>;
|
|
25
27
|
getReportingLines(userId: string): Promise<TeamCentralReportingLinesData>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -346,6 +346,7 @@ export interface ProfileClientOptions {
|
|
|
346
346
|
teamCentralBaseUrl?: string;
|
|
347
347
|
/** Name of integrating product e.g. jira, atlas, confluence **/
|
|
348
348
|
productIdentifier?: string;
|
|
349
|
+
cloudId?: string;
|
|
349
350
|
}
|
|
350
351
|
export interface ClientOverrides {
|
|
351
352
|
userClient?: UserProfileCardClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/profilecard",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.1.0",
|
|
4
4
|
"description": "A React component to display a card with user information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@atlaskit/avatar": "^21.0.0",
|
|
43
43
|
"@atlaskit/avatar-group": "^9.0.0",
|
|
44
44
|
"@atlaskit/button": "^16.3.0",
|
|
45
|
-
"@atlaskit/dropdown-menu": "^11.
|
|
45
|
+
"@atlaskit/dropdown-menu": "^11.5.0",
|
|
46
46
|
"@atlaskit/give-kudos": "^0.6.0",
|
|
47
47
|
"@atlaskit/icon": "^21.10.0",
|
|
48
48
|
"@atlaskit/lozenge": "^11.2.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@atlaskit/select": "^15.7.0",
|
|
71
71
|
"@atlaskit/util-data-test": "^17.5.0",
|
|
72
72
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
73
|
-
"@testing-library/react": "^
|
|
73
|
+
"@testing-library/react": "^12.1.5",
|
|
74
74
|
"enzyme": "^3.10.0",
|
|
75
75
|
"es6-promise": "^4.0.5",
|
|
76
76
|
"fetch-mock": "^8.0.0",
|
package/report.api.md
CHANGED
|
@@ -346,6 +346,7 @@ export declare interface ProfileClientOptions {
|
|
|
346
346
|
teamCentralBaseUrl?: string;
|
|
347
347
|
/** Name of integrating product e.g. jira, atlas, confluence **/
|
|
348
348
|
productIdentifier?: string;
|
|
349
|
+
cloudId?: string;
|
|
349
350
|
}
|
|
350
351
|
|
|
351
352
|
export declare type RelativeDateKeyType =
|
|
@@ -409,7 +410,9 @@ declare class TeamCentralCardClient extends CachingClient<
|
|
|
409
410
|
*/
|
|
410
411
|
bypassOnFailure: boolean;
|
|
411
412
|
featureFlagKeys: Map<string, boolean>;
|
|
413
|
+
isTCReadyPromise: Promise<boolean>;
|
|
412
414
|
constructor(options: TeamCentralCardClientOptions);
|
|
415
|
+
createTcReadyPromise(config: ProfileClientOptions): Promise<boolean>;
|
|
413
416
|
makeFeatureFlagCheckRequest(
|
|
414
417
|
featureKey: string,
|
|
415
418
|
context?: FeatureFlagExtraContext[],
|