@atlaskit/profilecard 16.2.0 → 16.3.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/client/CachingClient.js +2 -2
  3. package/dist/cjs/client/ProfileCardClient.js +2 -2
  4. package/dist/cjs/client/TeamProfileCardClient.js +18 -8
  5. package/dist/cjs/client/UserProfileCardClient.js +2 -2
  6. package/dist/cjs/client/getTeamFromAGG.js +106 -0
  7. package/dist/cjs/client/graphqlUtils.js +8 -1
  8. package/dist/cjs/components/Error/ErrorIllustration.js +1 -1
  9. package/dist/cjs/components/Team/TeamProfileCard.js +2 -2
  10. package/dist/cjs/components/User/ProfileCard.js +4 -2
  11. package/dist/cjs/components/User/ProfileCardResourced.js +2 -2
  12. package/dist/cjs/components/User/ProfileCardTrigger.js +5 -3
  13. package/dist/cjs/mocks/mock-profile-client.js +3 -3
  14. package/dist/cjs/mocks/mock-team-client.js +5 -0
  15. package/dist/cjs/mocks/simple-mock-clients.js +2 -2
  16. package/dist/cjs/styled/Error.js +1 -1
  17. package/dist/cjs/styled/TeamCard.js +3 -3
  18. package/dist/cjs/styled/constants.js +24 -24
  19. package/dist/cjs/util/analytics.js +3 -3
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/client/TeamProfileCardClient.js +16 -8
  22. package/dist/es2019/client/getTeamFromAGG.js +66 -0
  23. package/dist/es2019/client/graphqlUtils.js +6 -2
  24. package/dist/es2019/components/Error/ErrorIllustration.js +1 -1
  25. package/dist/es2019/components/User/ProfileCard.js +1 -1
  26. package/dist/es2019/mocks/mock-team-client.js +4 -0
  27. package/dist/es2019/styled/Error.js +1 -1
  28. package/dist/es2019/styled/TeamCard.js +3 -3
  29. package/dist/es2019/styled/constants.js +24 -24
  30. package/dist/es2019/util/analytics.js +1 -1
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/client/CachingClient.js +2 -2
  33. package/dist/esm/client/ProfileCardClient.js +2 -2
  34. package/dist/esm/client/TeamProfileCardClient.js +17 -8
  35. package/dist/esm/client/UserProfileCardClient.js +2 -2
  36. package/dist/esm/client/getTeamFromAGG.js +77 -0
  37. package/dist/esm/client/graphqlUtils.js +8 -1
  38. package/dist/esm/components/Error/ErrorIllustration.js +1 -1
  39. package/dist/esm/components/Team/TeamProfileCard.js +2 -2
  40. package/dist/esm/components/User/ProfileCard.js +3 -2
  41. package/dist/esm/components/User/ProfileCardResourced.js +2 -2
  42. package/dist/esm/components/User/ProfileCardTrigger.js +4 -3
  43. package/dist/esm/mocks/mock-profile-client.js +3 -3
  44. package/dist/esm/mocks/mock-team-client.js +5 -0
  45. package/dist/esm/mocks/simple-mock-clients.js +2 -2
  46. package/dist/esm/styled/Error.js +1 -1
  47. package/dist/esm/styled/TeamCard.js +3 -3
  48. package/dist/esm/styled/constants.js +24 -24
  49. package/dist/esm/util/analytics.js +3 -3
  50. package/dist/esm/version.json +1 -1
  51. package/dist/types/client/TeamProfileCardClient.d.ts +1 -0
  52. package/dist/types/client/getTeamFromAGG.d.ts +28 -0
  53. package/dist/types/client/graphqlUtils.d.ts +3 -1
  54. package/dist/types/styled/constants.d.ts +12 -12
  55. package/dist/types/types.d.ts +1 -0
  56. package/dist/types/util/analytics.d.ts +1 -1
  57. package/docs/1-profilecard-trigger.tsx +2 -1
  58. package/docs/2-team-profilecard.tsx +2 -1
  59. package/docs/3-profile-client.tsx +9 -5
  60. package/package.json +4 -4
@@ -1,6 +1,7 @@
1
1
  import { teamRequestAnalytics } from '../util/analytics';
2
2
  import { getPageTime } from '../util/performance';
3
3
  import CachingClient from './CachingClient';
