@atlaskit/profilecard 16.5.0 → 16.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/client/ProfileCardClient.js +2 -2
- package/dist/cjs/client/TeamCentralCardClient.js +14 -9
- package/dist/cjs/components/User/ProfileCard.js +35 -27
- package/dist/cjs/components/User/ProfileCardResourced.js +63 -13
- package/dist/cjs/components/User/ProfileCardTrigger.js +35 -4
- package/dist/cjs/mocks/mock-profile-client.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 +2 -2
- package/dist/es2019/client/TeamCentralCardClient.js +13 -8
- package/dist/es2019/components/User/ProfileCard.js +32 -22
- package/dist/es2019/components/User/ProfileCardResourced.js +51 -11
- package/dist/es2019/components/User/ProfileCardTrigger.js +35 -4
- package/dist/es2019/mocks/mock-profile-client.js +4 -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 +2 -2
- package/dist/esm/client/TeamCentralCardClient.js +14 -9
- package/dist/esm/components/User/ProfileCard.js +37 -27
- package/dist/esm/components/User/ProfileCardResourced.js +57 -13
- package/dist/esm/components/User/ProfileCardTrigger.js +36 -4
- package/dist/esm/mocks/mock-profile-client.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/TeamCentralCardClient.d.ts +6 -2
- package/dist/types/client/graphqlUtils.d.ts +1 -1
- package/dist/types/components/User/ProfileCard.d.ts +6 -4
- package/dist/types/components/User/ProfileCardResourced.d.ts +3 -1
- package/dist/types/components/User/ProfileCardTrigger.d.ts +2 -0
- package/dist/types/types.d.ts +10 -0
- package/package.json +3 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { Suspense } from 'react';
|
|
4
|
+
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
4
5
|
import { AnalyticsName } from '../../internal/analytics';
|
|
5
6
|
import filterActions from '../../internal/filterActions';
|
|
6
7
|
import { CardWrapper } from '../../styled/Card';
|
|
@@ -19,7 +20,9 @@ export default class ProfileCardResourced extends React.PureComponent {
|
|
|
19
20
|
hasError: false,
|
|
20
21
|
error: null,
|
|
21
22
|
data: null,
|
|
22
|
-
reportingLinesData: undefined
|
|
23
|
+
reportingLinesData: undefined,
|
|
24
|
+
isKudosEnabled: false,
|
|
25
|
+
kudosDrawerOpen: false
|
|
23
26
|
});
|
|
24
27
|
|
|
25
28
|
_defineProperty(this, "callAnalytics", (id, options = {}) => {
|
|
@@ -51,12 +54,24 @@ export default class ProfileCardResourced extends React.PureComponent {
|
|
|
51
54
|
hasError: false,
|
|
52
55
|
data: null
|
|
53
56
|
}, () => {
|
|
54
|
-
const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId), this.props.resourceClient.getReportingLines(userId)]);
|
|
55
|
-
requests.then(res => this.handleClientSuccess(res
|
|
57
|
+
const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos()]);
|
|
58
|
+
requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
|
|
56
59
|
});
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
_defineProperty(this, "filterActions", () => filterActions(this.props.actions, this.state.data));
|
|
63
|
+
|
|
64
|
+
_defineProperty(this, "openKudosDrawer", () => {
|
|
65
|
+
this.setState({
|
|
66
|
+
kudosDrawerOpen: true
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
_defineProperty(this, "closeKudosDrawer", () => {
|
|
71
|
+
this.setState({
|
|
72
|
+
kudosDrawerOpen: false
|
|
73
|
+
});
|
|
74
|
+
});
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
componentDidMount() {
|
|
@@ -89,7 +104,7 @@ export default class ProfileCardResourced extends React.PureComponent {
|
|
|
89
104
|
this._isMounted = false;
|
|
90
105
|
}
|
|
91
106
|
|
|
92
|
-
handleClientSuccess(profileData, reportingLinesData) {
|
|
107
|
+
handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
93
108
|
if (!this._isMounted) {
|
|
94
109
|
return;
|
|
95
110
|
}
|
|
@@ -98,7 +113,8 @@ export default class ProfileCardResourced extends React.PureComponent {
|
|
|
98
113
|
isLoading: false,
|
|
99
114
|
hasError: false,
|
|
100
115
|
data: profileData,
|
|
101
|
-
reportingLinesData
|
|
116
|
+
reportingLinesData,
|
|
117
|
+
isKudosEnabled: shouldShowGiveKudos
|
|
102
118
|
});
|
|
103
119
|
}
|
|
104
120
|
|
|
@@ -120,11 +136,15 @@ export default class ProfileCardResourced extends React.PureComponent {
|
|
|
120
136
|
hasError,
|
|
121
137
|
error,
|
|
122
138
|
data,
|
|
123
|
-
reportingLinesData
|
|
139
|
+
reportingLinesData,
|
|
140
|
+
isKudosEnabled
|
|
124
141
|
} = this.state;
|
|
125
142
|
const {
|
|
126
143
|
analytics,
|
|
127
|
-
onReportingLinesClick
|
|
144
|
+
onReportingLinesClick,
|
|
145
|
+
cloudId,
|
|
146
|
+
userId,
|
|
147
|
+
addFlag
|
|
128
148
|
} = this.props;
|
|
129
149
|
const isFetchingOrNotStartToFetchYet = isLoading === true || isLoading === undefined;
|
|
130
150
|
|
|
@@ -144,11 +164,31 @@ export default class ProfileCardResourced extends React.PureComponent {
|
|
|
144
164
|
analytics,
|
|
145
165
|
reportingLines: reportingLinesData,
|
|
146
166
|
onReportingLinesClick: onReportingLinesClick,
|
|
147
|
-
|
|
167
|
+
cloudId,
|
|
168
|
+
userId,
|
|
169
|
+
addFlag,
|
|
170
|
+
...data,
|
|
171
|
+
isKudosEnabled,
|
|
172
|
+
teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl(),
|
|
173
|
+
openKudosDrawer: this.openKudosDrawer
|
|
148
174
|
};
|
|
149
|
-
return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(
|
|
175
|
+
return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(React.Fragment, null, isKudosEnabled && /*#__PURE__*/React.createElement(Suspense, {
|
|
176
|
+
fallback: null
|
|
177
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
178
|
+
isOpen: this.state.kudosDrawerOpen,
|
|
179
|
+
recipient: {
|
|
180
|
+
type: KudosType.INDIVIDUAL,
|
|
181
|
+
recipientId: this.props.userId
|
|
182
|
+
},
|
|
183
|
+
analytics: this.props.analytics,
|
|
184
|
+
analyticsSource: "profile-card",
|
|
185
|
+
teamCentralBaseUrl: newProps.teamCentralBaseUrl,
|
|
186
|
+
cloudId: this.props.cloudId,
|
|
187
|
+
addFlag: this.props.addFlag,
|
|
188
|
+
onClose: this.closeKudosDrawer
|
|
189
|
+
})), /*#__PURE__*/React.createElement(ProfileCard, _extends({}, newProps, {
|
|
150
190
|
actions: this.filterActions()
|
|
151
|
-
})));
|
|
191
|
+
}))));
|
|
152
192
|
}
|
|
153
193
|
|
|
154
194
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import React, { Suspense } from 'react';
|
|
4
|
+
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
4
5
|
import Popup from '@atlaskit/popup';
|
|
5
6
|
import { layers } from '@atlaskit/theme/constants';
|
|
6
7
|
import filterActions from '../../internal/filterActions';
|
|
@@ -74,7 +75,8 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
74
75
|
data: null,
|
|
75
76
|
reportingLinesData: undefined,
|
|
76
77
|
shouldShowGiveKudos: false,
|
|
77
|
-
teamCentralBaseUrl: undefined
|
|
78
|
+
teamCentralBaseUrl: undefined,
|
|
79
|
+
kudosDrawerOpen: false
|
|
78
80
|
});
|
|
79
81
|
|
|
80
82
|
_defineProperty(this, "clientFetchProfile", () => {
|
|
@@ -104,6 +106,19 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
104
106
|
});
|
|
105
107
|
});
|
|
106
108
|
|
|
109
|
+
_defineProperty(this, "openKudosDrawer", () => {
|
|
110
|
+
this.hideProfilecard();
|
|
111
|
+
this.setState({
|
|
112
|
+
kudosDrawerOpen: true
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
_defineProperty(this, "closeKudosDrawer", () => {
|
|
117
|
+
this.setState({
|
|
118
|
+
kudosDrawerOpen: false
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
107
122
|
_defineProperty(this, "renderCard", () => {
|
|
108
123
|
const {
|
|
109
124
|
isLoading
|
|
@@ -186,7 +201,9 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
186
201
|
reportingLines: this.state.reportingLinesData,
|
|
187
202
|
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
188
203
|
isKudosEnabled: this.state.shouldShowGiveKudos,
|
|
189
|
-
teamCentralBaseUrl: this.state.teamCentralBaseUrl
|
|
204
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl,
|
|
205
|
+
cloudId: this.props.cloudId,
|
|
206
|
+
openKudosDrawer: this.openKudosDrawer
|
|
190
207
|
};
|
|
191
208
|
const wrapperProps = this.props.trigger === 'hover' ? {
|
|
192
209
|
onMouseEnter: this.showProfilecard,
|
|
@@ -203,7 +220,7 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
203
220
|
}
|
|
204
221
|
|
|
205
222
|
renderWithTrigger() {
|
|
206
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
|
223
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
207
224
|
isOpen: !!this.state.visible,
|
|
208
225
|
onClose: this.hideProfilecard,
|
|
209
226
|
placement: this.props.position,
|
|
@@ -220,7 +237,21 @@ class ProfilecardTrigger extends React.PureComponent {
|
|
|
220
237
|
},
|
|
221
238
|
zIndex: layers.modal(),
|
|
222
239
|
shouldUseCaptureOnOutsideClick: true
|
|
223
|
-
})
|
|
240
|
+
}), this.state.shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
241
|
+
fallback: null
|
|
242
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
243
|
+
isOpen: this.state.kudosDrawerOpen,
|
|
244
|
+
recipient: {
|
|
245
|
+
type: KudosType.INDIVIDUAL,
|
|
246
|
+
recipientId: this.props.userId
|
|
247
|
+
},
|
|
248
|
+
analytics: this.props.analytics,
|
|
249
|
+
analyticsSource: "profile-card",
|
|
250
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl,
|
|
251
|
+
cloudId: this.props.cloudId,
|
|
252
|
+
addFlag: this.props.addFlag,
|
|
253
|
+
onClose: this.closeKudosDrawer
|
|
254
|
+
})));
|
|
224
255
|
}
|
|
225
256
|
|
|
226
257
|
render() {
|
|
@@ -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.6.0",
|
|
39
39
|
...attributes,
|
|
40
40
|
firedAt: getPageTime()
|
|
41
41
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -58,11 +58,11 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
58
58
|
}, {
|
|
59
59
|
key: "shouldShowGiveKudos",
|
|
60
60
|
value: function shouldShowGiveKudos() {
|
|
61
|
-
var _this$tcClient4, _this$tcClient5;
|
|
61
|
+
var _this$tcClient4, _this$tcClient5, _this$tcClient6;
|
|
62
62
|
|
|
63
63
|
// Check if the kudos feature enabled and if the user has TC
|
|
64
64
|
// if the user does not have TC the tc client will be undefined.
|
|
65
|
-
return ((_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);
|
|
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', (_this$tcClient6 = this.tcClient) === null || _this$tcClient6 === void 0 ? void 0 : _this$tcClient6.options.productIdentifier)) || Promise.resolve(false);
|
|
66
66
|
}
|
|
67
67
|
}]);
|
|
68
68
|
|
|
@@ -22,11 +22,12 @@ var buildReportingLinesQuery = function buildReportingLinesQuery(aaid) {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
var buildCheckFeatureFlagQuery = function buildCheckFeatureFlagQuery(featureKey) {
|
|
25
|
+
var buildCheckFeatureFlagQuery = function buildCheckFeatureFlagQuery(featureKey, context) {
|
|
26
26
|
return {
|
|
27
|
-
query: "\n query isFeatureKeyEnabled($featureKey: String
|
|
27
|
+
query: "\n query isFeatureKeyEnabled($featureKey: String!, $context: [IsFeatureEnabledContextInput]) {\n isFeatureEnabled(featureKey: $featureKey, context: $context) {\n enabled\n }\n }\n ",
|
|
28
28
|
variables: {
|
|
29
|
-
featureKey: featureKey
|
|
29
|
+
featureKey: featureKey,
|
|
30
|
+
context: context
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
};
|
|
@@ -59,7 +60,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
59
60
|
_createClass(TeamCentralCardClient, [{
|
|
60
61
|
key: "makeFeatureFlagCheckRequest",
|
|
61
62
|
value: function () {
|
|
62
|
-
var _makeFeatureFlagCheckRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(featureKey) {
|
|
63
|
+
var _makeFeatureFlagCheckRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(featureKey, context) {
|
|
63
64
|
var query, response;
|
|
64
65
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
65
66
|
while (1) {
|
|
@@ -73,7 +74,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
73
74
|
throw new Error('options.teamCentralUrl is a required parameter for retrieving Team Central data');
|
|
74
75
|
|
|
75
76
|
case 2:
|
|
76
|
-
query = buildCheckFeatureFlagQuery(featureKey);
|
|
77
|
+
query = buildCheckFeatureFlagQuery(featureKey, context);
|
|
77
78
|
_context.next = 5;
|
|
78
79
|
return graphqlQuery(this.options.teamCentralUrl, query);
|
|
79
80
|
|
|
@@ -89,7 +90,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
89
90
|
}, _callee, this);
|
|
90
91
|
}));
|
|
91
92
|
|
|
92
|
-
function makeFeatureFlagCheckRequest(_x) {
|
|
93
|
+
function makeFeatureFlagCheckRequest(_x, _x2) {
|
|
93
94
|
return _makeFeatureFlagCheckRequest.apply(this, arguments);
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -128,7 +129,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
128
129
|
}, _callee2, this);
|
|
129
130
|
}));
|
|
130
131
|
|
|
131
|
-
function makeRequest(
|
|
132
|
+
function makeRequest(_x3) {
|
|
132
133
|
return _makeRequest.apply(this, arguments);
|
|
133
134
|
}
|
|
134
135
|
|
|
@@ -182,7 +183,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
182
183
|
}
|
|
183
184
|
}, {
|
|
184
185
|
key: "getFlagEnabled",
|
|
185
|
-
value: function getFlagEnabled(featureKey) {
|
|
186
|
+
value: function getFlagEnabled(featureKey, productIdentifier) {
|
|
186
187
|
var _this3 = this;
|
|
187
188
|
|
|
188
189
|
if (!featureKey) {
|
|
@@ -197,8 +198,12 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
|
|
|
197
198
|
return Promise.resolve(false);
|
|
198
199
|
}
|
|
199
200
|
|
|
201
|
+
var context = [{
|
|
202
|
+
key: 'productIdentifier',
|
|
203
|
+
value: productIdentifier || 'unset'
|
|
204
|
+
}];
|
|
200
205
|
return new Promise(function (resolve) {
|
|
201
|
-
_this3.makeFeatureFlagCheckRequest(featureKey).then(function (enabled) {
|
|
206
|
+
_this3.makeFeatureFlagCheckRequest(featureKey, context).then(function (enabled) {
|
|
202
207
|
_this3.featureFlagKeys.set(featureKey, enabled);
|
|
203
208
|
|
|
204
209
|
resolve(enabled);
|
|
@@ -61,14 +61,44 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "kudosUrl", function () {
|
|
65
|
+
var recipientId = _this.props.userId && "&recipientId=".concat(_this.props.userId) || '';
|
|
66
|
+
var cloudId = _this.props.cloudId && "&cloudId=".concat(_this.props.cloudId) || '';
|
|
67
|
+
return "".concat(_this.props.teamCentralBaseUrl, "/kudos/give?type=individual").concat(recipientId).concat(cloudId);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "kudosButtonCallback", function () {
|
|
71
|
+
if (_this.props.openKudosDrawer) {
|
|
72
|
+
_this.props.openKudosDrawer();
|
|
67
73
|
} else {
|
|
68
|
-
window.open(
|
|
74
|
+
window.open(_this.kudosUrl());
|
|
69
75
|
}
|
|
70
76
|
});
|
|
71
77
|
|
|
78
|
+
_defineProperty(_assertThisInitialized(_this), "renderButton", function (action, idx) {
|
|
79
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
80
|
+
appearance: idx === 0 ? 'default' : 'subtle',
|
|
81
|
+
key: action.id || idx,
|
|
82
|
+
onClick: function onClick(event) {
|
|
83
|
+
_this.callAnalytics(AnalyticsName.PROFILE_CARD_CLICK, {
|
|
84
|
+
id: action.id || null,
|
|
85
|
+
duration: _this.durationSince(_this.timeOpen)
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (action.callback && isBasicClick(event)) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
|
|
91
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
92
|
+
args[_key - 1] = arguments[_key];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
action.callback.apply(action, [event].concat(args));
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
href: action.link
|
|
99
|
+
}, action.label);
|
|
100
|
+
});
|
|
101
|
+
|
|
72
102
|
_this.timeOpen = null;
|
|
73
103
|
|
|
74
104
|
_this.clientFetchProfile = function () {
|
|
@@ -108,9 +138,9 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
108
138
|
label: /*#__PURE__*/React.createElement(FormattedMessage, messages.giveKudosButton),
|
|
109
139
|
id: 'give-kudos',
|
|
110
140
|
callback: function callback() {
|
|
111
|
-
_this3.
|
|
141
|
+
_this3.kudosButtonCallback();
|
|
112
142
|
},
|
|
113
|
-
link: this.
|
|
143
|
+
link: this.kudosUrl()
|
|
114
144
|
};
|
|
115
145
|
return actions.concat([kudosAction]);
|
|
116
146
|
}
|
|
@@ -128,27 +158,7 @@ var Profilecard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
128
158
|
|
|
129
159
|
var actions = this.getActions();
|
|
130
160
|
return /*#__PURE__*/React.createElement(ActionButtonGroup, null, actions.map(function (action, idx) {
|
|
131
|
-
return
|
|
132
|
-
appearance: idx === 0 ? 'default' : 'subtle',
|
|
133
|
-
key: action.id || idx,
|
|
134
|
-
onClick: function onClick(event) {
|
|
135
|
-
_this4.callAnalytics(AnalyticsName.PROFILE_CARD_CLICK, {
|
|
136
|
-
id: action.id || null,
|
|
137
|
-
duration: _this4.durationSince(_this4.timeOpen)
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
if (action.callback && isBasicClick(event)) {
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
|
|
143
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
144
|
-
args[_key - 1] = arguments[_key];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
action.callback.apply(action, [event].concat(args));
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
href: action.link
|
|
151
|
-
}, action.label);
|
|
161
|
+
return _this4.renderButton(action, idx);
|
|
152
162
|
}));
|
|
153
163
|
}
|
|
154
164
|
}, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
5
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -15,7 +16,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
15
16
|
|
|
16
17
|
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; } }
|
|
17
18
|
|
|
18
|
-
import React from 'react';
|
|
19
|
+
import React, { Suspense } from 'react';
|
|
20
|
+
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
19
21
|
import { AnalyticsName } from '../../internal/analytics';
|
|
20
22
|
import filterActions from '../../internal/filterActions';
|
|
21
23
|
import { CardWrapper } from '../../styled/Card';
|
|
@@ -47,7 +49,9 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
47
49
|
hasError: false,
|
|
48
50
|
error: null,
|
|
49
51
|
data: null,
|
|
50
|
-
reportingLinesData: undefined
|
|
52
|
+
reportingLinesData: undefined,
|
|
53
|
+
isKudosEnabled: false,
|
|
54
|
+
kudosDrawerOpen: false
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
_defineProperty(_assertThisInitialized(_this), "callAnalytics", function (id) {
|
|
@@ -75,9 +79,11 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
75
79
|
hasError: false,
|
|
76
80
|
data: null
|
|
77
81
|
}, function () {
|
|
78
|
-
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId), _this.props.resourceClient.getReportingLines(userId)]);
|
|
82
|
+
var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
|
|
79
83
|
requests.then(function (res) {
|
|
80
|
-
|
|
84
|
+
var _this2;
|
|
85
|
+
|
|
86
|
+
return (_this2 = _this).handleClientSuccess.apply(_this2, _toConsumableArray(res));
|
|
81
87
|
}, function (err) {
|
|
82
88
|
return _this.handleClientError(err);
|
|
83
89
|
}).catch(function (err) {
|
|
@@ -90,6 +96,18 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
90
96
|
return filterActions(_this.props.actions, _this.state.data);
|
|
91
97
|
});
|
|
92
98
|
|
|
99
|
+
_defineProperty(_assertThisInitialized(_this), "openKudosDrawer", function () {
|
|
100
|
+
_this.setState({
|
|
101
|
+
kudosDrawerOpen: true
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
_defineProperty(_assertThisInitialized(_this), "closeKudosDrawer", function () {
|
|
106
|
+
_this.setState({
|
|
107
|
+
kudosDrawerOpen: false
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
93
111
|
return _this;
|
|
94
112
|
}
|
|
95
113
|
|
|
@@ -125,7 +143,7 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
125
143
|
}
|
|
126
144
|
}, {
|
|
127
145
|
key: "handleClientSuccess",
|
|
128
|
-
value: function handleClientSuccess(profileData, reportingLinesData) {
|
|
146
|
+
value: function handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
|
|
129
147
|
if (!this._isMounted) {
|
|
130
148
|
return;
|
|
131
149
|
}
|
|
@@ -134,7 +152,8 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
134
152
|
isLoading: false,
|
|
135
153
|
hasError: false,
|
|
136
154
|
data: profileData,
|
|
137
|
-
reportingLinesData: reportingLinesData
|
|
155
|
+
reportingLinesData: reportingLinesData,
|
|
156
|
+
isKudosEnabled: shouldShowGiveKudos
|
|
138
157
|
});
|
|
139
158
|
}
|
|
140
159
|
}, {
|
|
@@ -158,10 +177,14 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
158
177
|
hasError = _this$state.hasError,
|
|
159
178
|
error = _this$state.error,
|
|
160
179
|
data = _this$state.data,
|
|
161
|
-
reportingLinesData = _this$state.reportingLinesData
|
|
180
|
+
reportingLinesData = _this$state.reportingLinesData,
|
|
181
|
+
isKudosEnabled = _this$state.isKudosEnabled;
|
|
162
182
|
var _this$props3 = this.props,
|
|
163
183
|
analytics = _this$props3.analytics,
|
|
164
|
-
onReportingLinesClick = _this$props3.onReportingLinesClick
|
|
184
|
+
onReportingLinesClick = _this$props3.onReportingLinesClick,
|
|
185
|
+
cloudId = _this$props3.cloudId,
|
|
186
|
+
userId = _this$props3.userId,
|
|
187
|
+
addFlag = _this$props3.addFlag;
|
|
165
188
|
var isFetchingOrNotStartToFetchYet = isLoading === true || isLoading === undefined;
|
|
166
189
|
|
|
167
190
|
if (isFetchingOrNotStartToFetchYet) {
|
|
@@ -173,18 +196,39 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
173
196
|
}));
|
|
174
197
|
}
|
|
175
198
|
|
|
176
|
-
var newProps = _objectSpread({
|
|
199
|
+
var newProps = _objectSpread(_objectSpread({
|
|
177
200
|
hasError: hasError,
|
|
178
201
|
errorType: error,
|
|
179
202
|
clientFetchProfile: this.clientFetchProfile,
|
|
180
203
|
analytics: analytics,
|
|
181
204
|
reportingLines: reportingLinesData,
|
|
182
|
-
onReportingLinesClick: onReportingLinesClick
|
|
183
|
-
|
|
205
|
+
onReportingLinesClick: onReportingLinesClick,
|
|
206
|
+
cloudId: cloudId,
|
|
207
|
+
userId: userId,
|
|
208
|
+
addFlag: addFlag
|
|
209
|
+
}, data), {}, {
|
|
210
|
+
isKudosEnabled: isKudosEnabled,
|
|
211
|
+
teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl(),
|
|
212
|
+
openKudosDrawer: this.openKudosDrawer
|
|
213
|
+
});
|
|
184
214
|
|
|
185
|
-
return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(
|
|
215
|
+
return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(React.Fragment, null, isKudosEnabled && /*#__PURE__*/React.createElement(Suspense, {
|
|
216
|
+
fallback: null
|
|
217
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
218
|
+
isOpen: this.state.kudosDrawerOpen,
|
|
219
|
+
recipient: {
|
|
220
|
+
type: KudosType.INDIVIDUAL,
|
|
221
|
+
recipientId: this.props.userId
|
|
222
|
+
},
|
|
223
|
+
analytics: this.props.analytics,
|
|
224
|
+
analyticsSource: "profile-card",
|
|
225
|
+
teamCentralBaseUrl: newProps.teamCentralBaseUrl,
|
|
226
|
+
cloudId: this.props.cloudId,
|
|
227
|
+
addFlag: this.props.addFlag,
|
|
228
|
+
onClose: this.closeKudosDrawer
|
|
229
|
+
})), /*#__PURE__*/React.createElement(ProfileCard, _extends({}, newProps, {
|
|
186
230
|
actions: this.filterActions()
|
|
187
|
-
})));
|
|
231
|
+
}))));
|
|
188
232
|
}
|
|
189
233
|
}]);
|
|
190
234
|
|
|
@@ -19,6 +19,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
19
19
|
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; } }
|
|
20
20
|
|
|
21
21
|
import React, { Suspense } from 'react';
|
|
22
|
+
import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
|
|
22
23
|
import Popup from '@atlaskit/popup';
|
|
23
24
|
import { layers } from '@atlaskit/theme/constants';
|
|
24
25
|
import _filterActions from '../../internal/filterActions';
|
|
@@ -106,7 +107,8 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
106
107
|
data: null,
|
|
107
108
|
reportingLinesData: undefined,
|
|
108
109
|
shouldShowGiveKudos: false,
|
|
109
|
-
teamCentralBaseUrl: undefined
|
|
110
|
+
teamCentralBaseUrl: undefined,
|
|
111
|
+
kudosDrawerOpen: false
|
|
110
112
|
});
|
|
111
113
|
|
|
112
114
|
_defineProperty(_assertThisInitialized(_this), "clientFetchProfile", function () {
|
|
@@ -142,6 +144,20 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
142
144
|
});
|
|
143
145
|
});
|
|
144
146
|
|
|
147
|
+
_defineProperty(_assertThisInitialized(_this), "openKudosDrawer", function () {
|
|
148
|
+
_this.hideProfilecard();
|
|
149
|
+
|
|
150
|
+
_this.setState({
|
|
151
|
+
kudosDrawerOpen: true
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
_defineProperty(_assertThisInitialized(_this), "closeKudosDrawer", function () {
|
|
156
|
+
_this.setState({
|
|
157
|
+
kudosDrawerOpen: false
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
145
161
|
_defineProperty(_assertThisInitialized(_this), "renderCard", function () {
|
|
146
162
|
var isLoading = _this.state.isLoading;
|
|
147
163
|
|
|
@@ -229,7 +245,9 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
229
245
|
reportingLines: this.state.reportingLinesData,
|
|
230
246
|
onReportingLinesClick: this.props.onReportingLinesClick,
|
|
231
247
|
isKudosEnabled: this.state.shouldShowGiveKudos,
|
|
232
|
-
teamCentralBaseUrl: this.state.teamCentralBaseUrl
|
|
248
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl,
|
|
249
|
+
cloudId: this.props.cloudId,
|
|
250
|
+
openKudosDrawer: this.openKudosDrawer
|
|
233
251
|
});
|
|
234
252
|
|
|
235
253
|
var wrapperProps = this.props.trigger === 'hover' ? {
|
|
@@ -250,7 +268,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
250
268
|
value: function renderWithTrigger() {
|
|
251
269
|
var _this3 = this;
|
|
252
270
|
|
|
253
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
|
271
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popup, {
|
|
254
272
|
isOpen: !!this.state.visible,
|
|
255
273
|
onClose: this.hideProfilecard,
|
|
256
274
|
placement: this.props.position,
|
|
@@ -266,7 +284,21 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
266
284
|
},
|
|
267
285
|
zIndex: layers.modal(),
|
|
268
286
|
shouldUseCaptureOnOutsideClick: true
|
|
269
|
-
})
|
|
287
|
+
}), this.state.shouldShowGiveKudos && /*#__PURE__*/React.createElement(Suspense, {
|
|
288
|
+
fallback: null
|
|
289
|
+
}, /*#__PURE__*/React.createElement(GiveKudosLauncherLazy, {
|
|
290
|
+
isOpen: this.state.kudosDrawerOpen,
|
|
291
|
+
recipient: {
|
|
292
|
+
type: KudosType.INDIVIDUAL,
|
|
293
|
+
recipientId: this.props.userId
|
|
294
|
+
},
|
|
295
|
+
analytics: this.props.analytics,
|
|
296
|
+
analyticsSource: "profile-card",
|
|
297
|
+
teamCentralBaseUrl: this.state.teamCentralBaseUrl,
|
|
298
|
+
cloudId: this.props.cloudId,
|
|
299
|
+
addFlag: this.props.addFlag,
|
|
300
|
+
onClose: this.closeKudosDrawer
|
|
301
|
+
})));
|
|
270
302
|
}
|
|
271
303
|
}, {
|
|
272
304
|
key: "render",
|
|
@@ -98,6 +98,11 @@ export default function getMockProfileClient(BaseProfileClient, modifyResponse)
|
|
|
98
98
|
}, timeout);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "getFlagEnabled",
|
|
103
|
+
value: function getFlagEnabled(featureKey) {
|
|
104
|
+
return Promise.resolve(true);
|
|
105
|
+
}
|
|
101
106
|
}]);
|
|
102
107
|
|
|
103
108
|
return MockTeamCentralClient;
|
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 a {\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 span {\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.6.0"
|
|
49
49
|
}, attributes), {}, {
|
|
50
50
|
firedAt: getPageTime()
|
|
51
51
|
})
|