@atlaskit/profilecard 19.5.9 → 19.5.11
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 +120 -108
- package/dist/cjs/client/TeamCentralCardClient.js +2 -2
- package/dist/cjs/client/UserProfileCardClient.js +1 -1
- package/dist/cjs/client/errorUtils.js +67 -14
- package/dist/cjs/client/getTeamFromAGG.js +5 -5
- package/dist/cjs/client/graphqlUtils.js +106 -36
- package/dist/cjs/client/types.js +5 -0
- package/dist/cjs/mocks/mock-team-client.js +6 -1
- package/dist/cjs/styled/ReportingLines.js +1 -1
- package/dist/cjs/styled/TeamCard.js +2 -2
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/cjs/util/errors.js +114 -0
- package/dist/es2019/client/TeamCentralCardClient.js +3 -3
- package/dist/es2019/client/UserProfileCardClient.js +2 -2
- package/dist/es2019/client/errorUtils.js +63 -12
- package/dist/es2019/client/getTeamFromAGG.js +3 -3
- package/dist/es2019/client/graphqlUtils.js +28 -26
- package/dist/es2019/client/types.js +1 -0
- package/dist/es2019/mocks/mock-team-client.js +6 -1
- package/dist/es2019/styled/ReportingLines.js +1 -1
- package/dist/es2019/styled/TeamCard.js +3 -3
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/es2019/util/errors.js +59 -0
- package/dist/esm/client/TeamCentralCardClient.js +3 -3
- package/dist/esm/client/UserProfileCardClient.js +2 -2
- package/dist/esm/client/errorUtils.js +63 -12
- package/dist/esm/client/getTeamFromAGG.js +6 -6
- package/dist/esm/client/graphqlUtils.js +104 -35
- package/dist/esm/client/types.js +1 -0
- package/dist/esm/mocks/mock-team-client.js +6 -1
- package/dist/esm/styled/ReportingLines.js +1 -1
- package/dist/esm/styled/TeamCard.js +2 -2
- package/dist/esm/util/analytics.js +1 -1
- package/dist/esm/util/errors.js +102 -0
- package/dist/types/client/errorUtils.d.ts +5 -9
- package/dist/types/client/graphqlUtils.d.ts +13 -1
- package/dist/types/client/types.d.ts +12 -0
- package/dist/types/mocks/mock-team-client.d.ts +1 -0
- package/dist/types/util/analytics.d.ts +2 -1
- package/dist/types/util/errors.d.ts +43 -0
- package/dist/types-ts4.5/client/errorUtils.d.ts +5 -9
- package/dist/types-ts4.5/client/graphqlUtils.d.ts +13 -1
- package/dist/types-ts4.5/client/types.d.ts +12 -0
- package/dist/types-ts4.5/mocks/mock-team-client.d.ts +1 -0
- package/dist/types-ts4.5/util/analytics.d.ts +2 -1
- package/dist/types-ts4.5/util/errors.d.ts +43 -0
- package/package.json +6 -6
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { HttpError } from '../util/errors';
|
|
2
|
+
import { handleAGGErrors, handleDirectoryGraphQLErrors } from './errorUtils';
|
|
1
3
|
const buildHeaders = () => {
|
|
2
4
|
const headers = new Headers();
|
|
3
5
|
headers.append('Content-Type', 'application/json');
|
|
@@ -10,36 +12,36 @@ const id = headers => headers;
|
|
|
10
12
|
* @param {Query} query - GraphQL query
|
|
11
13
|
* @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
|
|
12
14
|
*/
|
|
13
|
-
export function
|
|
15
|
+
export async function directoryGraphqlQuery(serviceUrl, query, processHeaders = id) {
|
|
16
|
+
return graphQLQuery(serviceUrl, query, processHeaders, handleDirectoryGraphQLErrors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} serviceUrl - GraphQL service endpoint
|
|
21
|
+
* @param {Query} query - GraphQL query
|
|
22
|
+
* @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
|
|
23
|
+
*/
|
|
24
|
+
export async function AGGQuery(serviceUrl, query, processHeaders = id) {
|
|
25
|
+
return graphQLQuery(serviceUrl, query, processHeaders, handleAGGErrors);
|
|
26
|
+
}
|
|
27
|
+
async function graphQLQuery(serviceUrl, query, processHeaders = id, handleErrors) {
|
|
28
|
+
var _response$headers;
|
|
14
29
|
const headers = processHeaders(buildHeaders());
|
|
15
|
-
|
|
30
|
+
const response = await fetch(new Request(serviceUrl, {
|
|
16
31
|
method: 'POST',
|
|
17
32
|
credentials: 'include',
|
|
18
33
|
mode: 'cors',
|
|
19
34
|
headers,
|
|
20
35
|
body: JSON.stringify(query)
|
|
21
|
-
}))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}).then(response => response.json()).then(json => {
|
|
33
|
-
if (json.errors) {
|
|
34
|
-
var _json$errors$, _json$errors$2, _json$errors$2$extens, _json$errors$3, _json$errors$3$extens, _json$errors$4, _json$errors$4$extens, _json$extensions, _json$extensions$gate;
|
|
35
|
-
return Promise.reject({
|
|
36
|
-
reason: ((_json$errors$ = json.errors[0]) === null || _json$errors$ === void 0 ? void 0 : _json$errors$.category) || ((_json$errors$2 = json.errors[0]) === null || _json$errors$2 === void 0 ? void 0 : (_json$errors$2$extens = _json$errors$2.extensions) === null || _json$errors$2$extens === void 0 ? void 0 : _json$errors$2$extens.classification) || 'default',
|
|
37
|
-
code: (_json$errors$3 = json.errors[0]) === null || _json$errors$3 === void 0 ? void 0 : (_json$errors$3$extens = _json$errors$3.extensions) === null || _json$errors$3$extens === void 0 ? void 0 : _json$errors$3$extens.statusCode,
|
|
38
|
-
source: (_json$errors$4 = json.errors[0]) === null || _json$errors$4 === void 0 ? void 0 : (_json$errors$4$extens = _json$errors$4.extensions) === null || _json$errors$4$extens === void 0 ? void 0 : _json$errors$4$extens.errorSource,
|
|
39
|
-
message: json.errors[0].message,
|
|
40
|
-
traceId: (_json$extensions = json.extensions) === null || _json$extensions === void 0 ? void 0 : (_json$extensions$gate = _json$extensions.gateway) === null || _json$extensions$gate === void 0 ? void 0 : _json$extensions$gate.request_id
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return json.data;
|
|
44
|
-
});
|
|
36
|
+
}));
|
|
37
|
+
const traceIdFromHeaders = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('atl-traceid');
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new HttpError(response.status, response.statusText, traceIdFromHeaders);
|
|
40
|
+
}
|
|
41
|
+
const json = await response.json();
|
|
42
|
+
if (json.errors) {
|
|
43
|
+
var _json$extensions$gate, _json$extensions, _json$extensions$gate2;
|
|
44
|
+
handleErrors(json.errors, (_json$extensions$gate = (_json$extensions = json.extensions) === null || _json$extensions === void 0 ? void 0 : (_json$extensions$gate2 = _json$extensions.gateway) === null || _json$extensions$gate2 === void 0 ? void 0 : _json$extensions$gate2.request_id) !== null && _json$extensions$gate !== void 0 ? _json$extensions$gate : traceIdFromHeaders);
|
|
45
|
+
}
|
|
46
|
+
return json.data;
|
|
45
47
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { handleAGGErrors } from '../client/errorUtils';
|
|
1
2
|
import TeamProfileCardClient from '../client/TeamProfileCardClient';
|
|
2
3
|
export default function getMockTeamClient(data) {
|
|
3
4
|
return class MockTeamClient extends TeamProfileCardClient {
|
|
@@ -12,7 +13,11 @@ export default function getMockTeamClient(data) {
|
|
|
12
13
|
};
|
|
13
14
|
if (!data.timeout) {
|
|
14
15
|
if (data.error && Math.random() < data.errorRate) {
|
|
15
|
-
|
|
16
|
+
try {
|
|
17
|
+
handleAGGErrors(data.error, data.traceId);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return Promise.reject(e);
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
return Promise.resolve(data.team);
|
|
18
23
|
}
|
|
@@ -24,5 +24,5 @@ export const ManagerName = styled.span`
|
|
|
24
24
|
export const OffsetWrapper = styled.div`
|
|
25
25
|
margin-top: ${"var(--ds-space-050, 4px)"};
|
|
26
26
|
// Offset left margin so the avatar aligns with the heading
|
|
27
|
-
margin-left:
|
|
27
|
+
margin-left: ${"var(--ds-space-negative-050, -4px)"};
|
|
28
28
|
`;
|
|
@@ -48,7 +48,7 @@ export const MemberCount = styled.div`
|
|
|
48
48
|
`;
|
|
49
49
|
export const AvatarSection = styled.div`
|
|
50
50
|
margin-top: ${"var(--ds-space-200, 16px)"};
|
|
51
|
-
margin-left:
|
|
51
|
+
margin-left: ${"var(--ds-space-negative-025, -2px)"};
|
|
52
52
|
`;
|
|
53
53
|
export const DescriptionWrapper = styled.div`
|
|
54
54
|
margin-top: ${"var(--ds-space-200, 16px)"};
|
|
@@ -66,8 +66,8 @@ export const ActionButtons = styled.div`
|
|
|
66
66
|
width: calc(100% + 8px);
|
|
67
67
|
display: flex;
|
|
68
68
|
justify-content: space-between;
|
|
69
|
-
margin: ${"var(--ds-space-300, 24px)"}
|
|
70
|
-
0
|
|
69
|
+
margin: ${"var(--ds-space-300, 24px)"} ${"var(--ds-space-negative-300, -24px)"}
|
|
70
|
+
0 ${"var(--ds-space-negative-100, -8px)"};
|
|
71
71
|
background-color: ${"var(--ds-surface-overlay, hsla(0, 100%, 100%, 0.2))"};
|
|
72
72
|
`;
|
|
73
73
|
export const WrappedButton = styled.div`
|
|
@@ -31,7 +31,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
31
31
|
actionSubjectId,
|
|
32
32
|
attributes: {
|
|
33
33
|
packageName: "@atlaskit/profilecard",
|
|
34
|
-
packageVersion: "19.5.
|
|
34
|
+
packageVersion: "19.5.11",
|
|
35
35
|
...attributes,
|
|
36
36
|
firedAt: Math.round(getPageTime())
|
|
37
37
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export class HttpError extends Error {
|
|
2
|
+
constructor(code, reason, traceId) {
|
|
3
|
+
super(reason);
|
|
4
|
+
this.code = code;
|
|
5
|
+
this.traceId = traceId;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class DirectoryGraphQLError extends Error {
|
|
9
|
+
constructor(message, category, type, extensions, path = []) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.category = category;
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.path = path.join('.');
|
|
14
|
+
const {
|
|
15
|
+
errorNumber,
|
|
16
|
+
...unknownExtension
|
|
17
|
+
} = extensions;
|
|
18
|
+
this.errorNumber = extensions.errorNumber;
|
|
19
|
+
this.extensions = unknownExtension;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class DirectoryGraphQLErrors extends Error {
|
|
23
|
+
constructor(errors, traceId) {
|
|
24
|
+
super('DirectoryGraphQLErrors');
|
|
25
|
+
this.traceId = traceId;
|
|
26
|
+
if (Array.isArray(errors)) {
|
|
27
|
+
this.errors = errors.map(error => new DirectoryGraphQLError(error.message, error.category, error.type, error.extensions, error.path));
|
|
28
|
+
} else {
|
|
29
|
+
this.errors = [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class AGGError extends Error {
|
|
34
|
+
constructor(message, extensions, path = []) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.path = path === null || path === void 0 ? void 0 : path.join('.');
|
|
37
|
+
const {
|
|
38
|
+
statusCode,
|
|
39
|
+
errorType,
|
|
40
|
+
classification,
|
|
41
|
+
...unknownExtension
|
|
42
|
+
} = extensions;
|
|
43
|
+
this.statusCode = statusCode;
|
|
44
|
+
this.errorType = errorType;
|
|
45
|
+
this.classification = classification;
|
|
46
|
+
this.extensions = unknownExtension;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class AGGErrors extends Error {
|
|
50
|
+
constructor(errors, traceId) {
|
|
51
|
+
super('AGGErrors');
|
|
52
|
+
this.traceId = traceId;
|
|
53
|
+
if (Array.isArray(errors)) {
|
|
54
|
+
this.errors = errors.map(error => new AGGError(error.message, error.extensions, error.path));
|
|
55
|
+
} else {
|
|
56
|
+
this.errors = [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -8,7 +8,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
8
8
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
9
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
10
|
import CachingClient from './CachingClient';
|
|
11
|
-
import {
|
|
11
|
+
import { directoryGraphqlQuery } from './graphqlUtils';
|
|
12
12
|
var buildReportingLinesQuery = function buildReportingLinesQuery(aaid) {
|
|
13
13
|
return {
|
|
14
14
|
query: "\n fragment ReportingLinesUserPII on UserPII {\n name\n picture\n }\n\n fragment ReportingLinesUserFragment on ReportingLinesUser {\n accountIdentifier\n identifierType\n pii {\n ...ReportingLinesUserPII\n }\n }\n\n query ReportingLines($aaid: String) {\n reportingLines(aaidOrHash: $aaid) {\n managers {\n ...ReportingLinesUserFragment\n }\n reports {\n ...ReportingLinesUserFragment\n }\n }\n }\n ",
|
|
@@ -83,7 +83,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
83
83
|
case 2:
|
|
84
84
|
query = buildCheckFeatureFlagQuery(featureKey, context);
|
|
85
85
|
_context.next = 5;
|
|
86
|
-
return
|
|
86
|
+
return directoryGraphqlQuery("".concat(this.options.teamCentralUrl, "?operationName=isFeatureKeyEnabled"), query);
|
|
87
87
|
case 5:
|
|
88
88
|
response = _context.sent;
|
|
89
89
|
return _context.abrupt("return", response.isFeatureEnabled.enabled);
|
|
@@ -114,7 +114,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
114
114
|
case 2:
|
|
115
115
|
query = buildReportingLinesQuery(userId);
|
|
116
116
|
_context2.next = 5;
|
|
117
|
-
return
|
|
117
|
+
return directoryGraphqlQuery("".concat(this.options.teamCentralUrl, "?operationName=ReportingLines"), query);
|
|
118
118
|
case 5:
|
|
119
119
|
response = _context2.sent;
|
|
120
120
|
return _context2.abrupt("return", response.reportingLines);
|
|
@@ -14,7 +14,7 @@ import { userRequestAnalytics } from '../util/analytics';
|
|
|
14
14
|
import { getPageTime } from '../util/performance';
|
|
15
15
|
import CachingClient from './CachingClient';
|
|
16
16
|
import { getErrorAttributes } from './errorUtils';
|
|
17
|
-
import {
|
|
17
|
+
import { directoryGraphqlQuery } from './graphqlUtils';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Transform response from GraphQL
|
|
@@ -86,7 +86,7 @@ var UserProfileCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
86
86
|
case 2:
|
|
87
87
|
query = buildUserQuery(cloudId, userId);
|
|
88
88
|
_context.next = 5;
|
|
89
|
-
return
|
|
89
|
+
return directoryGraphqlQuery(this.options.url, query);
|
|
90
90
|
case 5:
|
|
91
91
|
response = _context.sent;
|
|
92
92
|
return _context.abrupt("return", modifyResponse(response));
|
|
@@ -1,19 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
import { AGGError, AGGErrors, DirectoryGraphQLError, DirectoryGraphQLErrors } from '../util/errors';
|
|
2
|
+
var IGNORED_ERROR_REASONS_DIRECTORY = [
|
|
2
3
|
// Error categories from pf-directory
|
|
3
|
-
'NotPermitted', 'Gone'
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
'NotPermitted', 'Gone'];
|
|
5
|
+
var IGNORE_ERROR_TYPES_AGG = ['IdentityUserNotFoundError', 'TEAMS_FORBIDDEN', 'TEAMS_TEAM_DELETED'];
|
|
6
|
+
var IGNORE_ERROR_CLASSIFICATIONS_AGG = ['Gone'];
|
|
6
7
|
function isIgnoredError(error) {
|
|
7
|
-
|
|
8
|
+
if (!error) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (error instanceof DirectoryGraphQLError) {
|
|
12
|
+
return !!error && IGNORED_ERROR_REASONS_DIRECTORY.includes(error.type);
|
|
13
|
+
} else if (error instanceof AGGError) {
|
|
14
|
+
return !!error.errorType && IGNORE_ERROR_TYPES_AGG.includes(error.errorType) || !!error.classification && IGNORE_ERROR_CLASSIFICATIONS_AGG.includes(error.classification);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
8
17
|
}
|
|
9
18
|
export var getErrorAttributes = function getErrorAttributes(error) {
|
|
10
|
-
|
|
19
|
+
if (error instanceof DirectoryGraphQLErrors) {
|
|
20
|
+
return {
|
|
21
|
+
errorMessage: error.message,
|
|
22
|
+
errorCount: error.errors.length,
|
|
23
|
+
errorDetails: error.errors.map(getErrorAttributes),
|
|
24
|
+
isSLOFailure: !error.errors.every(isIgnoredError),
|
|
25
|
+
traceId: error.traceId
|
|
26
|
+
};
|
|
27
|
+
} else if (error instanceof DirectoryGraphQLError) {
|
|
28
|
+
return {
|
|
29
|
+
errorMessage: error.message,
|
|
30
|
+
errorCategory: error.category,
|
|
31
|
+
errorType: error.type,
|
|
32
|
+
errorPath: error.path,
|
|
33
|
+
errorNumber: error.errorNumber,
|
|
34
|
+
isSLOFailure: !isIgnoredError(error)
|
|
35
|
+
};
|
|
36
|
+
} else if (error instanceof AGGErrors) {
|
|
37
|
+
return {
|
|
38
|
+
errorMessage: error.message,
|
|
39
|
+
errorCount: error.errors.length,
|
|
40
|
+
errorDetails: error.errors.map(getErrorAttributes),
|
|
41
|
+
isSLOFailure: !error.errors.every(isIgnoredError),
|
|
42
|
+
traceId: error.traceId
|
|
43
|
+
};
|
|
44
|
+
} else if (error instanceof AGGError) {
|
|
45
|
+
return {
|
|
46
|
+
errorMessage: error.message,
|
|
47
|
+
errorType: error.errorType,
|
|
48
|
+
errorStatusCode: error.statusCode,
|
|
49
|
+
isSLOFailure: !isIgnoredError(error),
|
|
50
|
+
errorCategory: error.classification
|
|
51
|
+
};
|
|
52
|
+
} else if (error instanceof Error) {
|
|
53
|
+
return {
|
|
54
|
+
errorMessage: error.message,
|
|
55
|
+
isSLOFailure: true
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Unknown
|
|
11
60
|
return {
|
|
12
|
-
errorMessage:
|
|
13
|
-
|
|
14
|
-
errorReason: (error === null || error === void 0 ? void 0 : error.reason) || 'default',
|
|
15
|
-
errorSource: error === null || error === void 0 ? void 0 : error.source,
|
|
16
|
-
isSLOFailure: !isIgnoredError(error),
|
|
17
|
-
traceId: (_error$traceId = error === null || error === void 0 ? void 0 : error.traceId) !== null && _error$traceId !== void 0 ? _error$traceId : undefined
|
|
61
|
+
errorMessage: 'Unknown error',
|
|
62
|
+
isSLOFailure: true
|
|
18
63
|
};
|
|
64
|
+
};
|
|
65
|
+
export var handleDirectoryGraphQLErrors = function handleDirectoryGraphQLErrors(errors, traceId) {
|
|
66
|
+
throw new DirectoryGraphQLErrors(errors, traceId);
|
|
67
|
+
};
|
|
68
|
+
export var handleAGGErrors = function handleAGGErrors(errors, traceId) {
|
|
69
|
+
throw new AGGErrors(errors, traceId);
|
|
19
70
|
};
|
|
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
-
import {
|
|
7
|
+
import { AGGQuery } from './graphqlUtils';
|
|
8
8
|
export var extractIdFromAri = function extractIdFromAri(ari) {
|
|
9
9
|
var slashPos = ari.indexOf('/');
|
|
10
10
|
var id = ari.slice(slashPos + 1);
|
|
@@ -51,7 +51,7 @@ export var addHeaders = function addHeaders(headers) {
|
|
|
51
51
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
52
52
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
53
53
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
54
|
-
headers.append('atl-client-version', "19.5.
|
|
54
|
+
headers.append('atl-client-version', "19.5.11");
|
|
55
55
|
return headers;
|
|
56
56
|
};
|
|
57
57
|
export function getTeamFromAGG(_x, _x2, _x3) {
|
|
@@ -59,7 +59,7 @@ export function getTeamFromAGG(_x, _x2, _x3) {
|
|
|
59
59
|
}
|
|
60
60
|
function _getTeamFromAGG() {
|
|
61
61
|
_getTeamFromAGG = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, teamId, siteId) {
|
|
62
|
-
var query, _yield$
|
|
62
|
+
var query, _yield$AGGQuery, Team;
|
|
63
63
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
64
64
|
while (1) switch (_context.prev = _context.next) {
|
|
65
65
|
case 0:
|
|
@@ -68,10 +68,10 @@ function _getTeamFromAGG() {
|
|
|
68
68
|
siteId: siteId
|
|
69
69
|
});
|
|
70
70
|
_context.next = 3;
|
|
71
|
-
return
|
|
71
|
+
return AGGQuery(url, query, addHeaders);
|
|
72
72
|
case 3:
|
|
73
|
-
_yield$
|
|
74
|
-
Team = _yield$
|
|
73
|
+
_yield$AGGQuery = _context.sent;
|
|
74
|
+
Team = _yield$AGGQuery.Team;
|
|
75
75
|
return _context.abrupt("return", convertTeam(Team));
|
|
76
76
|
case 6:
|
|
77
77
|
case "end":
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { HttpError } from '../util/errors';
|
|
4
|
+
import { handleAGGErrors, handleDirectoryGraphQLErrors } from './errorUtils';
|
|
1
5
|
var buildHeaders = function buildHeaders() {
|
|
2
6
|
var headers = new Headers();
|
|
3
7
|
headers.append('Content-Type', 'application/json');
|
|
@@ -12,39 +16,104 @@ var id = function id(headers) {
|
|
|
12
16
|
* @param {Query} query - GraphQL query
|
|
13
17
|
* @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
|
|
14
18
|
*/
|
|
15
|
-
export function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
|
|
19
|
+
export function directoryGraphqlQuery(_x, _x2) {
|
|
20
|
+
return _directoryGraphqlQuery.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} serviceUrl - GraphQL service endpoint
|
|
25
|
+
* @param {Query} query - GraphQL query
|
|
26
|
+
* @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
|
|
27
|
+
*/
|
|
28
|
+
function _directoryGraphqlQuery() {
|
|
29
|
+
_directoryGraphqlQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(serviceUrl, query) {
|
|
30
|
+
var processHeaders,
|
|
31
|
+
_args = arguments;
|
|
32
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
processHeaders = _args.length > 2 && _args[2] !== undefined ? _args[2] : id;
|
|
36
|
+
return _context.abrupt("return", graphQLQuery(serviceUrl, query, processHeaders, handleDirectoryGraphQLErrors));
|
|
37
|
+
case 2:
|
|
38
|
+
case "end":
|
|
39
|
+
return _context.stop();
|
|
40
|
+
}
|
|
41
|
+
}, _callee);
|
|
42
|
+
}));
|
|
43
|
+
return _directoryGraphqlQuery.apply(this, arguments);
|
|
44
|
+
}
|
|
45
|
+
export function AGGQuery(_x3, _x4) {
|
|
46
|
+
return _AGGQuery.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
function _AGGQuery() {
|
|
49
|
+
_AGGQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(serviceUrl, query) {
|
|
50
|
+
var processHeaders,
|
|
51
|
+
_args2 = arguments;
|
|
52
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
53
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
processHeaders = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : id;
|
|
56
|
+
return _context2.abrupt("return", graphQLQuery(serviceUrl, query, processHeaders, handleAGGErrors));
|
|
57
|
+
case 2:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context2.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee2);
|
|
62
|
+
}));
|
|
63
|
+
return _AGGQuery.apply(this, arguments);
|
|
64
|
+
}
|
|
65
|
+
function graphQLQuery(_x5, _x6) {
|
|
66
|
+
return _graphQLQuery.apply(this, arguments);
|
|
67
|
+
}
|
|
68
|
+
function _graphQLQuery() {
|
|
69
|
+
_graphQLQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(serviceUrl, query) {
|
|
70
|
+
var _response$headers;
|
|
71
|
+
var processHeaders,
|
|
72
|
+
handleErrors,
|
|
73
|
+
headers,
|
|
74
|
+
response,
|
|
75
|
+
traceIdFromHeaders,
|
|
76
|
+
json,
|
|
77
|
+
_json$extensions$gate,
|
|
78
|
+
_json$extensions,
|
|
79
|
+
_json$extensions$gate2,
|
|
80
|
+
_args3 = arguments;
|
|
81
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
82
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
processHeaders = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : id;
|
|
85
|
+
handleErrors = _args3.length > 3 ? _args3[3] : undefined;
|
|
86
|
+
headers = processHeaders(buildHeaders());
|
|
87
|
+
_context3.next = 5;
|
|
88
|
+
return fetch(new Request(serviceUrl, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
credentials: 'include',
|
|
91
|
+
mode: 'cors',
|
|
92
|
+
headers: headers,
|
|
93
|
+
body: JSON.stringify(query)
|
|
94
|
+
}));
|
|
95
|
+
case 5:
|
|
96
|
+
response = _context3.sent;
|
|
97
|
+
traceIdFromHeaders = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('atl-traceid');
|
|
98
|
+
if (response.ok) {
|
|
99
|
+
_context3.next = 9;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
throw new HttpError(response.status, response.statusText, traceIdFromHeaders);
|
|
103
|
+
case 9:
|
|
104
|
+
_context3.next = 11;
|
|
105
|
+
return response.json();
|
|
106
|
+
case 11:
|
|
107
|
+
json = _context3.sent;
|
|
108
|
+
if (json.errors) {
|
|
109
|
+
handleErrors(json.errors, (_json$extensions$gate = (_json$extensions = json.extensions) === null || _json$extensions === void 0 ? void 0 : (_json$extensions$gate2 = _json$extensions.gateway) === null || _json$extensions$gate2 === void 0 ? void 0 : _json$extensions$gate2.request_id) !== null && _json$extensions$gate !== void 0 ? _json$extensions$gate : traceIdFromHeaders);
|
|
110
|
+
}
|
|
111
|
+
return _context3.abrupt("return", json.data);
|
|
112
|
+
case 14:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context3.stop();
|
|
115
|
+
}
|
|
116
|
+
}, _callee3);
|
|
117
|
+
}));
|
|
118
|
+
return _graphQLQuery.apply(this, arguments);
|
|
50
119
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8
|
+
import { handleAGGErrors } from '../client/errorUtils';
|
|
8
9
|
import TeamProfileCardClient from '../client/TeamProfileCardClient';
|
|
9
10
|
export default function getMockTeamClient(data) {
|
|
10
11
|
return /*#__PURE__*/function (_TeamProfileCardClien) {
|
|
@@ -27,7 +28,11 @@ export default function getMockTeamClient(data) {
|
|
|
27
28
|
};
|
|
28
29
|
if (!data.timeout) {
|
|
29
30
|
if (data.error && Math.random() < data.errorRate) {
|
|
30
|
-
|
|
31
|
+
try {
|
|
32
|
+
handleAGGErrors(data.error, data.traceId);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return Promise.reject(e);
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
return Promise.resolve(data.team);
|
|
33
38
|
}
|
|
@@ -7,4 +7,4 @@ export var ReportingLinesSection = styled.div(_templateObject || (_templateObjec
|
|
|
7
7
|
export var ReportingLinesHeading = styled.h5(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", "px;\n font-weight: 600;\n margin-bottom: ", ";\n"])), appLabelTextColor, gridSize() * 1.5, "var(--ds-space-100, 8px)");
|
|
8
8
|
export var ManagerSection = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n margin: ", " ", ";\n"])), "var(--ds-space-050, 4px)", "var(--ds-space-050, 4px)");
|
|
9
9
|
export var ManagerName = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: ", "px;\n margin-left: ", ";\n"])), gridSize() * 1.5, "var(--ds-space-100, 8px)");
|
|
10
|
-
export var OffsetWrapper = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-top: ", ";\n // Offset left margin so the avatar aligns with the heading\n margin-left:
|
|
10
|
+
export var OffsetWrapper = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-top: ", ";\n // Offset left margin so the avatar aligns with the heading\n margin-left: ", ";\n"])), "var(--ds-space-050, 4px)", "var(--ds-space-negative-050, -4px)");
|
|
@@ -16,10 +16,10 @@ export var CardHeader = styled.div(_templateObject4 || (_templateObject4 = _tagg
|
|
|
16
16
|
export var CardContent = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n padding: ", ";\n min-height: ", "px;\n"])), "var(--ds-space-300, 24px)", gridSize() * 13);
|
|
17
17
|
export var TeamName = styled.h6(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ", ";\n text-transform: none;\n overflow: hidden;\n max-height: 48px;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n"])), h600);
|
|
18
18
|
export var MemberCount = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n color: ", ";\n margin-top: ", ";\n"])), "var(--ds-text-subtlest, ".concat(N200, ")"), "var(--ds-space-050, 4px)");
|
|
19
|
-
export var AvatarSection = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n margin-top: ", ";\n margin-left:
|
|
19
|
+
export var AvatarSection = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n margin-top: ", ";\n margin-left: ", ";\n"])), "var(--ds-space-200, 16px)", "var(--ds-space-negative-025, -2px)");
|
|
20
20
|
export var DescriptionWrapper = styled.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n margin-top: ", ";\n align-items: center;\n display: flex;\n"])), "var(--ds-space-200, 16px)");
|
|
21
21
|
export var Description = styled.span(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n overflow: hidden;\n max-height: 60px;\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n"])));
|
|
22
|
-
export var ActionButtons = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n width: calc(100% + 8px);\n display: flex;\n justify-content: space-between;\n margin: ", "
|
|
22
|
+
export var ActionButtons = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n width: calc(100% + 8px);\n display: flex;\n justify-content: space-between;\n margin: ", " ", "\n 0 ", ";\n background-color: ", ";\n"])), "var(--ds-space-300, 24px)", "var(--ds-space-negative-300, -24px)", "var(--ds-space-negative-100, -8px)", "var(--ds-surface-overlay, hsla(0, 100%, 100%, 0.2))");
|
|
23
23
|
export var WrappedButton = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n flex-basis: 0;\n flex-grow: 1;\n margin-left: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
24
24
|
export var MoreButton = styled.div(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n margin-left: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
25
25
|
export var LoadingWrapper = styled.div(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n text-align: center;\n margin-top: ", ";\n"])), "var(--ds-space-500, 40px)");
|
|
@@ -38,7 +38,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
38
38
|
actionSubjectId: actionSubjectId,
|
|
39
39
|
attributes: _objectSpread(_objectSpread({
|
|
40
40
|
packageName: "@atlaskit/profilecard",
|
|
41
|
-
packageVersion: "19.5.
|
|
41
|
+
packageVersion: "19.5.11"
|
|
42
42
|
}, attributes), {}, {
|
|
43
43
|
firedAt: Math.round(getPageTime())
|
|
44
44
|
})
|