@atlaskit/profilecard 16.4.6 → 16.5.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 +18 -0
- package/dist/cjs/client/ProfileCardClient.js +16 -0
- package/dist/cjs/client/TeamCentralCardClient.js +86 -5
- package/dist/cjs/components/User/ProfileCard.js +35 -6
- package/dist/cjs/components/User/ProfileCardTrigger.js +27 -10
- package/dist/cjs/messages.js +5 -0
- package/dist/cjs/styled/Card.js +1 -1
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/ProfileCardClient.js +14 -0
- package/dist/es2019/client/TeamCentralCardClient.js +52 -0
- package/dist/es2019/components/User/ProfileCard.js +28 -1
- package/dist/es2019/components/User/ProfileCardTrigger.js +18 -6
- package/dist/es2019/messages.js +5 -0
- package/dist/es2019/styled/Card.js +2 -1
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/ProfileCardClient.js +16 -0
- package/dist/esm/client/TeamCentralCardClient.js +86 -5
- package/dist/esm/components/User/ProfileCard.js +36 -6
- package/dist/esm/components/User/ProfileCardTrigger.js +26 -10
- package/dist/esm/messages.js +5 -0
- package/dist/esm/styled/Card.js +1 -1
- package/dist/esm/util/analytics.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/client/ProfileCardClient.d.ts +2 -0
- package/dist/types/client/TeamCentralCardClient.d.ts +3 -0
- package/dist/types/components/User/ProfileCard.d.ts +2 -0
- package/dist/types/components/User/ProfileCardTrigger.d.ts +1 -1
- package/dist/types/messages.d.ts +5 -0
- package/dist/types/types.d.ts +11 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/profilecard
|
|
2
2
|
|
|
3
|
+
## 16.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`31ca93c69a3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/31ca93c69a3) - [ux] Adding give kudos button to the profile card
|
|
8
|
+
|
|
9
|
+
## 16.4.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 16.4.7
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 16.4.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -60,6 +60,22 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
60
60
|
reports: []
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "getTeamCentralBaseUrl",
|
|
65
|
+
value: function getTeamCentralBaseUrl() {
|
|
66
|
+
var _this$tcClient3;
|
|
67
|
+
|
|
68
|
+
return (_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl;
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "shouldShowGiveKudos",
|
|
72
|
+
value: function shouldShowGiveKudos() {
|
|
73
|
+
var _this$tcClient4, _this$tcClient5;
|
|
74
|
+
|
|
75
|
+
// Check if the kudos feature enabled and if the user has TC
|
|
76
|
+
// if the user does not have TC the tc client will be undefined.
|
|
77
|
+
return ((_this$tcClient4 = this.tcClient) === null || _this$tcClient4 === void 0 ? void 0 : _this$tcClient4.options.teamCentralBaseUrl) && ((_this$tcClient5 = this.tcClient) === null || _this$tcClient5 === void 0 ? void 0 : _this$tcClient5.getFlagEnabled('team-central-kudos-enabled-m2')) || Promise.resolve(false);
|
|
78
|
+
}
|
|
63
79
|
}]);
|
|
64
80
|
return ProfileCardClient;
|
|
65
81
|
}();
|
|
@@ -38,6 +38,15 @@ var buildReportingLinesQuery = function buildReportingLinesQuery(aaid) {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
var buildCheckFeatureFlagQuery = function buildCheckFeatureFlagQuery(featureKey) {
|
|
42
|
+
return {
|
|
43
|
+
query: "\n query isFeatureKeyEnabled($featureKey: String!) {\n isFeatureEnabled(featureKey: $featureKey) {\n enabled\n }\n }\n ",
|
|
44
|
+
variables: {
|
|
45
|
+
featureKey: featureKey
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
41
50
|
var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
42
51
|
(0, _inherits2.default)(TeamCentralCardClient, _CachingClient);
|
|
43
52
|
|
|
@@ -58,13 +67,14 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
58
67
|
_this = _super.call(this, options);
|
|
59
68
|
_this.options = options;
|
|
60
69
|
_this.bypassOnFailure = false;
|
|
70
|
+
_this.featureFlagKeys = new Map();
|
|
61
71
|
return _this;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
(0, _createClass2.default)(TeamCentralCardClient, [{
|
|
65
|
-
key: "
|
|
75
|
+
key: "makeFeatureFlagCheckRequest",
|
|
66
76
|
value: function () {
|
|
67
|
-
var
|
|
77
|
+
var _makeFeatureFlagCheckRequest = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(featureKey) {
|
|
68
78
|
var query, response;
|
|
69
79
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
70
80
|
while (1) {
|
|
@@ -78,13 +88,13 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
78
88
|
throw new Error('options.teamCentralUrl is a required parameter for retrieving Team Central data');
|
|
79
89
|
|
|
80
90
|
case 2:
|
|
81
|
-
query =
|
|
91
|
+
query = buildCheckFeatureFlagQuery(featureKey);
|
|
82
92
|
_context.next = 5;
|
|
83
93
|
return (0, _graphqlUtils.graphqlQuery)(this.options.teamCentralUrl, query);
|
|
84
94
|
|
|
85
95
|
case 5:
|
|
86
96
|
response = _context.sent;
|
|
87
|
-
return _context.abrupt("return", response.
|
|
97
|
+
return _context.abrupt("return", response.isFeatureEnabled.enabled);
|
|
88
98
|
|
|
89
99
|
case 7:
|
|
90
100
|
case "end":
|
|
@@ -94,7 +104,46 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
94
104
|
}, _callee, this);
|
|
95
105
|
}));
|
|
96
106
|
|
|
97
|
-
function
|
|
107
|
+
function makeFeatureFlagCheckRequest(_x) {
|
|
108
|
+
return _makeFeatureFlagCheckRequest.apply(this, arguments);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return makeFeatureFlagCheckRequest;
|
|
112
|
+
}()
|
|
113
|
+
}, {
|
|
114
|
+
key: "makeRequest",
|
|
115
|
+
value: function () {
|
|
116
|
+
var _makeRequest = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(userId) {
|
|
117
|
+
var query, response;
|
|
118
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
119
|
+
while (1) {
|
|
120
|
+
switch (_context2.prev = _context2.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
if (this.options.teamCentralUrl) {
|
|
123
|
+
_context2.next = 2;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
throw new Error('options.teamCentralUrl is a required parameter for retrieving Team Central data');
|
|
128
|
+
|
|
129
|
+
case 2:
|
|
130
|
+
query = buildReportingLinesQuery(userId);
|
|
131
|
+
_context2.next = 5;
|
|
132
|
+
return (0, _graphqlUtils.graphqlQuery)(this.options.teamCentralUrl, query);
|
|
133
|
+
|
|
134
|
+
case 5:
|
|
135
|
+
response = _context2.sent;
|
|
136
|
+
return _context2.abrupt("return", response.reportingLines);
|
|
137
|
+
|
|
138
|
+
case 7:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context2.stop();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, _callee2, this);
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
function makeRequest(_x2) {
|
|
98
147
|
return _makeRequest.apply(this, arguments);
|
|
99
148
|
}
|
|
100
149
|
|
|
@@ -146,6 +195,38 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
146
195
|
});
|
|
147
196
|
});
|
|
148
197
|
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "getFlagEnabled",
|
|
200
|
+
value: function getFlagEnabled(featureKey) {
|
|
201
|
+
var _this3 = this;
|
|
202
|
+
|
|
203
|
+
if (!featureKey) {
|
|
204
|
+
return Promise.reject(new Error('featureKey missing'));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (this.featureFlagKeys.has(featureKey)) {
|
|
208
|
+
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (this.bypassOnFailure) {
|
|
212
|
+
return Promise.resolve(false);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return new Promise(function (resolve) {
|
|
216
|
+
_this3.makeFeatureFlagCheckRequest(featureKey).then(function (enabled) {
|
|
217
|
+
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
218
|
+
|
|
219
|
+
resolve(enabled);
|
|
220
|
+
}).catch(function (error) {
|
|
221
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
222
|
+
// Trigger circuit breaker
|
|
223
|
+
_this3.bypassOnFailure = true;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
resolve(false);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
149
230
|
}, {
|
|
150
231
|
key: "filterReportingLinesUser",
|
|
151
232
|
value: function filterReportingLinesUser() {
|
|
@@ -89,6 +89,13 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
89
89
|
_this.props.analytics(id, options);
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "giveKudosCallback", function (clickedUserId) {
|
|
93
|
+
if (clickedUserId) {
|
|
94
|
+
window.open("".concat(_this.props.teamCentralBaseUrl, "/give-kudos?type=individual&recipientId=").concat(clickedUserId));
|
|
95
|
+
} else {
|
|
96
|
+
window.open("".concat(_this.props.teamCentralBaseUrl, "/give-kudos?type=individual"));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
92
99
|
_this.timeOpen = null;
|
|
93
100
|
|
|
94
101
|
_this.clientFetchProfile = function () {
|
|
@@ -116,23 +123,45 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
116
123
|
errorType: this.props.errorType
|
|
117
124
|
});
|
|
118
125
|
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "getActions",
|
|
128
|
+
value: function getActions() {
|
|
129
|
+
var _this3 = this;
|
|
130
|
+
|
|
131
|
+
var actions = this.props.actions || [];
|
|
132
|
+
|
|
133
|
+
if (!this.props.isCurrentUser && this.props.isKudosEnabled) {
|
|
134
|
+
var kudosAction = {
|
|
135
|
+
label: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.default.giveKudosButton),
|
|
136
|
+
id: 'give-kudos',
|
|
137
|
+
callback: function callback() {
|
|
138
|
+
_this3.giveKudosCallback(_this3.props.userId);
|
|
139
|
+
},
|
|
140
|
+
link: this.props.userId ? "".concat(this.props.teamCentralBaseUrl, "/give-kudos?type=individual&recipientId=").concat(this.props.userId) : "".concat(this.props.teamCentralBaseUrl, "/give-kudos?type=individual")
|
|
141
|
+
};
|
|
142
|
+
return actions.concat([kudosAction]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return actions;
|
|
146
|
+
}
|
|
119
147
|
}, {
|
|
120
148
|
key: "renderActionsButtons",
|
|
121
149
|
value: function renderActionsButtons() {
|
|
122
|
-
var
|
|
150
|
+
var _this4 = this;
|
|
123
151
|
|
|
124
152
|
if (this.props.actions && this.props.actions.length === 0) {
|
|
125
153
|
return null;
|
|
126
154
|
}
|
|
127
155
|
|
|
128
|
-
|
|
156
|
+
var actions = this.getActions();
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement(_Card.ActionButtonGroup, null, actions.map(function (action, idx) {
|
|
129
158
|
return /*#__PURE__*/_react.default.createElement(_customThemeButton.default, {
|
|
130
159
|
appearance: idx === 0 ? 'default' : 'subtle',
|
|
131
160
|
key: action.id || idx,
|
|
132
161
|
onClick: function onClick(event) {
|
|
133
|
-
|
|
162
|
+
_this4.callAnalytics(_analytics.AnalyticsName.PROFILE_CARD_CLICK, {
|
|
134
163
|
id: action.id || null,
|
|
135
|
-
duration:
|
|
164
|
+
duration: _this4.durationSince(_this4.timeOpen)
|
|
136
165
|
});
|
|
137
166
|
|
|
138
167
|
if (action.callback && (0, _click.isBasicClick)(event)) {
|
|
@@ -152,7 +181,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
152
181
|
}, {
|
|
153
182
|
key: "renderCardDetailsDefault",
|
|
154
183
|
value: function renderCardDetailsDefault() {
|
|
155
|
-
var
|
|
184
|
+
var _this5 = this;
|
|
156
185
|
|
|
157
186
|
var _this$props2 = this.props,
|
|
158
187
|
meta = _this$props2.meta,
|
|
@@ -175,7 +204,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
175
204
|
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
176
205
|
analytics: this.props.analytics,
|
|
177
206
|
getDuration: function getDuration() {
|
|
178
|
-
return
|
|
207
|
+
return _this5.durationSince(_this5.timeOpen);
|
|
179
208
|
}
|
|
180
209
|
}));
|
|
181
210
|
}
|
|
@@ -13,6 +13,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
13
13
|
|
|
14
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
15
|
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
|
|
16
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
19
|
|
|
18
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -123,7 +125,9 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
123
125
|
hasError: false,
|
|
124
126
|
error: null,
|
|
125
127
|
data: null,
|
|
126
|
-
reportingLinesData: undefined
|
|
128
|
+
reportingLinesData: undefined,
|
|
129
|
+
shouldShowGiveKudos: false,
|
|
130
|
+
teamCentralBaseUrl: undefined
|
|
127
131
|
});
|
|
128
132
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clientFetchProfile", function () {
|
|
129
133
|
var _this$props = _this.props,
|
|
@@ -136,14 +140,20 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
136
140
|
return;
|
|
137
141
|
}
|
|
138
142
|
|
|
143
|
+
_this.setState({
|
|
144
|
+
teamCentralBaseUrl: _this.props.resourceClient.getTeamCentralBaseUrl()
|
|
145
|
+
});
|
|
146
|
+
|
|
139
147
|
_this.setState({
|
|
140
148
|
isLoading: true,
|
|
141
149
|
hasError: false,
|
|
142
150
|
data: null
|
|
143
151
|
}, function () {
|
|
144
|
-
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId), _this.props.resourceClient.getReportingLines(userId)]);
|
|
152
|
+
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
|
|
145
153
|
requests.then(function (res) {
|
|
146
|
-
|
|
154
|
+
var _this2;
|
|
155
|
+
|
|
156
|
+
return (_this2 = _this).handleClientSuccess.apply(_this2, (0, _toConsumableArray2.default)(res));
|
|
147
157
|
}, function (err) {
|
|
148
158
|
return _this.handleClientError(err);
|
|
149
159
|
}).catch(function (err) {
|
|
@@ -192,7 +202,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
192
202
|
}
|
|
193
203
|
}, {
|
|
194
204
|
key: "handleClientSuccess",
|
|
195
|
-
value: function handleClientSuccess(profileData, reportingLinesData) {
|
|
205
|
+
value: function handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
196
206
|
if (!this._isMounted) {
|
|
197
207
|
return;
|
|
198
208
|
}
|
|
@@ -201,7 +211,8 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
201
211
|
isLoading: false,
|
|
202
212
|
hasError: false,
|
|
203
213
|
data: profileData,
|
|
204
|
-
reportingLinesData: reportingLinesData
|
|
214
|
+
reportingLinesData: reportingLinesData,
|
|
215
|
+
shouldShowGiveKudos: shouldShowGiveKudos
|
|
205
216
|
});
|
|
206
217
|
}
|
|
207
218
|
}, {
|
|
@@ -225,12 +236,18 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
225
236
|
}, {
|
|
226
237
|
key: "renderProfileCard",
|
|
227
238
|
value: function renderProfileCard() {
|
|
239
|
+
var _this$state$data;
|
|
240
|
+
|
|
228
241
|
var newProps = _objectSpread(_objectSpread({
|
|
242
|
+
userId: this.props.userId,
|
|
243
|
+
isCurrentUser: (_this$state$data = this.state.data) === null || _this$state$data === void 0 ? void 0 : _this$state$data.isCurrentUser,
|
|
229
244
|
clientFetchProfile: this.clientFetchProfile,
|
|
230
245
|
analytics: this.props.analytics
|
|
231
246
|
}, this.state.data), {}, {
|
|
232
247
|
reportingLines: this.state.reportingLinesData,
|
|
233
|
-
onReportingLinesClick: this.props.onReportingLinesClick
|
|
248
|
+
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
249
|
+
isKudosEnabled: this.state.shouldShowGiveKudos,
|
|
250
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl
|
|
234
251
|
});
|
|
235
252
|
|
|
236
253
|
var wrapperProps = this.props.trigger === 'hover' ? {
|
|
@@ -249,7 +266,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
249
266
|
}, {
|
|
250
267
|
key: "renderWithTrigger",
|
|
251
268
|
value: function renderWithTrigger() {
|
|
252
|
-
var
|
|
269
|
+
var _this3 = this;
|
|
253
270
|
|
|
254
271
|
return /*#__PURE__*/_react.default.createElement(_popup.default, {
|
|
255
272
|
isOpen: !!this.state.visible,
|
|
@@ -259,10 +276,10 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
259
276
|
trigger: function trigger(triggerProps) {
|
|
260
277
|
var ref = triggerProps.ref,
|
|
261
278
|
innerProps = (0, _objectWithoutProperties2.default)(triggerProps, _excluded);
|
|
262
|
-
return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({}, innerProps,
|
|
279
|
+
return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({}, innerProps, _this3.containerListeners, {
|
|
263
280
|
ref: ref,
|
|
264
|
-
"data-testid":
|
|
265
|
-
}),
|
|
281
|
+
"data-testid": _this3.props.testId
|
|
282
|
+
}), _this3.props.children);
|
|
266
283
|
},
|
|
267
284
|
zIndex: _constants.layers.modal(),
|
|
268
285
|
shouldUseCaptureOnOutsideClick: true
|
package/dist/cjs/messages.js
CHANGED
|
@@ -147,6 +147,11 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
147
147
|
id: 'pt.team-profile-card.directReports.heading',
|
|
148
148
|
defaultMessage: 'Direct reports',
|
|
149
149
|
description: "Title for a section on the profile card that show the user's direct reports"
|
|
150
|
+
},
|
|
151
|
+
giveKudosButton: {
|
|
152
|
+
id: 'pt.profile-card.give-kudos',
|
|
153
|
+
defaultMessage: 'Give kudos',
|
|
154
|
+
description: 'Title for the button on the profile card for a user to give a kudos'
|
|
150
155
|
}
|
|
151
156
|
});
|
|
152
157
|
var _default = messages;
|
package/dist/cjs/styled/Card.js
CHANGED
|
@@ -43,7 +43,7 @@ var ActionsFlexSpacer = _styledComponents.default.div(_templateObject4 || (_temp
|
|
|
43
43
|
|
|
44
44
|
exports.ActionsFlexSpacer = ActionsFlexSpacer;
|
|
45
45
|
|
|
46
|
-
var ActionButtonGroup = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n user-select: none;\n margin: ", "px 0 0 0;\n text-align: right;\n\n button {\n margin-left: ", "px;\n\n &:first-child {\n margin-left: 0;\n }\n }\n"])), 2 * (0, _constants.gridSize)(), _constants.gridSize);
|
|
46
|
+
var ActionButtonGroup = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n user-select: none;\n margin: ", "px 0 0 0;\n text-align: right;\n\n button,\n a {\n margin-left: ", "px;\n\n &:first-child {\n margin-left: 0;\n }\n }\n"])), 2 * (0, _constants.gridSize)(), _constants.gridSize);
|
|
47
47
|
|
|
48
48
|
exports.ActionButtonGroup = ActionButtonGroup;
|
|
49
49
|
|
|
@@ -56,7 +56,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
56
56
|
actionSubjectId: actionSubjectId,
|
|
57
57
|
attributes: _objectSpread(_objectSpread({
|
|
58
58
|
packageName: "@atlaskit/profilecard",
|
|
59
|
-
packageVersion: "16.
|
|
59
|
+
packageVersion: "16.5.0"
|
|
60
60
|
}, attributes), {}, {
|
|
61
61
|
firedAt: (0, _performance.getPageTime)()
|
|
62
62
|
})
|
package/dist/cjs/version.json
CHANGED
|
@@ -34,6 +34,20 @@ class ProfileCardClient {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
getTeamCentralBaseUrl() {
|
|
38
|
+
var _this$tcClient3;
|
|
39
|
+
|
|
40
|
+
return (_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
shouldShowGiveKudos() {
|
|
44
|
+
var _this$tcClient4, _this$tcClient5;
|
|
45
|
+
|
|
46
|
+
// Check if the kudos feature enabled and if the user has TC
|
|
47
|
+
// if the user does not have TC the tc client will be undefined.
|
|
48
|
+
return ((_this$tcClient4 = this.tcClient) === null || _this$tcClient4 === void 0 ? void 0 : _this$tcClient4.options.teamCentralBaseUrl) && ((_this$tcClient5 = this.tcClient) === null || _this$tcClient5 === void 0 ? void 0 : _this$tcClient5.getFlagEnabled('team-central-kudos-enabled-m2')) || Promise.resolve(false);
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
function maybeCreateTeamCentralClient(config, clients) {
|
|
@@ -32,6 +32,19 @@ const buildReportingLinesQuery = aaid => ({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
const buildCheckFeatureFlagQuery = featureKey => ({
|
|
36
|
+
query: `
|
|
37
|
+
query isFeatureKeyEnabled($featureKey: String!) {
|
|
38
|
+
isFeatureEnabled(featureKey: $featureKey) {
|
|
39
|
+
enabled
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`,
|
|
43
|
+
variables: {
|
|
44
|
+
featureKey
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
35
48
|
class TeamCentralCardClient extends CachingClient {
|
|
36
49
|
/**
|
|
37
50
|
* Simple circuit breaker to avoid making unnecessary calls to Team Central on auth failures
|
|
@@ -45,6 +58,17 @@ class TeamCentralCardClient extends CachingClient {
|
|
|
45
58
|
super(options);
|
|
46
59
|
this.options = options;
|
|
47
60
|
this.bypassOnFailure = false;
|
|
61
|
+
this.featureFlagKeys = new Map();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async makeFeatureFlagCheckRequest(featureKey) {
|
|
65
|
+
if (!this.options.teamCentralUrl) {
|
|
66
|
+
throw new Error('options.teamCentralUrl is a required parameter for retrieving Team Central data');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const query = buildCheckFeatureFlagQuery(featureKey);
|
|
70
|
+
const response = await graphqlQuery(this.options.teamCentralUrl, query);
|
|
71
|
+
return response.isFeatureEnabled.enabled;
|
|
48
72
|
}
|
|
49
73
|
|
|
50
74
|
async makeRequest(userId) {
|
|
@@ -100,6 +124,34 @@ class TeamCentralCardClient extends CachingClient {
|
|
|
100
124
|
});
|
|
101
125
|
}
|
|
102
126
|
|
|
127
|
+
getFlagEnabled(featureKey) {
|
|
128
|
+
if (!featureKey) {
|
|
129
|
+
return Promise.reject(new Error('featureKey missing'));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (this.featureFlagKeys.has(featureKey)) {
|
|
133
|
+
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (this.bypassOnFailure) {
|
|
137
|
+
return Promise.resolve(false);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return new Promise(resolve => {
|
|
141
|
+
this.makeFeatureFlagCheckRequest(featureKey).then(enabled => {
|
|
142
|
+
this.featureFlagKeys.set(featureKey, enabled);
|
|
143
|
+
resolve(enabled);
|
|
144
|
+
}).catch(error => {
|
|
145
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
146
|
+
// Trigger circuit breaker
|
|
147
|
+
this.bypassOnFailure = true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
resolve(false);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
103
155
|
filterReportingLinesUser(users = []) {
|
|
104
156
|
return users.filter(user => user.identifierType === 'ATLASSIAN_ID');
|
|
105
157
|
}
|
|
@@ -37,6 +37,14 @@ export default class Profilecard extends React.PureComponent {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
_defineProperty(this, "giveKudosCallback", clickedUserId => {
|
|
41
|
+
if (clickedUserId) {
|
|
42
|
+
window.open(`${this.props.teamCentralBaseUrl}/give-kudos?type=individual&recipientId=${clickedUserId}`);
|
|
43
|
+
} else {
|
|
44
|
+
window.open(`${this.props.teamCentralBaseUrl}/give-kudos?type=individual`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
40
48
|
this.timeOpen = null;
|
|
41
49
|
|
|
42
50
|
this.clientFetchProfile = (...args) => {
|
|
@@ -57,12 +65,31 @@ export default class Profilecard extends React.PureComponent {
|
|
|
57
65
|
});
|
|
58
66
|
}
|
|
59
67
|
|
|
68
|
+
getActions() {
|
|
69
|
+
const actions = this.props.actions || [];
|
|
70
|
+
|
|
71
|
+
if (!this.props.isCurrentUser && this.props.isKudosEnabled) {
|
|
72
|
+
const kudosAction = {
|
|
73
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
|
|
74
|
+
id: 'give-kudos',
|
|
75
|
+
callback: () => {
|
|
76
|
+
this.giveKudosCallback(this.props.userId);
|
|
77
|
+
},
|
|
78
|
+
link: this.props.userId ? `${this.props.teamCentralBaseUrl}/give-kudos?type=individual&recipientId=${this.props.userId}` : `${this.props.teamCentralBaseUrl}/give-kudos?type=individual`
|
|
79
|
+
};
|
|
80
|
+
return actions.concat([kudosAction]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return actions;
|
|
84
|
+
}
|
|
85
|
+
|
|
60
86
|
renderActionsButtons() {
|
|
61
87
|
if (this.props.actions && this.props.actions.length === 0) {
|
|
62
88
|
return null;
|
|
63
89
|
}
|
|
64
90
|
|
|
65
|
-
|
|
91
|
+
const actions = this.getActions();
|
|
92
|
+
return /*#__PURE__*/React.createElement(ActionButtonGroup, null, actions.map((action, idx) => /*#__PURE__*/React.createElement(Button, {
|
|
66
93
|
appearance: idx === 0 ? 'default' : 'subtle',
|
|
67
94
|
key: action.id || idx,
|
|
68
95
|
onClick: (event, ...args) => {
|
|
@@ -72,7 +72,9 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
72
72
|
hasError: false,
|
|
73
73
|
error: null,
|
|
74
74
|
data: null,
|
|
75
|
-
reportingLinesData: undefined
|
|
75
|
+
reportingLinesData: undefined,
|
|
76
|
+
shouldShowGiveKudos: false,
|
|
77
|
+
teamCentralBaseUrl: undefined
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
_defineProperty(this, "clientFetchProfile", () => {
|
|
@@ -89,13 +91,16 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
this.setState({
|
|
95
|
+
teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
|
|
96
|
+
});
|
|
92
97
|
this.setState({
|
|
93
98
|
isLoading: true,
|
|
94
99
|
hasError: false,
|
|
95
100
|
data: null
|
|
96
101
|
}, () => {
|
|
97
|
-
const requests = Promise.all([this.props.resourceClient.getProfile(cloudId || '', userId), this.props.resourceClient.getReportingLines(userId)]);
|
|
98
|
-
requests.then(res => this.handleClientSuccess(res
|
|
102
|
+
const requests = Promise.all([this.props.resourceClient.getProfile(cloudId || '', userId), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos()]);
|
|
103
|
+
requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
|
|
99
104
|
});
|
|
100
105
|
});
|
|
101
106
|
|
|
@@ -139,7 +144,7 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
139
144
|
clearTimeout(this.hideTimer);
|
|
140
145
|
}
|
|
141
146
|
|
|
142
|
-
handleClientSuccess(profileData, reportingLinesData) {
|
|
147
|
+
handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
143
148
|
if (!this._isMounted) {
|
|
144
149
|
return;
|
|
145
150
|
}
|
|
@@ -148,7 +153,8 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
148
153
|
isLoading: false,
|
|
149
154
|
hasError: false,
|
|
150
155
|
data: profileData,
|
|
151
|
-
reportingLinesData
|
|
156
|
+
reportingLinesData,
|
|
157
|
+
shouldShowGiveKudos
|
|
152
158
|
});
|
|
153
159
|
}
|
|
154
160
|
|
|
@@ -169,12 +175,18 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
169
175
|
}
|
|
170
176
|
|
|
171
177
|
renderProfileCard() {
|
|
178
|
+
var _this$state$data;
|
|
179
|
+
|
|
172
180
|
const newProps = {
|
|
181
|
+
userId: this.props.userId,
|
|
182
|
+
isCurrentUser: (_this$state$data = this.state.data) === null || _this$state$data === void 0 ? void 0 : _this$state$data.isCurrentUser,
|
|
173
183
|
clientFetchProfile: this.clientFetchProfile,
|
|
174
184
|
analytics: this.props.analytics,
|
|
175
185
|
...this.state.data,
|
|
176
186
|
reportingLines: this.state.reportingLinesData,
|
|
177
|
-
onReportingLinesClick: this.props.onReportingLinesClick
|
|
187
|
+
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
188
|
+
isKudosEnabled: this.state.shouldShowGiveKudos,
|
|
189
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl
|
|
178
190
|
};
|
|
179
191
|
const wrapperProps = this.props.trigger === 'hover' ? {
|
|
180
192
|
onMouseEnter: this.showProfilecard,
|
package/dist/es2019/messages.js
CHANGED
|
@@ -139,6 +139,11 @@ const messages = defineMessages({
|
|
|
139
139
|
id: 'pt.team-profile-card.directReports.heading',
|
|
140
140
|
defaultMessage: 'Direct reports',
|
|
141
141
|
description: "Title for a section on the profile card that show the user's direct reports"
|
|
142
|
+
},
|
|
143
|
+
giveKudosButton: {
|
|
144
|
+
id: 'pt.profile-card.give-kudos',
|
|
145
|
+
defaultMessage: 'Give kudos',
|
|
146
|
+
description: 'Title for the button on the profile card for a user to give a kudos'
|
|
142
147
|
}
|
|
143
148
|
});
|
|
144
149
|
export default messages;
|
|
@@ -35,7 +35,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
35
35
|
actionSubjectId,
|
|
36
36
|
attributes: {
|
|
37
37
|
packageName: "@atlaskit/profilecard",
|
|
38
|
-
packageVersion: "16.
|
|
38
|
+
packageVersion: "16.5.0",
|
|
39
39
|
...attributes,
|
|
40
40
|
firedAt: getPageTime()
|
|
41
41
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -48,6 +48,22 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
48
48
|
reports: []
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "getTeamCentralBaseUrl",
|
|
53
|
+
value: function getTeamCentralBaseUrl() {
|
|
54
|
+
var _this$tcClient3;
|
|
55
|
+
|
|
56
|
+
return (_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "shouldShowGiveKudos",
|
|
60
|
+
value: function shouldShowGiveKudos() {
|
|
61
|
+
var _this$tcClient4, _this$tcClient5;
|
|
62
|
+
|
|
63
|
+
// Check if the kudos feature enabled and if the user has TC
|
|
64
|
+
// if the user does not have TC the tc client will be undefined.
|
|
65
|
+
return ((_this$tcClient4 = this.tcClient) === null || _this$tcClient4 === void 0 ? void 0 : _this$tcClient4.options.teamCentralBaseUrl) && ((_this$tcClient5 = this.tcClient) === null || _this$tcClient5 === void 0 ? void 0 : _this$tcClient5.getFlagEnabled('team-central-kudos-enabled-m2')) || Promise.resolve(false);
|
|
66
|
+
}
|
|
51
67
|
}]);
|
|
52
68
|
|
|
53
69
|
return ProfileCardClient;
|
|
@@ -22,6 +22,15 @@ var buildReportingLinesQuery = function buildReportingLinesQuery(aaid) {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
var buildCheckFeatureFlagQuery = function buildCheckFeatureFlagQuery(featureKey) {
|
|
26
|
+
return {
|
|
27
|
+
query: "\n query isFeatureKeyEnabled($featureKey: String!) {\n isFeatureEnabled(featureKey: $featureKey) {\n enabled\n }\n }\n ",
|
|
28
|
+
variables: {
|
|
29
|
+
featureKey: featureKey
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
25
34
|
var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
26
35
|
_inherits(TeamCentralCardClient, _CachingClient);
|
|
27
36
|
|
|
@@ -43,13 +52,14 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
43
52
|
_this = _super.call(this, options);
|
|
44
53
|
_this.options = options;
|
|
45
54
|
_this.bypassOnFailure = false;
|
|
55
|
+
_this.featureFlagKeys = new Map();
|
|
46
56
|
return _this;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
_createClass(TeamCentralCardClient, [{
|
|
50
|
-
key: "
|
|
60
|
+
key: "makeFeatureFlagCheckRequest",
|
|
51
61
|
value: function () {
|
|
52
|
-
var
|
|
62
|
+
var _makeFeatureFlagCheckRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(featureKey) {
|
|
53
63
|
var query, response;
|
|
54
64
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
55
65
|
while (1) {
|
|
@@ -63,13 +73,13 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
63
73
|
throw new Error('options.teamCentralUrl is a required parameter for retrieving Team Central data');
|
|
64
74
|
|
|
65
75
|
case 2:
|
|
66
|
-
query =
|
|
76
|
+
query = buildCheckFeatureFlagQuery(featureKey);
|
|
67
77
|
_context.next = 5;
|
|
68
78
|
return graphqlQuery(this.options.teamCentralUrl, query);
|
|
69
79
|
|
|
70
80
|
case 5:
|
|
71
81
|
response = _context.sent;
|
|
72
|
-
return _context.abrupt("return", response.
|
|
82
|
+
return _context.abrupt("return", response.isFeatureEnabled.enabled);
|
|
73
83
|
|
|
74
84
|
case 7:
|
|
75
85
|
case "end":
|
|
@@ -79,7 +89,46 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
79
89
|
}, _callee, this);
|
|
80
90
|
}));
|
|
81
91
|
|
|
82
|
-
function
|
|
92
|
+
function makeFeatureFlagCheckRequest(_x) {
|
|
93
|
+
return _makeFeatureFlagCheckRequest.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return makeFeatureFlagCheckRequest;
|
|
97
|
+
}()
|
|
98
|
+
}, {
|
|
99
|
+
key: "makeRequest",
|
|
100
|
+
value: function () {
|
|
101
|
+
var _makeRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(userId) {
|
|
102
|
+
var query, response;
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) {
|
|
105
|
+
switch (_context2.prev = _context2.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
if (this.options.teamCentralUrl) {
|
|
108
|
+
_context2.next = 2;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
throw new Error('options.teamCentralUrl is a required parameter for retrieving Team Central data');
|
|
113
|
+
|
|
114
|
+
case 2:
|
|
115
|
+
query = buildReportingLinesQuery(userId);
|
|
116
|
+
_context2.next = 5;
|
|
117
|
+
return graphqlQuery(this.options.teamCentralUrl, query);
|
|
118
|
+
|
|
119
|
+
case 5:
|
|
120
|
+
response = _context2.sent;
|
|
121
|
+
return _context2.abrupt("return", response.reportingLines);
|
|
122
|
+
|
|
123
|
+
case 7:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context2.stop();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, _callee2, this);
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
function makeRequest(_x2) {
|
|
83
132
|
return _makeRequest.apply(this, arguments);
|
|
84
133
|
}
|
|
85
134
|
|
|
@@ -131,6 +180,38 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
131
180
|
});
|
|
132
181
|
});
|
|
133
182
|
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "getFlagEnabled",
|
|
185
|
+
value: function getFlagEnabled(featureKey) {
|
|
186
|
+
var _this3 = this;
|
|
187
|
+
|
|
188
|
+
if (!featureKey) {
|
|
189
|
+
return Promise.reject(new Error('featureKey missing'));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this.featureFlagKeys.has(featureKey)) {
|
|
193
|
+
return Promise.resolve(this.featureFlagKeys.get(featureKey));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (this.bypassOnFailure) {
|
|
197
|
+
return Promise.resolve(false);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return new Promise(function (resolve) {
|
|
201
|
+
_this3.makeFeatureFlagCheckRequest(featureKey).then(function (enabled) {
|
|
202
|
+
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
203
|
+
|
|
204
|
+
resolve(enabled);
|
|
205
|
+
}).catch(function (error) {
|
|
206
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 401 || (error === null || error === void 0 ? void 0 : error.status) === 403) {
|
|
207
|
+
// Trigger circuit breaker
|
|
208
|
+
_this3.bypassOnFailure = true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
resolve(false);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
134
215
|
}, {
|
|
135
216
|
key: "filterReportingLinesUser",
|
|
136
217
|
value: function filterReportingLinesUser() {
|
|
@@ -61,6 +61,14 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "giveKudosCallback", function (clickedUserId) {
|
|
65
|
+
if (clickedUserId) {
|
|
66
|
+
window.open("".concat(_this.props.teamCentralBaseUrl, "/give-kudos?type=individual&recipientId=").concat(clickedUserId));
|
|
67
|
+
} else {
|
|
68
|
+
window.open("".concat(_this.props.teamCentralBaseUrl, "/give-kudos?type=individual"));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
64
72
|
_this.timeOpen = null;
|
|
65
73
|
|
|
66
74
|
_this.clientFetchProfile = function () {
|
|
@@ -88,23 +96,45 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
88
96
|
errorType: this.props.errorType
|
|
89
97
|
});
|
|
90
98
|
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "getActions",
|
|
101
|
+
value: function getActions() {
|
|
102
|
+
var _this3 = this;
|
|
103
|
+
|
|
104
|
+
var actions = this.props.actions || [];
|
|
105
|
+
|
|
106
|
+
if (!this.props.isCurrentUser && this.props.isKudosEnabled) {
|
|
107
|
+
var kudosAction = {
|
|
108
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
|
|
109
|
+
id: 'give-kudos',
|
|
110
|
+
callback: function callback() {
|
|
111
|
+
_this3.giveKudosCallback(_this3.props.userId);
|
|
112
|
+
},
|
|
113
|
+
link: this.props.userId ? "".concat(this.props.teamCentralBaseUrl, "/give-kudos?type=individual&recipientId=").concat(this.props.userId) : "".concat(this.props.teamCentralBaseUrl, "/give-kudos?type=individual")
|
|
114
|
+
};
|
|
115
|
+
return actions.concat([kudosAction]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return actions;
|
|
119
|
+
}
|
|
91
120
|
}, {
|
|
92
121
|
key: "renderActionsButtons",
|
|
93
122
|
value: function renderActionsButtons() {
|
|
94
|
-
var
|
|
123
|
+
var _this4 = this;
|
|
95
124
|
|
|
96
125
|
if (this.props.actions && this.props.actions.length === 0) {
|
|
97
126
|
return null;
|
|
98
127
|
}
|
|
99
128
|
|
|
100
|
-
|
|
129
|
+
var actions = this.getActions();
|
|
130
|
+
return /*#__PURE__*/React.createElement(ActionButtonGroup, null, actions.map(function (action, idx) {
|
|
101
131
|
return /*#__PURE__*/React.createElement(Button, {
|
|
102
132
|
appearance: idx === 0 ? 'default' : 'subtle',
|
|
103
133
|
key: action.id || idx,
|
|
104
134
|
onClick: function onClick(event) {
|
|
105
|
-
|
|
135
|
+
_this4.callAnalytics(AnalyticsName.PROFILE_CARD_CLICK, {
|
|
106
136
|
id: action.id || null,
|
|
107
|
-
duration:
|
|
137
|
+
duration: _this4.durationSince(_this4.timeOpen)
|
|
108
138
|
});
|
|
109
139
|
|
|
110
140
|
if (action.callback && isBasicClick(event)) {
|
|
@@ -124,7 +154,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
124
154
|
}, {
|
|
125
155
|
key: "renderCardDetailsDefault",
|
|
126
156
|
value: function renderCardDetailsDefault() {
|
|
127
|
-
var
|
|
157
|
+
var _this5 = this;
|
|
128
158
|
|
|
129
159
|
var _this$props2 = this.props,
|
|
130
160
|
meta = _this$props2.meta,
|
|
@@ -147,7 +177,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
147
177
|
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
148
178
|
analytics: this.props.analytics,
|
|
149
179
|
getDuration: function getDuration() {
|
|
150
|
-
return
|
|
180
|
+
return _this5.durationSince(_this5.timeOpen);
|
|
151
181
|
}
|
|
152
182
|
}));
|
|
153
183
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
6
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -103,7 +104,9 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
103
104
|
hasError: false,
|
|
104
105
|
error: null,
|
|
105
106
|
data: null,
|
|
106
|
-
reportingLinesData: undefined
|
|
107
|
+
reportingLinesData: undefined,
|
|
108
|
+
shouldShowGiveKudos: false,
|
|
109
|
+
teamCentralBaseUrl: undefined
|
|
107
110
|
});
|
|
108
111
|
|
|
109
112
|
_defineProperty(_assertThisInitialized(_this), "clientFetchProfile", function () {
|
|
@@ -117,14 +120,20 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
122
|
|
|
123
|
+
_this.setState({
|
|
124
|
+
teamCentralBaseUrl: _this.props.resourceClient.getTeamCentralBaseUrl()
|
|
125
|
+
});
|
|
126
|
+
|
|
120
127
|
_this.setState({
|
|
121
128
|
isLoading: true,
|
|
122
129
|
hasError: false,
|
|
123
130
|
data: null
|
|
124
131
|
}, function () {
|
|
125
|
-
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId), _this.props.resourceClient.getReportingLines(userId)]);
|
|
132
|
+
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
|
|
126
133
|
requests.then(function (res) {
|
|
127
|
-
|
|
134
|
+
var _this2;
|
|
135
|
+
|
|
136
|
+
return (_this2 = _this).handleClientSuccess.apply(_this2, _toConsumableArray(res));
|
|
128
137
|
}, function (err) {
|
|
129
138
|
return _this.handleClientError(err);
|
|
130
139
|
}).catch(function (err) {
|
|
@@ -175,7 +184,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
175
184
|
}
|
|
176
185
|
}, {
|
|
177
186
|
key: "handleClientSuccess",
|
|
178
|
-
value: function handleClientSuccess(profileData, reportingLinesData) {
|
|
187
|
+
value: function handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
179
188
|
if (!this._isMounted) {
|
|
180
189
|
return;
|
|
181
190
|
}
|
|
@@ -184,7 +193,8 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
184
193
|
isLoading: false,
|
|
185
194
|
hasError: false,
|
|
186
195
|
data: profileData,
|
|
187
|
-
reportingLinesData: reportingLinesData
|
|
196
|
+
reportingLinesData: reportingLinesData,
|
|
197
|
+
shouldShowGiveKudos: shouldShowGiveKudos
|
|
188
198
|
});
|
|
189
199
|
}
|
|
190
200
|
}, {
|
|
@@ -208,12 +218,18 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
208
218
|
}, {
|
|
209
219
|
key: "renderProfileCard",
|
|
210
220
|
value: function renderProfileCard() {
|
|
221
|
+
var _this$state$data;
|
|
222
|
+
|
|
211
223
|
var newProps = _objectSpread(_objectSpread({
|
|
224
|
+
userId: this.props.userId,
|
|
225
|
+
isCurrentUser: (_this$state$data = this.state.data) === null || _this$state$data === void 0 ? void 0 : _this$state$data.isCurrentUser,
|
|
212
226
|
clientFetchProfile: this.clientFetchProfile,
|
|
213
227
|
analytics: this.props.analytics
|
|
214
228
|
}, this.state.data), {}, {
|
|
215
229
|
reportingLines: this.state.reportingLinesData,
|
|
216
|
-
onReportingLinesClick: this.props.onReportingLinesClick
|
|
230
|
+
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
231
|
+
isKudosEnabled: this.state.shouldShowGiveKudos,
|
|
232
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl
|
|
217
233
|
});
|
|
218
234
|
|
|
219
235
|
var wrapperProps = this.props.trigger === 'hover' ? {
|
|
@@ -232,7 +248,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
232
248
|
}, {
|
|
233
249
|
key: "renderWithTrigger",
|
|
234
250
|
value: function renderWithTrigger() {
|
|
235
|
-
var
|
|
251
|
+
var _this3 = this;
|
|
236
252
|
|
|
237
253
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
238
254
|
isOpen: !!this.state.visible,
|
|
@@ -243,10 +259,10 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
243
259
|
var ref = triggerProps.ref,
|
|
244
260
|
innerProps = _objectWithoutProperties(triggerProps, _excluded);
|
|
245
261
|
|
|
246
|
-
return /*#__PURE__*/React.createElement("span", _extends({}, innerProps,
|
|
262
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, innerProps, _this3.containerListeners, {
|
|
247
263
|
ref: ref,
|
|
248
|
-
"data-testid":
|
|
249
|
-
}),
|
|
264
|
+
"data-testid": _this3.props.testId
|
|
265
|
+
}), _this3.props.children);
|
|
250
266
|
},
|
|
251
267
|
zIndex: layers.modal(),
|
|
252
268
|
shouldUseCaptureOnOutsideClick: true
|
package/dist/esm/messages.js
CHANGED
|
@@ -139,6 +139,11 @@ var messages = defineMessages({
|
|
|
139
139
|
id: 'pt.team-profile-card.directReports.heading',
|
|
140
140
|
defaultMessage: 'Direct reports',
|
|
141
141
|
description: "Title for a section on the profile card that show the user's direct reports"
|
|
142
|
+
},
|
|
143
|
+
giveKudosButton: {
|
|
144
|
+
id: 'pt.profile-card.give-kudos',
|
|
145
|
+
defaultMessage: 'Give kudos',
|
|
146
|
+
description: 'Title for the button on the profile card for a user to give a kudos'
|
|
142
147
|
}
|
|
143
148
|
});
|
|
144
149
|
export default messages;
|
package/dist/esm/styled/Card.js
CHANGED
|
@@ -14,7 +14,7 @@ export var CardContainerEmpty = styled.div(_templateObject || (_templateObject =
|
|
|
14
14
|
export var CardWrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background-color: ", ";\n border-radius: ", "px;\n width: ", "px;\n"])), bgColor, borderRadius, gridSize() * 45);
|
|
15
15
|
export var ProfileImage = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n top: ", "px;\n left: ", "px;\n"])), gridSize() * 3, gridSize() * 3);
|
|
16
16
|
export var ActionsFlexSpacer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex: 1 0 auto;\n"])));
|
|
17
|
-
export var ActionButtonGroup = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n user-select: none;\n margin: ", "px 0 0 0;\n text-align: right;\n\n button {\n margin-left: ", "px;\n\n &:first-child {\n margin-left: 0;\n }\n }\n"])), 2 * gridSize(), gridSize);
|
|
17
|
+
export var ActionButtonGroup = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n user-select: none;\n margin: ", "px 0 0 0;\n text-align: right;\n\n button,\n a {\n margin-left: ", "px;\n\n &:first-child {\n margin-left: 0;\n }\n }\n"])), 2 * gridSize(), gridSize);
|
|
18
18
|
export var CardContent = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n min-height: ", "px;\n"])), gridSize() * 17);
|
|
19
19
|
export var DetailsGroup = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n margin-left: ", "px;\n width: ", "px;\n"])), gridSize() * 14.5, gridSize() * 24.5);
|
|
20
20
|
export var DisabledInfo = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n font-size: ", "px;\n color: ", ";\n margin: ", "px 0 0 0;\n line-height: ", "px;\n"])), fontSizeSmall, labelTextColor, gridSize() * 1.5, gridSize() * 2);
|
|
@@ -45,7 +45,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
45
45
|
actionSubjectId: actionSubjectId,
|
|
46
46
|
attributes: _objectSpread(_objectSpread({
|
|
47
47
|
packageName: "@atlaskit/profilecard",
|
|
48
|
-
packageVersion: "16.
|
|
48
|
+
packageVersion: "16.5.0"
|
|
49
49
|
}, attributes), {}, {
|
|
50
50
|
firedAt: getPageTime()
|
|
51
51
|
})
|
package/dist/esm/version.json
CHANGED
|
@@ -11,5 +11,7 @@ declare class ProfileCardClient {
|
|
|
11
11
|
getProfile(cloudId: string, userId: string): Promise<any>;
|
|
12
12
|
getTeamProfile(teamId: string, orgId?: string, analytics?: (event: Record<string, any>) => void): Promise<import("../types").Team>;
|
|
13
13
|
getReportingLines(userId: string): Promise<TeamCentralReportingLinesData>;
|
|
14
|
+
getTeamCentralBaseUrl(): string | undefined;
|
|
15
|
+
shouldShowGiveKudos(): Promise<boolean>;
|
|
14
16
|
}
|
|
15
17
|
export default ProfileCardClient;
|
|
@@ -14,9 +14,12 @@ declare class TeamCentralCardClient extends CachingClient<TeamCentralReportingLi
|
|
|
14
14
|
* catch a pretty specific edge case.
|
|
15
15
|
*/
|
|
16
16
|
bypassOnFailure: boolean;
|
|
17
|
+
featureFlagKeys: Map<string, boolean>;
|
|
17
18
|
constructor(options: TeamCentralCardClientOptions);
|
|
19
|
+
makeFeatureFlagCheckRequest(featureKey: string): Promise<boolean>;
|
|
18
20
|
makeRequest(userId: string): Promise<TeamCentralReportingLinesData>;
|
|
19
21
|
getReportingLines(userId: string): Promise<TeamCentralReportingLinesData>;
|
|
22
|
+
getFlagEnabled(featureKey: string): Promise<boolean>;
|
|
20
23
|
private filterReportingLinesUser;
|
|
21
24
|
}
|
|
22
25
|
export default TeamCentralCardClient;
|
|
@@ -10,6 +10,8 @@ export default class Profilecard extends React.PureComponent<ProfilecardProps> {
|
|
|
10
10
|
callAnalytics: (id: string, options: any) => void;
|
|
11
11
|
componentDidMount(): void;
|
|
12
12
|
renderErrorMessage(): JSX.Element;
|
|
13
|
+
giveKudosCallback: (clickedUserId?: string | undefined) => void;
|
|
14
|
+
getActions(): import("../../types").ProfileCardAction[];
|
|
13
15
|
renderActionsButtons(): JSX.Element | null;
|
|
14
16
|
renderCardDetailsDefault(): JSX.Element;
|
|
15
17
|
renderCardDetailsForDisabledAccount(): JSX.Element;
|
|
@@ -28,7 +28,7 @@ declare class ProfilecardTrigger extends React.PureComponent<ProfileCardTriggerP
|
|
|
28
28
|
componentDidUpdate(prevProps: ProfileCardTriggerProps): void;
|
|
29
29
|
componentWillUnmount(): void;
|
|
30
30
|
clientFetchProfile: () => void;
|
|
31
|
-
handleClientSuccess(profileData: ProfileCardClientData, reportingLinesData: TeamCentralReportingLinesData): void;
|
|
31
|
+
handleClientSuccess(profileData: ProfileCardClientData, reportingLinesData: TeamCentralReportingLinesData, shouldShowGiveKudos: boolean): void;
|
|
32
32
|
handleClientError(err: any): void;
|
|
33
33
|
filterActions(): ProfileCardAction[];
|
|
34
34
|
renderProfileCard(): JSX.Element;
|
package/dist/types/messages.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ export interface ProfileCardTriggerState {
|
|
|
118
118
|
error?: ProfileCardErrorType;
|
|
119
119
|
data: ProfileCardClientData | null;
|
|
120
120
|
reportingLinesData?: TeamCentralReportingLinesData;
|
|
121
|
+
shouldShowGiveKudos?: boolean;
|
|
122
|
+
teamCentralBaseUrl?: string;
|
|
121
123
|
}
|
|
122
124
|
export interface TeamProfileCardTriggerState {
|
|
123
125
|
visible?: boolean;
|
|
@@ -256,6 +258,8 @@ export interface ProfilecardProps {
|
|
|
256
258
|
avatarUrl?: string;
|
|
257
259
|
fullName?: string;
|
|
258
260
|
meta?: string;
|
|
261
|
+
userId?: string;
|
|
262
|
+
isCurrentUser?: boolean;
|
|
259
263
|
nickname?: string;
|
|
260
264
|
email?: string;
|
|
261
265
|
location?: string;
|
|
@@ -272,6 +276,8 @@ export interface ProfilecardProps {
|
|
|
272
276
|
reportingLinesProfileUrl?: string;
|
|
273
277
|
/** Click handler when user clicks on manager's and direct reports' user avatar, un-clickable otherwise */
|
|
274
278
|
onReportingLinesClick?: (user: ReportingLinesUser) => void;
|
|
279
|
+
isKudosEnabled?: boolean;
|
|
280
|
+
teamCentralBaseUrl?: string;
|
|
275
281
|
disabledAccountMessage?: React.ReactNode;
|
|
276
282
|
hasDisabledAccountLozenge?: boolean;
|
|
277
283
|
customLozenges?: LozengeProps[];
|
|
@@ -302,6 +308,8 @@ export interface ProfileClient {
|
|
|
302
308
|
getProfile: (cloudId: string, userId: string) => Promise<ProfileCardClientData>;
|
|
303
309
|
getTeamProfile: (teamId: string, orgId?: string, fireAnalytics?: (event: Record<string, any>) => void) => Promise<Team>;
|
|
304
310
|
getReportingLines: (userId: string) => Promise<TeamCentralReportingLinesData>;
|
|
311
|
+
shouldShowGiveKudos: () => Promise<boolean>;
|
|
312
|
+
getTeamCentralBaseUrl: () => string | undefined;
|
|
305
313
|
}
|
|
306
314
|
export declare type ProfilecardTriggerPosition = 'bottom-start' | 'bottom' | 'bottom-end' | 'left-start' | 'left' | 'left-end' | 'top-end' | 'top' | 'top-start' | 'right-end' | 'right' | 'right-start';
|
|
307
315
|
export declare type ProfileCardErrorType = {
|
|
@@ -312,8 +320,10 @@ export interface ProfileClientOptions {
|
|
|
312
320
|
gatewayGraphqlUrl?: string;
|
|
313
321
|
cacheSize?: number;
|
|
314
322
|
cacheMaxAge?: number;
|
|
315
|
-
/** Enables Team Central functionality if enabled */
|
|
323
|
+
/** Enables Team Central functionality if enabled e.g. /gateway/api/watermelon/graphql*/
|
|
316
324
|
teamCentralUrl?: string;
|
|
325
|
+
/** URL to the Team Central app e.g. team.atlassian.com */
|
|
326
|
+
teamCentralBaseUrl?: string;
|
|
317
327
|
}
|
|
318
328
|
export interface ClientOverrides {
|
|
319
329
|
userClient?: UserProfileCardClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/profilecard",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.5.0",
|
|
4
4
|
"description": "A React component to display a card with user information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
42
|
-
"@atlaskit/avatar": "^
|
|
43
|
-
"@atlaskit/avatar-group": "^
|
|
42
|
+
"@atlaskit/avatar": "^21.0.0",
|
|
43
|
+
"@atlaskit/avatar-group": "^9.0.0",
|
|
44
44
|
"@atlaskit/button": "^16.3.0",
|
|
45
45
|
"@atlaskit/icon": "^21.10.0",
|
|
46
46
|
"@atlaskit/lozenge": "^11.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/popup": "^1.3.0",
|
|
49
49
|
"@atlaskit/spinner": "^15.0.0",
|
|
50
50
|
"@atlaskit/theme": "^12.1.0",
|
|
51
|
-
"@atlaskit/tokens": "^0.
|
|
51
|
+
"@atlaskit/tokens": "^0.10.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0",
|
|
53
53
|
"date-fns": "^2.17.0",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@atlaskit/docs": "*",
|
|
65
|
-
"@atlaskit/dynamic-table": "^14.
|
|
65
|
+
"@atlaskit/dynamic-table": "^14.6.0",
|
|
66
66
|
"@atlaskit/inline-edit": "^12.0.0",
|
|
67
|
-
"@atlaskit/select": "^15.
|
|
68
|
-
"@atlaskit/util-data-test": "^17.
|
|
67
|
+
"@atlaskit/select": "^15.3.0",
|
|
68
|
+
"@atlaskit/util-data-test": "^17.3.0",
|
|
69
69
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
70
70
|
"@testing-library/react": "^8.0.1",
|
|
71
71
|
"enzyme": "^3.10.0",
|