4
+ import { getTeamFromAGG } from './getTeamFromAGG';
4
5
  import { graphqlQuery } from './graphqlUtils';
5
6
  const QUERY = `query Team($teamId: String!, $organizationId: String) {
6
7
  Team: Team(teamId: $teamId, organizationId: $organizationId) {
@@ -18,11 +19,6 @@ const QUERY = `query Team($teamId: String!, $organizationId: String) {
18
19
  },
19
20
  }
20
21
  }`;
21
- /**
22
- * @param {string} userId
23
- * @param {string} cloudId
24
- * @return {string} GraphQL Query String
25
- */
26
22
 
27
23
  const buildTeamQuery = (teamId, orgId) => ({
28
24
  query: QUERY,
@@ -38,6 +34,14 @@ export default class TeamProfileCardClient extends CachingClient {
38
34
  this.options = options;
39
35
  }
40
36
 
37
+ makeRequestViaGateway(teamId, _orgId) {
38
+ if (!this.options.gatewayGraphqlUrl) {
39
+ throw new Error('Trying to fetch via gateway with no specified config.gatewayGraphqlUrl');
40
+ }
41
+
42
+ return getTeamFromAGG(this.options.gatewayGraphqlUrl, teamId);
43
+ }
44
+
41
45
  makeRequest(teamId, orgId) {
42
46
  if (!this.options.url) {
43
47
  throw new Error('config.url is a required parameter for fetching teams');
@@ -65,14 +69,17 @@ export default class TeamProfileCardClient extends CachingClient {
65
69
  analytics(teamRequestAnalytics('triggered'));
66
70
  }
67
71
 
68
- this.makeRequest(teamId, orgId).then(data => {
72
+ const shouldUseGateway = !!this.options.gatewayGraphqlUrl;
73
+ const promise = shouldUseGateway ? this.makeRequestViaGateway(teamId, orgId) : this.makeRequest(teamId, orgId);
74
+ promise.then(data => {
69
75
  if (this.cache) {
70
76
  this.setCachedProfile(teamId, data);
71
77
  }
72
78
 
73
79
  if (analytics) {
74
80
  analytics(teamRequestAnalytics('succeeded', {
75
- duration: getPageTime() - startTime
81
+ duration: getPageTime() - startTime,
82
+ gateway: shouldUseGateway
76
83
  }));
77
84
  }
78
85
 
@@ -82,7 +89,8 @@ export default class TeamProfileCardClient extends CachingClient {
82
89
  analytics(teamRequestAnalytics('failed', {
83
90
  duration: getPageTime() - startTime,
84
91
  errorStatus: error.code,
85
- errorReason: error.reason
92
+ errorReason: error.reason,
93
+ gateway: shouldUseGateway
86
94
  }));
87
95
  }
88
96
 
@@ -0,0 +1,66 @@
1
+ import { graphqlQuery } from './graphqlUtils';
2
+ export const extractIdFromAri = ari => {
3
+ const slashPos = ari.indexOf('/');
4
+ const id = ari.slice(slashPos + 1);
5
+ return id;
6
+ };
7
+ export const idToAri = teamId => {
8
+ return `ari:cloud:teams::team/${teamId}`;
9
+ };
10
+ export const convertTeam = result => {
11
+ var _team$members;
12
+
13
+ const {
14
+ team
15
+ } = result;
16
+ return { ...team,
17
+ id: extractIdFromAri(team.id),
18
+ members: (_team$members = team.members) === null || _team$members === void 0 ? void 0 : _team$members.nodes.map(({
19
+ member
20
+ }) => ({
21
+ id: member.accountId,
22
+ fullName: member.name,
23
+ avatarUrl: member.picture
24
+ }))
25
+ };
26
+ };
27
+ const GATEWAY_QUERY = `query TeamCard($teamId: ID!) {
28
+ Team: team {
29
+ team (id: $teamId) {
30
+ id
31
+ displayName
32
+ description
33
+ smallHeaderImageUrl
34
+ largeHeaderImageUrl
35
+ smallAvatarImageUrl
36
+ largeAvatarImageUrl
37
+ members {
38
+ nodes {
39
+ member {
40
+ accountId
41
+ name
42
+ picture
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }`;
49
+ export const buildGatewayQuery = teamId => ({
50
+ query: GATEWAY_QUERY,
51
+ variables: {
52
+ teamId: idToAri(teamId)
53
+ }
54
+ });
55
+ export const addExperimentalHeaders = headers => {
56
+ headers.append('X-ExperimentalApi', 'teams-beta');
57
+ headers.append('X-ExperimentalApi', 'team-members-beta');
58
+ return headers;
59
+ };
60
+ export async function getTeamFromAGG(url, teamId) {
61
+ const query = buildGatewayQuery(teamId);
62
+ const {
63
+ Team
64
+ } = await graphqlQuery(url, query, addExperimentalHeaders);
65
+ return convertTeam(Team);
66
+ }
@@ -4,12 +4,16 @@ const buildHeaders = () => {
4
4
  return headers;
5
5
  };
6
6
 
7
+ const id = headers => headers;
7
8
  /**
8
9
  * @param {string} serviceUrl - GraphQL service endpoint
9
10
  * @param {Query} query - GraphQL query
11
+ * @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
10
12
  */
11
- export function graphqlQuery(serviceUrl, query) {
12
- const headers = buildHeaders();
13
+
14
+
15
+ export function graphqlQuery(serviceUrl, query, processHeaders = id) {
16
+ const headers = processHeaders(buildHeaders());
13
17
  return fetch(new Request(serviceUrl, {
14
18
  method: 'POST',
15
19
  credentials: 'include',
@@ -12,7 +12,7 @@ export const ErrorIllustration = () => {
12
12
  clipPath: "url(#clip0)"
13
13
  }, /*#__PURE__*/React.createElement("path", {
14
14
  d: "M0.649902 0H163.93V212H0.649902V0Z",
15
- fill: token('color.background.overlay', 'white'),
15
+ fill: token('elevation.surface.overlay', 'white'),
16
16
  fillOpacity: "0.01"
17
17
  }), /*#__PURE__*/React.createElement("path", {
18
18
  d: "M95.4299 74.1603L161.87 189.24C167.71 199.36 160.41 212 148.73 212H15.8499C4.16994 212 -3.13006 199.35 2.70994 189.24L69.1499 74.1603C74.9899 64.0403 89.5899 64.0403 95.4299 74.1603ZM87.8699 157.71L90.7499 113.36C91.0899 108.07 86.8899 103.58 81.5899 103.58C76.2799 103.58 72.0799 108.06 72.4299 113.36L75.3099 157.71C75.5299 161.02 78.2699 163.6 81.5899 163.6C84.8999 163.6 87.6499 161.02 87.8699 157.71ZM72.0299 181.25C72.0299 186.91 76.7899 191.35 82.4199 190.83C87.2699 190.38 91.1499 186.33 91.2499 181.46C91.3599 176.01 86.9399 171.52 81.5199 171.52C76.2899 171.51 72.0299 175.89 72.0299 181.25Z",
@@ -247,7 +247,7 @@ export default class Profilecard extends React.PureComponent {
247
247
  }, /*#__PURE__*/React.createElement(ProfileImage, null, /*#__PURE__*/React.createElement(Avatar, {
248
248
  size: "xlarge",
249
249
  src: this.props.status !== 'closed' ? this.props.avatarUrl : undefined,
250
- borderColor: token('color.background.overlay', N0)
250
+ borderColor: token('elevation.surface.overlay', N0)
251
251
  })), /*#__PURE__*/React.createElement(CardContent, null, this.renderCardDetails(), actions ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsFlexSpacer, null), actions) : null));
252
252
  }
253
253
 
@@ -25,5 +25,9 @@ export default function getMockTeamClient(data) {
25
25
  });
26
26
  }
27
27
 
28
+ makeRequestViaGateway(teamId) {
29
+ return this.makeRequest(teamId);
30
+ }
31
+
28
32
  };
29
33
  }
@@ -21,6 +21,6 @@ export const TeamErrorTitle = styled.p`
21
21
  ${h400};
22
22
  `;
23
23
  export const TeamErrorText = styled.p`
24
- color: ${token('color.text.lowEmphasis', N200)};
24
+ color: ${token('color.text.subtlest', N200)};
25
25
  margin-top: ${gridSize() * 1}px;
26
26
  `;
@@ -16,7 +16,7 @@ export const CardWrapper = styled.div`
16
16
  -moz-osx-font-smoothing: grayscale;
17
17
  `;
18
18
  const loadingImage = css`
19
- background-color: ${token('color.background.subtleNeutral.resting', N20)};
19
+ background-color: ${token('color.background.neutral', N20)};
20
20
  `;
21
21
  const defaultImage = css`
22
22
  background-color: ${teamHeaderBgColor};
@@ -58,7 +58,7 @@ export const TeamName = styled.h6`
58
58
  -webkit-box-orient: vertical;
59
59
  `;
60
60
  export const MemberCount = styled.div`
61
- color: ${token('color.text.lowEmphasis', N200)};
61
+ color: ${token('color.text.subtlest', N200)};
62
62
  margin-top: ${gridSize() * 0.5}px;
63
63
  `;
64
64
  export const AvatarSection = styled.div`
@@ -82,7 +82,7 @@ export const ActionButtons = styled.div`
82
82
  display: flex;
83
83
  justify-content: space-between;
84
84
  margin: ${gridSize() * 3}px -${gridSize() * 3}px 0 -${gridSize()}px;
85
- background-color: ${token('color.background.overlay', 'hsla(0, 100%, 100%, 0.2)')};
85
+ background-color: ${token('elevation.surface.overlay', 'hsla(0, 100%, 100%, 0.2)')};
86
86
  `;
87
87
  export const WrappedButton = styled.div`
88
88
  flex-basis: 0;
@@ -2,58 +2,58 @@ import * as colors from '@atlaskit/theme/colors';
2
2
  import { themed } from '@atlaskit/theme/components';
3
3
  import { token } from '@atlaskit/tokens';
4
4
  export const bgColor = themed({
5
- light: token('color.background.overlay', colors.N0),
6
- dark: token('color.background.overlay', colors.DN50)
5
+ light: token('elevation.surface.overlay', colors.N0),
6
+ dark: token('elevation.surface.overlay', colors.DN50)
7
7
  });
8
8
  export const headerBgColor = themed({
9
- light: token('color.background.boldBrand.resting', colors.B500),
10
- dark: token('color.background.boldBrand.resting', colors.B100)
9
+ light: token('color.background.brand.bold', colors.B500),
10
+ dark: token('color.background.brand.bold', colors.B100)
11
11
  });
12
12
  export const teamHeaderBgColor = themed({
13
- light: token('color.background.subtleNeutral.resting', colors.N50),
14
- dark: token('color.background.subtleNeutral.resting', colors.N50)
13
+ light: token('color.background.neutral', colors.N50),
14
+ dark: token('color.background.neutral', colors.N50)
15
15
  });
16
16
  export const headerBgColorDisabledUser = themed({
17
17
  light: token('color.background.disabled', colors.N30),
18
18
  dark: token('color.background.disabled', colors.B100)
19
19
  });
20
20
  export const headerTextColor = themed({
21
- light: token('color.text.onBold', colors.N0),
22
- dark: token('color.text.onBold', colors.N0)
21
+ light: token('color.text.inverse', colors.N0),
22
+ dark: token('color.text.inverse', colors.N0)
23
23
  });
24
24
  export const headerTextColorInactive = themed({
25
- light: token('color.text.highEmphasis', colors.N800),
26
- dark: token('color.text.highEmphasis', colors.N0)
25
+ light: token('color.text', colors.N800),
26
+ dark: token('color.text', colors.N0)
27
27
  });
28
28
  export const appLabelBgColor = themed({
29
- light: token('color.background.subtleNeutral.resting', colors.N20),
30
- dark: token('color.background.subtleNeutral.resting', colors.N20)
29
+ light: token('color.background.neutral', colors.N20),
30
+ dark: token('color.background.neutral', colors.N20)
31
31
  });
32
32
  export const appLabelTextColor = themed({
33
- light: token('color.text.highEmphasis', colors.N500),
34
- dark: token('color.text.highEmphasis', colors.N500)
33
+ light: token('color.text', colors.N500),
34
+ dark: token('color.text', colors.N500)
35
35
  });
36
36
  export const labelTextColor = themed({
37
- light: token('color.text.highEmphasis', colors.N800),
38
- dark: token('color.text.highEmphasis', colors.DN900)
37
+ light: token('color.text', colors.N800),
38
+ dark: token('color.text', colors.DN900)
39
39
  });
40
40
  export const labelIconColor = themed({
41
- light: token('color.text.lowEmphasis', colors.N60),
42
- dark: token('color.text.lowEmphasis', colors.DN100)
41
+ light: token('color.text.subtlest', colors.N60),
42
+ dark: token('color.text.subtlest', colors.DN100)
43
43
  });
44
44
  export const errorIconColor = themed({
45
45
  light: token('color.text.disabled', colors.N90),
46
46
  dark: token('color.text.disabled', colors.DN90)
47
47
  });
48
48
  export const errorTitleColor = themed({
49
- light: token('color.text.highEmphasis', colors.N800),
50
- dark: token('color.text.highEmphasis', colors.DN800)
49
+ light: token('color.text', colors.N800),
50
+ dark: token('color.text', colors.DN800)
51
51
  });
52
52
  export const errorTextColor = themed({
53
- light: token('color.text.lowEmphasis', colors.N90),
54
- dark: token('color.text.lowEmphasis', colors.DN90)
53
+ light: token('color.text.subtlest', colors.N90),
54
+ dark: token('color.text.subtlest', colors.DN90)
55
55
  });
56
56
  export const boxShadow = themed({
57
- light: token('shadow.overlay', `0 4px 8px -2px ${colors.N50A}, 0 0 1px ${colors.N60A}`),
58
- dark: token('shadow.overlay', `0 4px 8px -2px ${colors.DN50A}, 0 0 1px ${colors.DN60A}`)
57
+ light: token('elevation.shadow.overlay', `0 4px 8px -2px ${colors.N50A}, 0 0 1px ${colors.N60A}`),
58
+ dark: token('elevation.shadow.overlay', `0 4px 8px -2px ${colors.DN50A}, 0 0 1px ${colors.DN60A}`)
59
59
  });
@@ -11,7 +11,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
11
11
  actionSubjectId,
12
12
  attributes: {
13
13
  packageName: "@atlaskit/profilecard",
14
- packageVersion: "16.2.0",
14
+ packageVersion: "16.3.0",
15
15
  ...attributes,
16
16
  firedAt: getPageTime()
17
17
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.2.0"
3
+ "version": "16.3.0"
4
4
  }
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  import { LRUCache } from 'lru-fast';
10
10
 
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  import TeamCentralCardClient from './TeamCentralCardClient';
10
10
  import TeamProfileCardClient from './TeamProfileCardClient';
@@ -11,13 +11,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
11
11
  import { teamRequestAnalytics } from '../util/analytics';
12
12
  import { getPageTime } from '../util/performance';
13
13
  import CachingClient from './CachingClient';
14
+ import { getTeamFromAGG } from './getTeamFromAGG';
14
15
  import { graphqlQuery } from './graphqlUtils';
15
16
  var QUERY = "query Team($teamId: String!, $organizationId: String) {\n Team: Team(teamId: $teamId, organizationId: $organizationId) {\n id,\n description,\n displayName,\n largeHeaderImageUrl,\n smallHeaderImageUrl,\n largeAvatarImageUrl,\n smallAvatarImageUrl,\n members {\n id,\n fullName,\n avatarUrl,\n },\n }\n}";
16
- /**
17
- * @param {string} userId
18
- * @param {string} cloudId
19
- * @return {string} GraphQL Query String
20
- */
21
17
 
22
18
  var buildTeamQuery = function buildTeamQuery(teamId, orgId) {
23
19
  return {
@@ -45,6 +41,15 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
45
41
  }
46
42
 
47
43
  _createClass(TeamProfileCardClient, [{
44
+ key: "makeRequestViaGateway",
45
+ value: function makeRequestViaGateway(teamId, _orgId) {
46
+ if (!this.options.gatewayGraphqlUrl) {
47
+ throw new Error('Trying to fetch via gateway with no specified config.gatewayGraphqlUrl');
48
+ }
49
+
50
+ return getTeamFromAGG(this.options.gatewayGraphqlUrl, teamId);
51
+ }
52
+ }, {
48
53
  key: "makeRequest",
49
54
  value: function makeRequest(teamId, orgId) {
50
55
  if (!this.options.url) {
@@ -78,14 +83,17 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
78
83
  analytics(teamRequestAnalytics('triggered'));
79
84
  }
80
85
 
81
- _this2.makeRequest(teamId, orgId).then(function (data) {
86
+ var shouldUseGateway = !!_this2.options.gatewayGraphqlUrl;
87
+ var promise = shouldUseGateway ? _this2.makeRequestViaGateway(teamId, orgId) : _this2.makeRequest(teamId, orgId);
88
+ promise.then(function (data) {
82
89
  if (_this2.cache) {
83
90
  _this2.setCachedProfile(teamId, data);
84
91
  }
85
92
 
86
93
  if (analytics) {
87
94
  analytics(teamRequestAnalytics('succeeded', {
88
- duration: getPageTime() - startTime
95
+ duration: getPageTime() - startTime,
96
+ gateway: shouldUseGateway
89
97
  }));
90
98
  }
91
99
 
@@ -95,7 +103,8 @@ var TeamProfileCardClient = /*#__PURE__*/function (_CachingClient) {
95
103
  analytics(teamRequestAnalytics('failed', {
96
104
  duration: getPageTime() - startTime,
97
105
  errorStatus: error.code,
98
- errorReason: error.reason
106
+ errorReason: error.reason,
107
+ gateway: shouldUseGateway
99
108
  }));
100
109
  }
101
110
 
@@ -11,9 +11,9 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
 
12
12
  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; } }
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
15
 
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
17
 
18
18
  import CachingClient from './CachingClient';
19
19
  import { graphqlQuery } from './graphqlUtils';
@@ -0,0 +1,77 @@
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+
9
+ import { graphqlQuery } from './graphqlUtils';
10
+ export var extractIdFromAri = function extractIdFromAri(ari) {
11
+ var slashPos = ari.indexOf('/');
12
+ var id = ari.slice(slashPos + 1);
13
+ return id;
14
+ };
15
+ export var idToAri = function idToAri(teamId) {
16
+ return "ari:cloud:teams::team/".concat(teamId);
17
+ };
18
+ export var convertTeam = function convertTeam(result) {
19
+ var _team$members;
20
+
21
+ var team = result.team;
22
+ return _objectSpread(_objectSpread({}, team), {}, {
23
+ id: extractIdFromAri(team.id),
24
+ members: (_team$members = team.members) === null || _team$members === void 0 ? void 0 : _team$members.nodes.map(function (_ref) {
25
+ var member = _ref.member;
26
+ return {
27
+ id: member.accountId,
28
+ fullName: member.name,
29
+ avatarUrl: member.picture
30
+ };
31
+ })
32
+ });
33
+ };
34
+ var GATEWAY_QUERY = "query TeamCard($teamId: ID!) {\n Team: team {\n team (id: $teamId) {\n id\n displayName\n description\n smallHeaderImageUrl\n largeHeaderImageUrl\n smallAvatarImageUrl\n largeAvatarImageUrl\n members {\n nodes {\n member {\n accountId\n name\n picture\n }\n }\n }\n }\n }\n}";
35
+ export var buildGatewayQuery = function buildGatewayQuery(teamId) {
36
+ return {
37
+ query: GATEWAY_QUERY,
38
+ variables: {
39
+ teamId: idToAri(teamId)
40
+ }
41
+ };
42
+ };
43
+ export var addExperimentalHeaders = function addExperimentalHeaders(headers) {
44
+ headers.append('X-ExperimentalApi', 'teams-beta');
45
+ headers.append('X-ExperimentalApi', 'team-members-beta');
46
+ return headers;
47
+ };
48
+ export function getTeamFromAGG(_x, _x2) {
49
+ return _getTeamFromAGG.apply(this, arguments);
50
+ }
51
+
52
+ function _getTeamFromAGG() {
53
+ _getTeamFromAGG = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, teamId) {
54
+ var query, _yield$graphqlQuery, Team;
55
+
56
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ while (1) {
58
+ switch (_context.prev = _context.next) {
59
+ case 0:
60
+ query = buildGatewayQuery(teamId);
61
+ _context.next = 3;
62
+ return graphqlQuery(url, query, addExperimentalHeaders);
63
+
64
+ case 3:
65
+ _yield$graphqlQuery = _context.sent;
66
+ Team = _yield$graphqlQuery.Team;
67
+ return _context.abrupt("return", convertTeam(Team));
68
+
69
+ case 6:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }
74
+ }, _callee);
75
+ }));
76
+ return _getTeamFromAGG.apply(this, arguments);
77
+ }
@@ -4,12 +4,19 @@ var buildHeaders = function buildHeaders() {
4
4
  return headers;
5
5
  };
6
6
 
7
+ var id = function id(headers) {
8
+ return headers;
9
+ };
7
10
  /**
8
11
  * @param {string} serviceUrl - GraphQL service endpoint
9
12
  * @param {Query} query - GraphQL query
13
+ * @param {HeaderProcessor} processHeaders - a function to add extra headers to the request
10
14
  */
15
+
16
+
11
17
  export function graphqlQuery(serviceUrl, query) {
12
- var headers = buildHeaders();
18
+ var processHeaders = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : id;
19
+ var headers = processHeaders(buildHeaders());
13
20
  return fetch(new Request(serviceUrl, {
14
21
  method: 'POST',
15
22
  credentials: 'include',
@@ -12,7 +12,7 @@ export var ErrorIllustration = function ErrorIllustration() {
12
12
  clipPath: "url(#clip0)"
13
13
  }, /*#__PURE__*/React.createElement("path", {
14
14
  d: "M0.649902 0H163.93V212H0.649902V0Z",
15
- fill: token('color.background.overlay', 'white'),
15
+ fill: token('elevation.surface.overlay', 'white'),
16
16
  fillOpacity: "0.01"
17
17
  }), /*#__PURE__*/React.createElement("path", {
18
18
  d: "M95.4299 74.1603L161.87 189.24C167.71 199.36 160.41 212 148.73 212H15.8499C4.16994 212 -3.13006 199.35 2.70994 189.24L69.1499 74.1603C74.9899 64.0403 89.5899 64.0403 95.4299 74.1603ZM87.8699 157.71L90.7499 113.36C91.0899 108.07 86.8899 103.58 81.5899 103.58C76.2799 103.58 72.0799 108.06 72.4299 113.36L75.3099 157.71C75.5299 161.02 78.2699 163.6 81.5899 163.6C84.8999 163.6 87.6499 161.02 87.8699 157.71ZM72.0299 181.25C72.0299 186.91 76.7899 191.35 82.4199 190.83C87.2699 190.38 91.1499 186.33 91.2499 181.46C91.3599 176.01 86.9399 171.52 81.5199 171.52C76.2899 171.51 72.0299 175.89 72.0299 181.25Z",
@@ -3,9 +3,9 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _extends from "@babel/runtime/helpers/extends";
5
5
 
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
7
 
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
9
 
10
10
  import React, { useCallback, useEffect, useRef, useState } from 'react';
11
11
  import { FormattedMessage } from 'react-intl-next';
@@ -7,6 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+ var _excluded = ["text"];
10
11
 
11
12
  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); }; }
12
13
 
@@ -235,7 +236,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
235
236
  value: function renderCustomLozenges(lozenges) {
236
237
  return lozenges.length > 0 ? /*#__PURE__*/React.createElement(CustomLozengeContainer, null, lozenges.map(function (_ref, index) {
237
238
  var text = _ref.text,
238
- otherProps = _objectWithoutProperties(_ref, ["text"]);
239
+ otherProps = _objectWithoutProperties(_ref, _excluded);
239
240
 
240
241
  return /*#__PURE__*/React.createElement(Lozenge, _extends({}, otherProps, {
241
242
  key: index
@@ -297,7 +298,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
297
298
  }, /*#__PURE__*/React.createElement(ProfileImage, null, /*#__PURE__*/React.createElement(Avatar, {
298
299
  size: "xlarge",
299
300
  src: this.props.status !== 'closed' ? this.props.avatarUrl : undefined,
300
- borderColor: token('color.background.overlay', N0)
301
+ borderColor: token('elevation.surface.overlay', N0)
301
302
  })), /*#__PURE__*/React.createElement(CardContent, null, this.renderCardDetails(), actions ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsFlexSpacer, null), actions) : null));
302
303
  }
303
304
 
@@ -7,9 +7,9 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
 
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
11
 
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
13
 
14
14
  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); }; }
15
15
 
@@ -7,10 +7,11 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+ var _excluded = ["ref"];
10
11
 
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
13
 
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
15
 
15
16
  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); }; }
16
17
 
@@ -231,7 +232,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
231
232
  content: this.renderCard,
232
233
  trigger: function trigger(triggerProps) {
233
234
  var ref = triggerProps.ref,
234
- innerProps = _objectWithoutProperties(triggerProps, ["ref"]);
235
+ innerProps = _objectWithoutProperties(triggerProps, _excluded);
235
236
 
236
237
  return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, _this2.containerListeners, {
237
238
  ref: ref,