@atlaskit/reactions 21.3.3 → 21.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 +28 -0
- package/dist/cjs/analytics/constants.js +9 -0
- package/dist/cjs/analytics/ufo.js +10 -2
- package/dist/cjs/client/MockReactionsClient.js +202 -107
- package/dist/cjs/client/index.js +33 -1
- package/dist/cjs/components/Counter.js +1 -0
- package/dist/cjs/components/Reaction.js +7 -4
- package/dist/cjs/components/ReactionPicker.js +26 -7
- package/dist/cjs/components/Reactions.js +1 -1
- package/dist/cjs/components/UfoErrorBoundary.js +13 -3
- package/dist/cjs/containers/ConnectedReactionPicker.js +9 -0
- package/dist/cjs/containers/ConnectedReactionsView.js +15 -7
- package/dist/cjs/shared/constants.js +13 -0
- package/dist/cjs/shared/index.js +16 -0
- package/dist/cjs/store/ReactionsStore.js +57 -11
- package/dist/cjs/types/ReactionStatus.js +4 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/constants.js +2 -0
- package/dist/es2019/analytics/ufo.js +3 -1
- package/dist/es2019/client/MockReactionsClient.js +90 -86
- package/dist/es2019/client/index.js +2 -1
- package/dist/es2019/components/Counter.js +2 -1
- package/dist/es2019/components/Reaction.js +5 -2
- package/dist/es2019/components/ReactionPicker.js +26 -7
- package/dist/es2019/components/Reactions.js +1 -1
- package/dist/es2019/components/UfoErrorBoundary.js +13 -3
- package/dist/es2019/containers/ConnectedReactionPicker.js +9 -0
- package/dist/es2019/containers/ConnectedReactionsView.js +15 -9
- package/dist/es2019/shared/constants.js +4 -0
- package/dist/es2019/shared/index.js +2 -0
- package/dist/es2019/store/ReactionsStore.js +56 -11
- package/dist/es2019/types/ReactionStatus.js +3 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/constants.js +2 -0
- package/dist/esm/analytics/ufo.js +5 -1
- package/dist/esm/client/MockReactionsClient.js +196 -102
- package/dist/esm/client/index.js +2 -1
- package/dist/esm/components/Counter.js +2 -1
- package/dist/esm/components/Reaction.js +7 -4
- package/dist/esm/components/ReactionPicker.js +26 -7
- package/dist/esm/components/Reactions.js +1 -1
- package/dist/esm/components/UfoErrorBoundary.js +13 -3
- package/dist/esm/containers/ConnectedReactionPicker.js +9 -0
- package/dist/esm/containers/ConnectedReactionsView.js +15 -7
- package/dist/esm/shared/constants.js +4 -0
- package/dist/esm/shared/index.js +2 -0
- package/dist/esm/store/ReactionsStore.js +58 -11
- package/dist/esm/types/ReactionStatus.js +3 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/constants.d.ts +1 -0
- package/dist/types/analytics/ufo.d.ts +1 -0
- package/dist/types/client/MockReactionsClient.d.ts +6 -13
- package/dist/types/client/ReactionClient.d.ts +5 -2
- package/dist/types/client/index.d.ts +1 -0
- package/dist/types/components/Counter.d.ts +18 -0
- package/dist/types/components/EmojiButton.d.ts +9 -0
- package/dist/types/components/FlashAnimation.d.ts +7 -2
- package/dist/types/components/Reaction.d.ts +26 -7
- package/dist/types/components/ReactionPicker.d.ts +36 -1
- package/dist/types/components/ReactionTooltip.d.ts +7 -2
- package/dist/types/components/Reactions.d.ts +42 -8
- package/dist/types/components/Selector.d.ts +12 -0
- package/dist/types/components/ShowMore.d.ts +12 -0
- package/dist/types/components/Trigger.d.ts +9 -0
- package/dist/types/components/UfoErrorBoundary.d.ts +4 -3
- package/dist/types/containers/ConnectedReactionPicker.d.ts +9 -3
- package/dist/types/containers/ConnectedReactionsView.d.ts +12 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/constants.d.ts +3 -0
- package/dist/types/shared/index.d.ts +1 -0
- package/dist/types/store/ReactionsStore.d.ts +44 -7
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/types/Actions.d.ts +17 -4
- package/dist/types/types/ReactionSource.d.ts +3 -0
- package/dist/types/types/ReactionStatus.d.ts +3 -0
- package/dist/types/types/ReactionsState.d.ts +3 -0
- package/dist/types/types/index.d.ts +1 -1
- package/docs/0-intro.tsx +118 -27
- package/docs/1-connected-reaction-picker.tsx +133 -0
- package/docs/2-connected-reactions-view.tsx +130 -0
- package/docs/3-reactions-store.tsx +71 -0
- package/docs/4-reaction-service-client.tsx +42 -0
- package/extract-react-type/ConnectedReactionPicker.ts +8 -0
- package/extract-react-type/ConnectedReactionsView.ts +8 -0
- package/extract-react-type/Reaction.ts +8 -0
- package/extract-react-type/Reactions.ts +8 -0
- package/extract-react-type/actions.ts +8 -0
- package/extract-react-type/reactionClient.ts +8 -0
- package/extract-react-type/reactionsStore.ts +8 -0
- package/package.json +8 -7
|
@@ -4,6 +4,11 @@ import * as Types from '../types';
|
|
|
4
4
|
import { batch, batchByKey } from './batched';
|
|
5
5
|
import * as utils from './utils';
|
|
6
6
|
import { isRealErrorFromService } from './utils';
|
|
7
|
+
import { SAMPLING_RATE_REACTIONS_RENDERED_EXP } from '../analytics/constants';
|
|
8
|
+
import { sampledReactionsRendered } from '../analytics/ufo';
|
|
9
|
+
/**
|
|
10
|
+
* store main structure
|
|
11
|
+
*/
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Set of all available UFO experiences relating to reaction element
|
|
@@ -20,15 +25,19 @@ export const ufoExperiences = {
|
|
|
20
25
|
remove: Analytics.UFO.ReactionsRemove,
|
|
21
26
|
|
|
22
27
|
/**
|
|
23
|
-
* Experience when the list of reactions gets rendered
|
|
28
|
+
* Experience when the list of reactions gets rendered with sampling
|
|
24
29
|
*/
|
|
25
|
-
render:
|
|
30
|
+
render: instanceId => sampledReactionsRendered(instanceId),
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Experience when a reaction details gets fetched
|
|
29
34
|
*/
|
|
30
35
|
fetchDetails: Analytics.UFO.ReactionDetailsFetch
|
|
31
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Collection of methods to manage internal state across the different Reaction container components ConnectedReactionPicker and ConnectedReactionsView
|
|
39
|
+
*/
|
|
40
|
+
|
|
32
41
|
export class MemoryReactionsStore {
|
|
33
42
|
constructor(client, state = {
|
|
34
43
|
reactions: {},
|
|
@@ -131,7 +140,15 @@ export class MemoryReactionsStore {
|
|
|
131
140
|
|
|
132
141
|
exp.failure({
|
|
133
142
|
metadata: {
|
|
134
|
-
error
|
|
143
|
+
error,
|
|
144
|
+
source: 'Reaction-Store',
|
|
145
|
+
data: {
|
|
146
|
+
containerAri,
|
|
147
|
+
ari,
|
|
148
|
+
emojiId,
|
|
149
|
+
metadata: this.metadata
|
|
150
|
+
},
|
|
151
|
+
reason: 'addReaction fetch failed'
|
|
135
152
|
}
|
|
136
153
|
});
|
|
137
154
|
}
|
|
@@ -157,7 +174,15 @@ export class MemoryReactionsStore {
|
|
|
157
174
|
// ufo add reaction failure
|
|
158
175
|
exp.failure({
|
|
159
176
|
metadata: {
|
|
160
|
-
error
|
|
177
|
+
error,
|
|
178
|
+
source: 'Reaction-Store',
|
|
179
|
+
data: {
|
|
180
|
+
containerAri,
|
|
181
|
+
ari,
|
|
182
|
+
emojiId,
|
|
183
|
+
metadata: this.metadata
|
|
184
|
+
},
|
|
185
|
+
reason: 'deleteReaction fetch failed'
|
|
161
186
|
}
|
|
162
187
|
});
|
|
163
188
|
});
|
|
@@ -172,10 +197,13 @@ export class MemoryReactionsStore {
|
|
|
172
197
|
* TODO:
|
|
173
198
|
* All reactions are usually fetched in a single call to reactions-service. Need to check why "getReactions" gets called randomly 1-2 times everytime on each fetch request despite using same containerAri.
|
|
174
199
|
*/
|
|
175
|
-
const
|
|
200
|
+
const sampledExp = ufoExperiences.render(containerAri);
|
|
201
|
+
const arisArr = aris.reduce(utils.flattenAris); // ufo start reaction experience
|
|
176
202
|
|
|
177
|
-
|
|
178
|
-
|
|
203
|
+
sampledExp.start({
|
|
204
|
+
samplingRate: SAMPLING_RATE_REACTIONS_RENDERED_EXP
|
|
205
|
+
});
|
|
206
|
+
this.client.getReactions(containerAri, arisArr).then(value => {
|
|
179
207
|
Object.keys(value).map(ari => {
|
|
180
208
|
const reactionsState = this.getReactionsState(containerAri, ari);
|
|
181
209
|
const reactions = reactionsState && reactionsState.status === Types.ReactionStatus.ready ? reactionsState.reactions : undefined;
|
|
@@ -186,14 +214,24 @@ export class MemoryReactionsStore {
|
|
|
186
214
|
Analytics.createAndFireSafe(this.createAnalyticsEvent, Analytics.createRestSucceededEvent, 'getReactions');
|
|
187
215
|
}
|
|
188
216
|
|
|
189
|
-
|
|
217
|
+
sampledExp.success();
|
|
190
218
|
}).catch(error => {
|
|
191
219
|
if (isRealErrorFromService(error.code)) {
|
|
192
220
|
if (this.createAnalyticsEvent) {
|
|
193
221
|
Analytics.createAndFireSafe(this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'getReactions', error.code);
|
|
194
222
|
}
|
|
195
223
|
|
|
196
|
-
|
|
224
|
+
sampledExp.failure({
|
|
225
|
+
metadata: {
|
|
226
|
+
error,
|
|
227
|
+
source: 'Reaction-Store',
|
|
228
|
+
data: {
|
|
229
|
+
containerAri,
|
|
230
|
+
aris: arisArr.join(',')
|
|
231
|
+
},
|
|
232
|
+
reason: 'getReactions fetch failed'
|
|
233
|
+
}
|
|
234
|
+
});
|
|
197
235
|
return Promise.reject(error);
|
|
198
236
|
}
|
|
199
237
|
});
|
|
@@ -214,7 +252,14 @@ export class MemoryReactionsStore {
|
|
|
214
252
|
// ufo get reaction details failure
|
|
215
253
|
exp.failure({
|
|
216
254
|
metadata: {
|
|
217
|
-
error
|
|
255
|
+
error,
|
|
256
|
+
source: 'Reaction-Store',
|
|
257
|
+
data: {
|
|
258
|
+
containerAri,
|
|
259
|
+
ari,
|
|
260
|
+
emojiId
|
|
261
|
+
},
|
|
262
|
+
reason: 'getDetailedReaction fetch failed'
|
|
218
263
|
}
|
|
219
264
|
});
|
|
220
265
|
});
|
|
@@ -264,7 +309,7 @@ export class MemoryReactionsStore {
|
|
|
264
309
|
return updater => {
|
|
265
310
|
const reactionsState = this.getReactionsState(containerAri, ari);
|
|
266
311
|
|
|
267
|
-
if (reactionsState.status === Types.ReactionStatus.ready) {
|
|
312
|
+
if (reactionsState && reactionsState.status === Types.ReactionStatus.ready) {
|
|
268
313
|
const updated = updater(reactionsState);
|
|
269
314
|
|
|
270
315
|
if (updated) {
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConcurrentExperience, UFOExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
2
|
+
import { withSampling } from '@atlaskit/emoji';
|
|
2
3
|
/**
|
|
3
4
|
* Initial experience config object (deferred from @atlaskit/ufo inner types)
|
|
4
5
|
* TODO: Check if possible to add this to exported types from @atlaskit/ufo
|
|
@@ -66,4 +67,7 @@ export var ReactionDetailsFetch = new ConcurrentExperience(ExperienceName.REACTI
|
|
|
66
67
|
* Experience when a reaction emoji gets removed/decrement
|
|
67
68
|
*/
|
|
68
69
|
|
|
69
|
-
export var ReactionsRemove = new ConcurrentExperience(ExperienceName.REACTION_REMOVED, createExperienceConfig(ComponentName.REACTIONS, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
|
|
70
|
+
export var ReactionsRemove = new ConcurrentExperience(ExperienceName.REACTION_REMOVED, createExperienceConfig(ComponentName.REACTIONS, ExperienceTypes.Experience, ExperiencePerformanceTypes.InlineResult));
|
|
71
|
+
export var sampledReactionsRendered = function sampledReactionsRendered(instanceId) {
|
|
72
|
+
return withSampling(ReactionsRendered.getInstance(instanceId));
|
|
73
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
@@ -7,10 +8,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
8
|
|
|
8
9
|
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
10
|
|
|
11
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
12
|
import { defaultReactionsByShortName } from '../components/Selector';
|
|
11
|
-
|
|
12
|
-
export var
|
|
13
|
-
export var
|
|
13
|
+
import { Constants } from '../shared';
|
|
14
|
+
export var containerAri = "".concat(Constants.ContainerAriPrefix, "1");
|
|
15
|
+
export var ari = "".concat(Constants.AriPrefix, "1");
|
|
16
|
+
export var getReactionSummary = function getReactionSummary(shortName, count, reacted) {
|
|
14
17
|
return {
|
|
15
18
|
ari: ari,
|
|
16
19
|
containerAri: containerAri,
|
|
@@ -19,18 +22,25 @@ export var reaction = function reaction(shortName, count, reacted) {
|
|
|
19
22
|
reacted: reacted
|
|
20
23
|
};
|
|
21
24
|
};
|
|
22
|
-
export var
|
|
25
|
+
export var getUser = function getUser(id, displayName) {
|
|
23
26
|
return {
|
|
24
27
|
id: id,
|
|
25
28
|
displayName: displayName
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
var
|
|
32
|
+
var getReactionKey = function getReactionKey(containerAri, ari) {
|
|
30
33
|
return "".concat(containerAri, "|").concat(ari);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
|
-
var defaultUsers = [
|
|
36
|
+
var defaultUsers = [getUser('oscar', 'Oscar Wallhult'), getUser('julien', 'Julien Michel Hoarau'), getUser('craig', 'Craig Petchell'), getUser('jerome', 'Jerome Touffe-Blin'), getUser('esoares', 'Eduardo Soares'), getUser('lpereira', 'Luiz Pereira'), getUser('pcurren', 'Paul Curren'), getUser('ttjandra', 'Tara Tjandra'), getUser('severington', 'Ste Everington'), getUser('sguillope', 'Sylvain Guillope'), getUser('alunnon', 'Alex Lunnon')];
|
|
37
|
+
|
|
38
|
+
var mockData = _defineProperty({}, getReactionKey(containerAri, ari), [getReactionSummary(':fire:', 1, true), getReactionSummary(':thumbsup:', 999, false), getReactionSummary(':astonished:', 9, false), getReactionSummary(':heart:', 99, false)]);
|
|
39
|
+
/**
|
|
40
|
+
* Mocked version of the client to fetch user information
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
|
|
34
44
|
export var MockReactionsClient = /*#__PURE__*/function () {
|
|
35
45
|
function MockReactionsClient() {
|
|
36
46
|
var _this = this;
|
|
@@ -39,8 +49,6 @@ export var MockReactionsClient = /*#__PURE__*/function () {
|
|
|
39
49
|
|
|
40
50
|
_classCallCheck(this, MockReactionsClient);
|
|
41
51
|
|
|
42
|
-
_defineProperty(this, "mockData", _defineProperty({}, objectReactionKey(containerAri, ari), [reaction(':fire:', 1, true), reaction(':thumbsup:', 9, false), reaction(':astonished:', 5, false), reaction(':heart:', 100, false)]));
|
|
43
|
-
|
|
44
52
|
_defineProperty(this, "delayPromise", function () {
|
|
45
53
|
return new Promise(function (resolve) {
|
|
46
54
|
return window.setTimeout(resolve, _this.delay);
|
|
@@ -52,112 +60,198 @@ export var MockReactionsClient = /*#__PURE__*/function () {
|
|
|
52
60
|
|
|
53
61
|
_createClass(MockReactionsClient, [{
|
|
54
62
|
key: "getReactions",
|
|
55
|
-
value: function
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
value: function () {
|
|
64
|
+
var _getReactions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(containerAri, aris) {
|
|
65
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
66
|
+
while (1) {
|
|
67
|
+
switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
_context.next = 2;
|
|
70
|
+
return this.delayPromise();
|
|
71
|
+
|
|
72
|
+
case 2:
|
|
73
|
+
return _context.abrupt("return", aris.reduce(function (results, ari) {
|
|
74
|
+
var reactionKey = getReactionKey(containerAri, ari);
|
|
75
|
+
results[ari] = mockData[reactionKey] || [];
|
|
76
|
+
return results;
|
|
77
|
+
}, {}));
|
|
78
|
+
|
|
79
|
+
case 3:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context.stop();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, _callee, this);
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
function getReactions(_x, _x2) {
|
|
88
|
+
return _getReactions.apply(this, arguments);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return getReactions;
|
|
92
|
+
}()
|
|
66
93
|
}, {
|
|
67
94
|
key: "getDetailedReaction",
|
|
68
|
-
value: function
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
95
|
+
value: function () {
|
|
96
|
+
var _getDetailedReaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(containerAri, ari, emojiId) {
|
|
97
|
+
var reactionKey, reactionsMockData, reaction, users;
|
|
98
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
99
|
+
while (1) {
|
|
100
|
+
switch (_context2.prev = _context2.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
_context2.next = 2;
|
|
103
|
+
return this.delayPromise();
|
|
104
|
+
|
|
105
|
+
case 2:
|
|
106
|
+
reactionKey = "".concat(containerAri, "|").concat(ari);
|
|
107
|
+
reactionsMockData = mockData[reactionKey];
|
|
108
|
+
|
|
109
|
+
if (!reactionsMockData) {
|
|
110
|
+
_context2.next = 9;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
reaction = reactionsMockData.find(function (reaction_1) {
|
|
115
|
+
return reaction_1.emojiId === emojiId;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
if (!reaction) {
|
|
119
|
+
_context2.next = 9;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
users = [].concat(defaultUsers).slice(Math.floor(Math.random() * 4), Math.floor(Math.random() * 9) + 4).slice(0, reaction.count);
|
|
124
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, reaction), {}, {
|
|
125
|
+
users: users
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
case 9:
|
|
129
|
+
return _context2.abrupt("return", {
|
|
130
|
+
containerAri: containerAri,
|
|
131
|
+
ari: ari,
|
|
132
|
+
emojiId: emojiId,
|
|
133
|
+
count: 1,
|
|
134
|
+
reacted: true,
|
|
135
|
+
users: []
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
case 10:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context2.stop();
|
|
141
|
+
}
|
|
85
142
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
}
|
|
143
|
+
}, _callee2, this);
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
function getDetailedReaction(_x3, _x4, _x5) {
|
|
147
|
+
return _getDetailedReaction.apply(this, arguments);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return getDetailedReaction;
|
|
151
|
+
}()
|
|
98
152
|
}, {
|
|
99
153
|
key: "addReaction",
|
|
100
|
-
value: function
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
154
|
+
value: function () {
|
|
155
|
+
var _addReaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(containerAri, ari, emojiId) {
|
|
156
|
+
var reactionKey, found, reactionsMockData;
|
|
157
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
158
|
+
while (1) {
|
|
159
|
+
switch (_context3.prev = _context3.next) {
|
|
160
|
+
case 0:
|
|
161
|
+
_context3.next = 2;
|
|
162
|
+
return this.delayPromise();
|
|
163
|
+
|
|
164
|
+
case 2:
|
|
165
|
+
reactionKey = getReactionKey(containerAri, ari);
|
|
166
|
+
found = false;
|
|
167
|
+
reactionsMockData = mockData[reactionKey];
|
|
168
|
+
|
|
169
|
+
if (reactionsMockData) {
|
|
170
|
+
mockData[reactionKey] = reactionsMockData.map(function (reaction) {
|
|
171
|
+
if (reaction.emojiId === emojiId) {
|
|
172
|
+
found = true;
|
|
173
|
+
return _objectSpread(_objectSpread({}, reaction), {}, {
|
|
174
|
+
count: reaction.count + 1,
|
|
175
|
+
reacted: true
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return reaction;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (!found) {
|
|
184
|
+
mockData[reactionKey] = [].concat(_toConsumableArray(reactionsMockData ? reactionsMockData : []), [{
|
|
185
|
+
containerAri: containerAri,
|
|
186
|
+
ari: ari,
|
|
187
|
+
emojiId: emojiId,
|
|
188
|
+
count: 1,
|
|
189
|
+
reacted: true
|
|
190
|
+
}]);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return _context3.abrupt("return", mockData[reactionKey]);
|
|
194
|
+
|
|
195
|
+
case 8:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context3.stop();
|
|
116
198
|
}
|
|
199
|
+
}
|
|
200
|
+
}, _callee3, this);
|
|
201
|
+
}));
|
|
117
202
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
containerAri: containerAri,
|
|
125
|
-
ari: ari,
|
|
126
|
-
emojiId: emojiId,
|
|
127
|
-
count: 1,
|
|
128
|
-
reacted: true
|
|
129
|
-
}]);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return _this4.mockData[reactionKey];
|
|
133
|
-
});
|
|
134
|
-
}
|
|
203
|
+
function addReaction(_x6, _x7, _x8) {
|
|
204
|
+
return _addReaction.apply(this, arguments);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return addReaction;
|
|
208
|
+
}()
|
|
135
209
|
}, {
|
|
136
210
|
key: "deleteReaction",
|
|
137
|
-
value: function
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
211
|
+
value: function () {
|
|
212
|
+
var _deleteReaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(containerAri, ari, emojiId) {
|
|
213
|
+
var reactionKey;
|
|
214
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
215
|
+
while (1) {
|
|
216
|
+
switch (_context4.prev = _context4.next) {
|
|
217
|
+
case 0:
|
|
218
|
+
_context4.next = 2;
|
|
219
|
+
return this.delayPromise();
|
|
220
|
+
|
|
221
|
+
case 2:
|
|
222
|
+
reactionKey = getReactionKey(containerAri, ari);
|
|
223
|
+
mockData[reactionKey] = mockData[reactionKey].map(function (reaction) {
|
|
224
|
+
if (reaction.emojiId === emojiId) {
|
|
225
|
+
if (reaction.count === 1) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return _objectSpread(_objectSpread({}, reaction), {}, {
|
|
230
|
+
count: reaction.count - 1,
|
|
231
|
+
reacted: false
|
|
232
|
+
});
|
|
233
|
+
}
|
|
147
234
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
235
|
+
return reaction;
|
|
236
|
+
}).filter(function (reaction_1) {
|
|
237
|
+
return !!reaction_1;
|
|
238
|
+
});
|
|
239
|
+
return _context4.abrupt("return", mockData[reactionKey]);
|
|
240
|
+
|
|
241
|
+
case 5:
|
|
242
|
+
case "end":
|
|
243
|
+
return _context4.stop();
|
|
244
|
+
}
|
|
152
245
|
}
|
|
246
|
+
}, _callee4, this);
|
|
247
|
+
}));
|
|
153
248
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
249
|
+
function deleteReaction(_x9, _x10, _x11) {
|
|
250
|
+
return _deleteReaction.apply(this, arguments);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return deleteReaction;
|
|
254
|
+
}()
|
|
161
255
|
}]);
|
|
162
256
|
|
|
163
257
|
return MockReactionsClient;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ReactionServiceClient } from './ReactionServiceClient';
|
|
1
|
+
export { ReactionServiceClient } from './ReactionServiceClient';
|
|
2
|
+
export { MockReactionsClient, ari, containerAri, getReactionSummary, getUser } from './MockReactionsClient';
|
|
@@ -3,7 +3,8 @@ import { jsx, css } from '@emotion/core';
|
|
|
3
3
|
import { N500, B400 } from '@atlaskit/theme/colors';
|
|
4
4
|
import { token } from '@atlaskit/tokens';
|
|
5
5
|
import React, { memo } from 'react';
|
|
6
|
-
import { SlideIn, ExitingPersistence, mediumDurationMs } from '@atlaskit/motion';
|
|
6
|
+
import { SlideIn, ExitingPersistence, mediumDurationMs } from '@atlaskit/motion'; // eslint-disable-next-line @atlaskit/design-system/no-banned-imports
|
|
7
|
+
|
|
7
8
|
import usePreviousValue from '@atlaskit/ds-lib/use-previous-value';
|
|
8
9
|
export var counterTestId = 'counter-container';
|
|
9
10
|
export var countStyle = css({
|
|
@@ -69,6 +69,10 @@ var flashStyle = css({
|
|
|
69
69
|
borderRadius: '10px',
|
|
70
70
|
height: "".concat(flashHeight, "px")
|
|
71
71
|
});
|
|
72
|
+
/**
|
|
73
|
+
* @param id give id for the emoji
|
|
74
|
+
* @param event selected mouse event proerties
|
|
75
|
+
*/
|
|
72
76
|
|
|
73
77
|
var ReactionWithoutAnalytics = /*#__PURE__*/function (_PureComponent) {
|
|
74
78
|
_inherits(ReactionWithoutAnalytics, _PureComponent);
|
|
@@ -93,8 +97,8 @@ var ReactionWithoutAnalytics = /*#__PURE__*/function (_PureComponent) {
|
|
|
93
97
|
_reaction = _this$props.reaction,
|
|
94
98
|
createAnalyticsEvent = _this$props.createAnalyticsEvent;
|
|
95
99
|
var reacted = _reaction.reacted,
|
|
96
|
-
|
|
97
|
-
createAndFireSafe(createAnalyticsEvent, createReactionClickedEvent, !reacted,
|
|
100
|
+
emojiId = _reaction.emojiId;
|
|
101
|
+
createAndFireSafe(createAnalyticsEvent, createReactionClickedEvent, !reacted, emojiId);
|
|
98
102
|
|
|
99
103
|
_this.props.onClick(_this.props.reaction.emojiId, event);
|
|
100
104
|
}
|
|
@@ -195,8 +199,7 @@ var ReactionWithoutAnalytics = /*#__PURE__*/function (_PureComponent) {
|
|
|
195
199
|
_defineProperty(ReactionWithoutAnalytics, "defaultProps", {
|
|
196
200
|
flash: false,
|
|
197
201
|
className: undefined,
|
|
198
|
-
onMouseEnter: undefined
|
|
199
|
-
flashOnMount: false
|
|
202
|
+
onMouseEnter: undefined
|
|
200
203
|
});
|
|
201
204
|
|
|
202
205
|
_defineProperty(ReactionWithoutAnalytics, "displayName", 'Reaction');
|
|
@@ -47,6 +47,10 @@ var popupStyle = css({
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
function noop() {}
|
|
50
|
+
/**
|
|
51
|
+
* This renders the picker component (wrapped by the ConnectedReactionPicker)
|
|
52
|
+
*/
|
|
53
|
+
|
|
50
54
|
|
|
51
55
|
export var ReactionPicker = /*#__PURE__*/function (_PureComponent) {
|
|
52
56
|
_inherits(ReactionPicker, _PureComponent);
|
|
@@ -82,10 +86,10 @@ export var ReactionPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
82
86
|
|
|
83
87
|
_defineProperty(_assertThisInitialized(_this), "showFullPicker", function (e) {
|
|
84
88
|
e.preventDefault();
|
|
85
|
-
var
|
|
89
|
+
var onShowMore = _this.props.onShowMore;
|
|
86
90
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
91
|
+
if (onShowMore) {
|
|
92
|
+
onShowMore();
|
|
89
93
|
} // Update popper position
|
|
90
94
|
|
|
91
95
|
|
|
@@ -160,13 +164,22 @@ export var ReactionPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
160
164
|
_createClass(ReactionPicker, [{
|
|
161
165
|
key: "componentDidMount",
|
|
162
166
|
value: function componentDidMount() {
|
|
163
|
-
document.addEventListener('click', this.handleClickOutside
|
|
167
|
+
document.addEventListener('click', this.handleClickOutside, {
|
|
168
|
+
capture: true
|
|
169
|
+
});
|
|
164
170
|
}
|
|
165
171
|
}, {
|
|
166
172
|
key: "componentWillUnmount",
|
|
167
173
|
value: function componentWillUnmount() {
|
|
168
|
-
document.removeEventListener('click', this.handleClickOutside
|
|
169
|
-
|
|
174
|
+
document.removeEventListener('click', this.handleClickOutside, {
|
|
175
|
+
capture: true
|
|
176
|
+
});
|
|
177
|
+
UFO.PickerRender.abort({
|
|
178
|
+
metadata: {
|
|
179
|
+
source: 'Reaction-Picker',
|
|
180
|
+
reason: 'unmount'
|
|
181
|
+
}
|
|
182
|
+
});
|
|
170
183
|
}
|
|
171
184
|
}, {
|
|
172
185
|
key: "close",
|
|
@@ -176,7 +189,13 @@ export var ReactionPicker = /*#__PURE__*/function (_PureComponent) {
|
|
|
176
189
|
showFullPicker: false
|
|
177
190
|
}, function () {
|
|
178
191
|
// ufo abort reaction experience
|
|
179
|
-
UFO.PickerRender.abort(
|
|
192
|
+
UFO.PickerRender.abort({
|
|
193
|
+
metadata: {
|
|
194
|
+
emojiId: _emojiId,
|
|
195
|
+
source: 'Reaction-Picker',
|
|
196
|
+
reason: 'close dialog'
|
|
197
|
+
}
|
|
198
|
+
});
|
|
180
199
|
});
|
|
181
200
|
}
|
|
182
201
|
}, {
|
|
@@ -155,7 +155,7 @@ export var ReactionsWithoutAnalytics = /*#__PURE__*/function (_React$PureCompone
|
|
|
155
155
|
onSelection: this.handleOnSelection,
|
|
156
156
|
onOpen: this.handlePickerOpen,
|
|
157
157
|
onCancel: this.handleOnCancel,
|
|
158
|
-
|
|
158
|
+
onShowMore: this.handleOnMore
|
|
159
159
|
}));
|
|
160
160
|
}
|
|
161
161
|
}, {
|