@atlaskit/share 5.0.0 → 5.0.1
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 +8 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/dist/cjs/components/CopyLinkButton.js +11 -7
- package/dist/cjs/components/CopyLinkButtonNext.compiled.css +8 -0
- package/dist/cjs/components/CopyLinkButtonNext.js +180 -0
- package/dist/cjs/components/IntegrationButton.js +10 -1
- package/dist/cjs/components/IntegrationButtonNext.compiled.css +7 -0
- package/dist/cjs/components/IntegrationButtonNext.js +38 -0
- package/dist/cjs/components/LazyShareForm/LazyShareFormNext.compiled.css +5 -0
- package/dist/cjs/components/LazyShareForm/LazyShareFormNext.js +138 -0
- package/dist/cjs/components/LazyShareForm/lazy.js +3 -1
- package/dist/cjs/components/LazyShareForm/lazyNext.compiled.css +5 -0
- package/dist/cjs/components/LazyShareForm/lazyNext.js +58 -0
- package/dist/cjs/components/ShareDialogWithTrigger.js +12 -8
- package/dist/cjs/components/ShareDialogWithTriggerNext.compiled.css +4 -0
- package/dist/cjs/components/ShareDialogWithTriggerNext.js +653 -0
- package/dist/cjs/components/ShareFormNext.compiled.css +21 -0
- package/dist/cjs/components/ShareFormNext.js +473 -0
- package/dist/cjs/components/ShareFormWrapper/ShareFormWrapper.js +6 -2
- package/dist/cjs/components/ShareFormWrapper/compiled.compiled.css +7 -0
- package/dist/cjs/components/ShareFormWrapper/compiled.js +48 -0
- package/dist/cjs/components/SplitButton.js +25 -17
- package/dist/cjs/components/UserPickerField.js +3 -1
- package/dist/cjs/components/analytics/analytics.js +1 -1
- package/dist/es2019/components/CopyLinkButton.js +3 -1
- package/dist/es2019/components/CopyLinkButtonNext.compiled.css +8 -0
- package/dist/es2019/components/CopyLinkButtonNext.js +151 -0
- package/dist/es2019/components/IntegrationButton.js +9 -1
- package/dist/es2019/components/IntegrationButtonNext.compiled.css +7 -0
- package/dist/es2019/components/IntegrationButtonNext.js +33 -0
- package/dist/es2019/components/LazyShareForm/LazyShareFormNext.compiled.css +5 -0
- package/dist/es2019/components/LazyShareForm/LazyShareFormNext.js +136 -0
- package/dist/es2019/components/LazyShareForm/lazy.js +3 -1
- package/dist/es2019/components/LazyShareForm/lazyNext.compiled.css +5 -0
- package/dist/es2019/components/LazyShareForm/lazyNext.js +43 -0
- package/dist/es2019/components/ShareDialogWithTrigger.js +4 -2
- package/dist/es2019/components/ShareDialogWithTriggerNext.compiled.css +4 -0
- package/dist/es2019/components/ShareDialogWithTriggerNext.js +593 -0
- package/dist/es2019/components/ShareFormNext.compiled.css +21 -0
- package/dist/es2019/components/ShareFormNext.js +417 -0
- package/dist/es2019/components/ShareFormWrapper/ShareFormWrapper.js +6 -2
- package/dist/es2019/components/ShareFormWrapper/compiled.compiled.css +7 -0
- package/dist/es2019/components/ShareFormWrapper/compiled.js +41 -0
- package/dist/es2019/components/SplitButton.js +9 -3
- package/dist/es2019/components/UserPickerField.js +3 -1
- package/dist/es2019/components/analytics/analytics.js +1 -1
- package/dist/esm/components/CopyLinkButton.js +10 -6
- package/dist/esm/components/CopyLinkButtonNext.compiled.css +8 -0
- package/dist/esm/components/CopyLinkButtonNext.js +173 -0
- package/dist/esm/components/IntegrationButton.js +11 -1
- package/dist/esm/components/IntegrationButtonNext.compiled.css +7 -0
- package/dist/esm/components/IntegrationButtonNext.js +31 -0
- package/dist/esm/components/LazyShareForm/LazyShareFormNext.compiled.css +5 -0
- package/dist/esm/components/LazyShareForm/LazyShareFormNext.js +131 -0
- package/dist/esm/components/LazyShareForm/lazy.js +3 -1
- package/dist/esm/components/LazyShareForm/lazyNext.compiled.css +5 -0
- package/dist/esm/components/LazyShareForm/lazyNext.js +46 -0
- package/dist/esm/components/ShareDialogWithTrigger.js +11 -7
- package/dist/esm/components/ShareDialogWithTriggerNext.compiled.css +4 -0
- package/dist/esm/components/ShareDialogWithTriggerNext.js +646 -0
- package/dist/esm/components/ShareFormNext.compiled.css +21 -0
- package/dist/esm/components/ShareFormNext.js +463 -0
- package/dist/esm/components/ShareFormWrapper/ShareFormWrapper.js +6 -2
- package/dist/esm/components/ShareFormWrapper/compiled.compiled.css +7 -0
- package/dist/esm/components/ShareFormWrapper/compiled.js +41 -0
- package/dist/esm/components/SplitButton.js +25 -17
- package/dist/esm/components/UserPickerField.js +3 -1
- package/dist/esm/components/analytics/analytics.js +1 -1
- package/dist/types/components/CopyLinkButton.d.ts +2 -1
- package/dist/types/components/CopyLinkButtonNext.d.ts +35 -0
- package/dist/types/components/IntegrationButtonNext.d.ts +11 -0
- package/dist/types/components/LazyShareForm/LazyShareFormNext.d.ts +21 -0
- package/dist/types/components/LazyShareForm/lazyNext.d.ts +4 -0
- package/dist/types/components/ShareDialogWithTrigger.d.ts +3 -3
- package/dist/types/components/ShareDialogWithTriggerNext.d.ts +47 -0
- package/dist/types/components/ShareFormNext.d.ts +9 -0
- package/dist/types/components/ShareFormWrapper/compiled.d.ts +10 -0
- package/dist/types-ts4.5/components/CopyLinkButton.d.ts +2 -1
- package/dist/types-ts4.5/components/CopyLinkButtonNext.d.ts +35 -0
- package/dist/types-ts4.5/components/IntegrationButtonNext.d.ts +11 -0
- package/dist/types-ts4.5/components/LazyShareForm/LazyShareFormNext.d.ts +21 -0
- package/dist/types-ts4.5/components/LazyShareForm/lazyNext.d.ts +4 -0
- package/dist/types-ts4.5/components/ShareDialogWithTrigger.d.ts +3 -3
- package/dist/types-ts4.5/components/ShareDialogWithTriggerNext.d.ts +47 -0
- package/dist/types-ts4.5/components/ShareFormNext.d.ts +9 -0
- package/dist/types-ts4.5/components/ShareFormWrapper/compiled.d.ts +10 -0
- package/package.json +15 -11
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
/* ShareDialogWithTriggerNext.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import "./ShareDialogWithTriggerNext.compiled.css";
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { FormattedMessage, injectIntl } from 'react-intl-next';
|
|
7
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
8
|
+
import { cx } from '@atlaskit/css';
|
|
9
|
+
import ShareIcon from '@atlaskit/icon/core/migration/share';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import Popup from '@atlaskit/popup';
|
|
12
|
+
import Portal from '@atlaskit/portal';
|
|
13
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
14
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
15
|
+
import Aktooltip from '@atlaskit/tooltip';
|
|
16
|
+
import { messages } from '../i18n';
|
|
17
|
+
import { OBJECT_SHARED } from '../types';
|
|
18
|
+
import { cancelShare, CHANNEL_ID, copyLinkButtonClicked, formShareSubmitted, screenEvent, shareMenuItemClicked, shareSplitButtonEvent, shareTabClicked, shareTriggerButtonClicked } from './analytics/analytics';
|
|
19
|
+
import { isValidFailedExperience } from './analytics/ufoExperienceHelper';
|
|
20
|
+
import { renderShareDialogExp, shareSubmitExp } from './analytics/ufoExperiences';
|
|
21
|
+
import LazyShareFormLazy from './LazyShareForm/lazy';
|
|
22
|
+
import ShareButton from './ShareButton';
|
|
23
|
+
import SplitButton from './SplitButton';
|
|
24
|
+
import { generateSelectZIndex, resolveShareFooter } from './utils';
|
|
25
|
+
const styles = {
|
|
26
|
+
shareButtonWrapperStyles: "_12ji1r31 _1qu2glyw _12y31o36 _1e0c116y",
|
|
27
|
+
outlineNone: "_12ji1r31 _1qu2glyw _12y31o36"
|
|
28
|
+
};
|
|
29
|
+
export const defaultShareContentState = {
|
|
30
|
+
users: [],
|
|
31
|
+
comment: {
|
|
32
|
+
format: 'plain_text',
|
|
33
|
+
value: ''
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const IconShare = () => /*#__PURE__*/React.createElement(ShareIcon, {
|
|
37
|
+
spacing: "spacious",
|
|
38
|
+
label: "",
|
|
39
|
+
color: "currentColor"
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
43
|
+
export class ShareDialogWithTriggerInternal extends React.PureComponent {
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
_defineProperty(this, "containerRef", /*#__PURE__*/React.createRef());
|
|
47
|
+
/**
|
|
48
|
+
* Because the PopUp component has a higher zIndex it causes
|
|
49
|
+
* the select to be rendered within it, and add scrollbars.
|
|
50
|
+
* We will render the select options the PopUp outside,
|
|
51
|
+
*/
|
|
52
|
+
_defineProperty(this, "selectPortalRef", /*#__PURE__*/React.createRef());
|
|
53
|
+
_defineProperty(this, "start", 0);
|
|
54
|
+
_defineProperty(this, "state", {
|
|
55
|
+
isDialogOpen: false,
|
|
56
|
+
isSharing: false,
|
|
57
|
+
ignoreIntermediateState: false,
|
|
58
|
+
defaultValue: defaultShareContentState,
|
|
59
|
+
isUsingSplitButton: false,
|
|
60
|
+
showIntegrationForm: false,
|
|
61
|
+
selectedIntegration: null,
|
|
62
|
+
tabIndex: 0,
|
|
63
|
+
isMenuItemSelected: false,
|
|
64
|
+
isLoading: false
|
|
65
|
+
});
|
|
66
|
+
_defineProperty(this, "closeAndResetDialog", () => {
|
|
67
|
+
this.setState({
|
|
68
|
+
defaultValue: defaultShareContentState,
|
|
69
|
+
ignoreIntermediateState: true,
|
|
70
|
+
shareError: undefined,
|
|
71
|
+
isDialogOpen: false,
|
|
72
|
+
showIntegrationForm: false,
|
|
73
|
+
selectedIntegration: null,
|
|
74
|
+
isMenuItemSelected: false
|
|
75
|
+
});
|
|
76
|
+
const {
|
|
77
|
+
onUserSelectionChange,
|
|
78
|
+
onDialogClose
|
|
79
|
+
} = this.props;
|
|
80
|
+
if (onUserSelectionChange) {
|
|
81
|
+
onUserSelectionChange(defaultShareContentState.users);
|
|
82
|
+
}
|
|
83
|
+
if (onDialogClose) {
|
|
84
|
+
onDialogClose();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
_defineProperty(this, "createAndFireEvent", payload => {
|
|
88
|
+
const {
|
|
89
|
+
createAnalyticsEvent,
|
|
90
|
+
analyticsDecorator
|
|
91
|
+
} = this.props;
|
|
92
|
+
if (analyticsDecorator) {
|
|
93
|
+
payload = analyticsDecorator(payload);
|
|
94
|
+
}
|
|
95
|
+
if (createAnalyticsEvent) {
|
|
96
|
+
createAnalyticsEvent(payload).fire(CHANNEL_ID);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
_defineProperty(this, "onTabChange", index => {
|
|
100
|
+
let subjectId = 'shareTab';
|
|
101
|
+
const {
|
|
102
|
+
shareContentType
|
|
103
|
+
} = this.props;
|
|
104
|
+
if (index === 1) {
|
|
105
|
+
subjectId = 'shareToSlackTab';
|
|
106
|
+
}
|
|
107
|
+
this.createAndFireEvent(shareTabClicked(subjectId, shareContentType));
|
|
108
|
+
this.setState({
|
|
109
|
+
tabIndex: index
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
_defineProperty(this, "onMenuItemChange", menuType => {
|
|
113
|
+
let subjectId = menuType === 'Slack' ? 'shareToSlackMenuItem' : 'shareMenuItem';
|
|
114
|
+
const {
|
|
115
|
+
shareContentType
|
|
116
|
+
} = this.props;
|
|
117
|
+
this.createAndFireEvent(shareMenuItemClicked(subjectId, shareContentType));
|
|
118
|
+
this.setState({
|
|
119
|
+
isMenuItemSelected: true
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
_defineProperty(this, "getFlags", () => {
|
|
123
|
+
const {
|
|
124
|
+
intl: {
|
|
125
|
+
formatMessage
|
|
126
|
+
}
|
|
127
|
+
} = this.props;
|
|
128
|
+
|
|
129
|
+
// The reason for providing message property is that in jira,
|
|
130
|
+
// the Flag system takes only Message Descriptor as payload
|
|
131
|
+
// and formatMessage is called for every flag
|
|
132
|
+
// if the translation data is not provided, a translated default message
|
|
133
|
+
// will be displayed
|
|
134
|
+
return [{
|
|
135
|
+
appearance: 'success',
|
|
136
|
+
title: {
|
|
137
|
+
...messages.shareSuccessMessage,
|
|
138
|
+
defaultMessage: formatMessage(messages.shareSuccessMessage, {
|
|
139
|
+
object: this.props.shareContentType.toLowerCase()
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
type: OBJECT_SHARED
|
|
143
|
+
}];
|
|
144
|
+
});
|
|
145
|
+
_defineProperty(this, "setIsLoading", isLoading => {
|
|
146
|
+
this.setState({
|
|
147
|
+
isLoading
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
_defineProperty(this, "focus", () => {
|
|
151
|
+
if (this.containerRef.current) {
|
|
152
|
+
this.containerRef.current.focus();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
_defineProperty(this, "handleKeyDown", event => {
|
|
156
|
+
const {
|
|
157
|
+
isLoading,
|
|
158
|
+
isDialogOpen
|
|
159
|
+
} = this.state;
|
|
160
|
+
const {
|
|
161
|
+
shouldCloseOnEscapePress
|
|
162
|
+
} = this.props;
|
|
163
|
+
if (isLoading) {
|
|
164
|
+
event.stopPropagation();
|
|
165
|
+
this.focus();
|
|
166
|
+
}
|
|
167
|
+
if (isDialogOpen) {
|
|
168
|
+
switch (event.key) {
|
|
169
|
+
case 'Esc':
|
|
170
|
+
case 'Escape':
|
|
171
|
+
// The @atlaskit/popup will capture the event and auto-close, we
|
|
172
|
+
// need to prevent that if the dialog is set to not close on `ESC`
|
|
173
|
+
if (!shouldCloseOnEscapePress) {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
event.stopPropagation();
|
|
176
|
+
// put the focus back onto the share dialog so that
|
|
177
|
+
// the user can press the escape key again to close the dialog
|
|
178
|
+
this.focus();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
// The dialog will auto-close in @atlaskit/popup, we just need to fire
|
|
182
|
+
// the right events.
|
|
183
|
+
if (shouldCloseOnEscapePress) {
|
|
184
|
+
// This experience should be aborted in a scenario when a user closes the dialog before the shareClient.getConfig() call is finished
|
|
185
|
+
// It is a race condition between the `SUCCEEDED` case and the `ABORTED` case of this experience
|
|
186
|
+
// UFO experiences can only have one FINAL state so it doesn't matter if we call .abort() after the experience has succeeded and vice versa
|
|
187
|
+
renderShareDialogExp.abort();
|
|
188
|
+
this.createAndFireEvent(cancelShare(this.start));
|
|
189
|
+
this.closeAndResetDialog();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
_defineProperty(this, "handleDialogOpen", () => {
|
|
195
|
+
this.setState(state => ({
|
|
196
|
+
isDialogOpen: !state.isDialogOpen,
|
|
197
|
+
ignoreIntermediateState: false,
|
|
198
|
+
showIntegrationForm: false,
|
|
199
|
+
selectedIntegration: null
|
|
200
|
+
}), () => {
|
|
201
|
+
const {
|
|
202
|
+
onDialogOpen,
|
|
203
|
+
isPublicLink
|
|
204
|
+
} = this.props;
|
|
205
|
+
const {
|
|
206
|
+
isDialogOpen
|
|
207
|
+
} = this.state;
|
|
208
|
+
if (isDialogOpen) {
|
|
209
|
+
this.start = Date.now();
|
|
210
|
+
this.createAndFireEvent(screenEvent({
|
|
211
|
+
isPublicLink
|
|
212
|
+
}));
|
|
213
|
+
if (onDialogOpen) {
|
|
214
|
+
onDialogOpen();
|
|
215
|
+
}
|
|
216
|
+
this.focus();
|
|
217
|
+
} else {
|
|
218
|
+
this.handleCloseDialog();
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
_defineProperty(this, "onTriggerClick", () => {
|
|
223
|
+
const {
|
|
224
|
+
onTriggerButtonClick
|
|
225
|
+
} = this.props;
|
|
226
|
+
this.createAndFireEvent(shareTriggerButtonClicked());
|
|
227
|
+
this.handleDialogOpen();
|
|
228
|
+
if (onTriggerButtonClick) {
|
|
229
|
+
onTriggerButtonClick();
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
_defineProperty(this, "handleCloseDialog", () => {
|
|
233
|
+
if (this.props.onDialogClose) {
|
|
234
|
+
this.props.onDialogClose();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// This experience should be aborted in a scenario when a user closes the dialog before the shareClient.getConfig() call is finished
|
|
238
|
+
// It is a race condition between the `SUCCEEDED` case and the `ABORTED` case of this experience
|
|
239
|
+
// UFO experiences can only have one FINAL state so it doesn't matter if we call .abort() after the experience has succeeded and vice versa
|
|
240
|
+
renderShareDialogExp.abort();
|
|
241
|
+
this.setState({
|
|
242
|
+
isDialogOpen: false,
|
|
243
|
+
showIntegrationForm: false,
|
|
244
|
+
selectedIntegration: null,
|
|
245
|
+
tabIndex: 0,
|
|
246
|
+
isMenuItemSelected: false
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
_defineProperty(this, "handleShareSubmit", data => {
|
|
250
|
+
const {
|
|
251
|
+
onShareSubmit,
|
|
252
|
+
shareContentType,
|
|
253
|
+
shareContentSubType,
|
|
254
|
+
shareContentId,
|
|
255
|
+
formShareOrigin,
|
|
256
|
+
showFlags,
|
|
257
|
+
isPublicLink
|
|
258
|
+
} = this.props;
|
|
259
|
+
if (!onShareSubmit) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
shareSubmitExp.start();
|
|
263
|
+
this.setState({
|
|
264
|
+
isSharing: true
|
|
265
|
+
});
|
|
266
|
+
this.createAndFireEvent(formShareSubmitted({
|
|
267
|
+
start: this.start,
|
|
268
|
+
data,
|
|
269
|
+
shareContentType,
|
|
270
|
+
shareOrigin: formShareOrigin,
|
|
271
|
+
isPublicLink,
|
|
272
|
+
shareContentSubType,
|
|
273
|
+
shareContentId
|
|
274
|
+
}));
|
|
275
|
+
onShareSubmit(data).then(() => {
|
|
276
|
+
this.closeAndResetDialog();
|
|
277
|
+
this.setState({
|
|
278
|
+
isSharing: false
|
|
279
|
+
});
|
|
280
|
+
showFlags(this.getFlags());
|
|
281
|
+
shareSubmitExp.success();
|
|
282
|
+
}).catch(async err => {
|
|
283
|
+
const shareError = await this.generateShareError(err).catch(errorGenFailed => ({
|
|
284
|
+
message: err.message || errorGenFailed.message || 'Unknown error',
|
|
285
|
+
retryable: true
|
|
286
|
+
}));
|
|
287
|
+
this.setState({
|
|
288
|
+
isSharing: false,
|
|
289
|
+
shareError
|
|
290
|
+
});
|
|
291
|
+
isValidFailedExperience(shareSubmitExp, err);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
_defineProperty(this, "handleFormDismiss", data => {
|
|
295
|
+
this.setState(({
|
|
296
|
+
ignoreIntermediateState
|
|
297
|
+
}) => ignoreIntermediateState ? null : {
|
|
298
|
+
defaultValue: data
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
_defineProperty(this, "calculatePopupOffset", ({
|
|
302
|
+
isMenuItemSelected,
|
|
303
|
+
dialogPlacement
|
|
304
|
+
}) => {
|
|
305
|
+
if (isMenuItemSelected && dialogPlacement === 'bottom-end') {
|
|
306
|
+
return [-0.1, 8];
|
|
307
|
+
}
|
|
308
|
+
return [0, 8];
|
|
309
|
+
});
|
|
310
|
+
_defineProperty(this, "handleCopyLink", () => {
|
|
311
|
+
const {
|
|
312
|
+
copyLinkOrigin,
|
|
313
|
+
shareContentType,
|
|
314
|
+
shareContentSubType,
|
|
315
|
+
shareContentId,
|
|
316
|
+
isPublicLink,
|
|
317
|
+
shareAri
|
|
318
|
+
} = this.props;
|
|
319
|
+
this.createAndFireEvent(copyLinkButtonClicked({
|
|
320
|
+
start: this.start,
|
|
321
|
+
shareContentType,
|
|
322
|
+
shareOrigin: copyLinkOrigin,
|
|
323
|
+
isPublicLink,
|
|
324
|
+
ari: shareAri,
|
|
325
|
+
shareContentSubType,
|
|
326
|
+
shareContentId
|
|
327
|
+
}));
|
|
328
|
+
});
|
|
329
|
+
_defineProperty(this, "handleIntegrationClick", integration => {
|
|
330
|
+
this.setState({
|
|
331
|
+
isUsingSplitButton: false,
|
|
332
|
+
isDialogOpen: true,
|
|
333
|
+
showIntegrationForm: true,
|
|
334
|
+
selectedIntegration: integration
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
_defineProperty(this, "renderShareTriggerButton", triggerProps => {
|
|
338
|
+
const {
|
|
339
|
+
isDialogOpen,
|
|
340
|
+
isUsingSplitButton
|
|
341
|
+
} = this.state;
|
|
342
|
+
const {
|
|
343
|
+
intl: {
|
|
344
|
+
formatMessage
|
|
345
|
+
},
|
|
346
|
+
isDisabled,
|
|
347
|
+
renderCustomTriggerButton,
|
|
348
|
+
triggerButtonIcon,
|
|
349
|
+
triggerButtonTooltipText,
|
|
350
|
+
triggerButtonTooltipPosition,
|
|
351
|
+
triggerButtonAppearance,
|
|
352
|
+
triggerButtonStyle,
|
|
353
|
+
integrationMode,
|
|
354
|
+
shareIntegrations,
|
|
355
|
+
dialogZIndex,
|
|
356
|
+
dialogPlacement
|
|
357
|
+
} = this.props;
|
|
358
|
+
let button;
|
|
359
|
+
const ShareButtonIcon = triggerButtonIcon || IconShare;
|
|
360
|
+
|
|
361
|
+
// Render a custom or standard button.
|
|
362
|
+
if (renderCustomTriggerButton) {
|
|
363
|
+
const {
|
|
364
|
+
shareError
|
|
365
|
+
} = this.state;
|
|
366
|
+
button = renderCustomTriggerButton({
|
|
367
|
+
error: shareError,
|
|
368
|
+
isDisabled,
|
|
369
|
+
isSelected: isDialogOpen,
|
|
370
|
+
onClick: this.onTriggerClick
|
|
371
|
+
}, triggerProps);
|
|
372
|
+
} else {
|
|
373
|
+
button = /*#__PURE__*/React.createElement(ShareButton, {
|
|
374
|
+
appearance: triggerButtonAppearance,
|
|
375
|
+
text: triggerButtonStyle !== 'icon-only' ? /*#__PURE__*/React.createElement(FormattedMessage, messages.shareTriggerButtonText) : null,
|
|
376
|
+
"aria-label": formatMessage(messages.shareTriggerButtonText),
|
|
377
|
+
onClick: this.onTriggerClick,
|
|
378
|
+
iconBefore: triggerButtonStyle !== 'text-only' ? /*#__PURE__*/React.createElement(ShareButtonIcon, {
|
|
379
|
+
label: ""
|
|
380
|
+
}) : undefined,
|
|
381
|
+
isSelected: isDialogOpen,
|
|
382
|
+
isDisabled: isDisabled,
|
|
383
|
+
ref: triggerProps.ref
|
|
384
|
+
// When we autoFocus the dialog, we want to autofocus the trigger as well, that way when the dialog is closed, the trigger is focused
|
|
385
|
+
,
|
|
386
|
+
autoFocus: this.props.isAutoOpenDialog
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// If the button only shows the icon, wrap it in a tooltip containing the button text.
|
|
391
|
+
if (triggerButtonStyle === 'icon-only') {
|
|
392
|
+
button = /*#__PURE__*/React.createElement(Aktooltip, {
|
|
393
|
+
content: !isUsingSplitButton ? triggerButtonTooltipText || formatMessage(messages.shareTriggerButtonTooltipText) : null,
|
|
394
|
+
position: triggerButtonTooltipPosition,
|
|
395
|
+
hideTooltipOnClick: true
|
|
396
|
+
}, button);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// If there are any integrations, wrap the share button in a split button with integrations.
|
|
400
|
+
if (integrationMode === 'split' && shareIntegrations !== null && shareIntegrations !== void 0 && shareIntegrations.length) {
|
|
401
|
+
button = /*#__PURE__*/React.createElement(SplitButton, {
|
|
402
|
+
shareButton: button,
|
|
403
|
+
handleOpenSplitButton: this.handleOpenSplitButton,
|
|
404
|
+
handleCloseSplitButton: this.handleCloseSplitButton,
|
|
405
|
+
isUsingSplitButton: isUsingSplitButton,
|
|
406
|
+
triggerButtonAppearance: triggerButtonAppearance,
|
|
407
|
+
dialogZIndex: dialogZIndex,
|
|
408
|
+
dialogPlacement: dialogPlacement,
|
|
409
|
+
shareIntegrations: shareIntegrations,
|
|
410
|
+
onIntegrationClick: this.handleIntegrationClick,
|
|
411
|
+
createAndFireEvent: this.createAndFireEvent
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
return button;
|
|
415
|
+
});
|
|
416
|
+
_defineProperty(this, "handleOpenSplitButton", () => {
|
|
417
|
+
this.setState({
|
|
418
|
+
isUsingSplitButton: true
|
|
419
|
+
}, () => this.handleCloseDialog());
|
|
420
|
+
this.createAndFireEvent(shareSplitButtonEvent());
|
|
421
|
+
});
|
|
422
|
+
_defineProperty(this, "handleCloseSplitButton", () => {
|
|
423
|
+
this.setState({
|
|
424
|
+
isUsingSplitButton: false
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
_defineProperty(this, "handleOnUserSelectionChange", value => {
|
|
428
|
+
const {
|
|
429
|
+
onUserSelectionChange
|
|
430
|
+
} = this.props;
|
|
431
|
+
this.setState({
|
|
432
|
+
shareError: undefined
|
|
433
|
+
});
|
|
434
|
+
onUserSelectionChange === null || onUserSelectionChange === void 0 ? void 0 : onUserSelectionChange(value);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
componentDidMount() {
|
|
438
|
+
if (this.props.isAutoOpenDialog) {
|
|
439
|
+
this.handleDialogOpen();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
componentDidUpdate(prevProps) {
|
|
443
|
+
if (this.props.isAutoOpenDialog !== prevProps.isAutoOpenDialog && this.props.isAutoOpenDialog) {
|
|
444
|
+
this.handleDialogOpen();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
componentWillUnmount() {
|
|
448
|
+
if (this.props.isAutoOpenDialog && this.props.onDialogClose) {
|
|
449
|
+
this.props.onDialogClose();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
async generateShareError(err) {
|
|
453
|
+
var _errorBody$messagesDe;
|
|
454
|
+
const errorBody = err.body ? await err.body : {};
|
|
455
|
+
|
|
456
|
+
// We'll only try and deal with the first error, sorry
|
|
457
|
+
const firstErrorFromBody = (_errorBody$messagesDe = errorBody.messagesDetails) === null || _errorBody$messagesDe === void 0 ? void 0 : _errorBody$messagesDe[0];
|
|
458
|
+
return {
|
|
459
|
+
message: (firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.message) || err.message,
|
|
460
|
+
errorCode: firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.errorCode,
|
|
461
|
+
helpUrl: firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.helpUrl,
|
|
462
|
+
retryable: (firstErrorFromBody === null || firstErrorFromBody === void 0 ? void 0 : firstErrorFromBody.errorCode) === undefined
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
render() {
|
|
466
|
+
const {
|
|
467
|
+
isDialogOpen,
|
|
468
|
+
isSharing,
|
|
469
|
+
shareError,
|
|
470
|
+
defaultValue,
|
|
471
|
+
showIntegrationForm,
|
|
472
|
+
selectedIntegration,
|
|
473
|
+
isMenuItemSelected
|
|
474
|
+
} = this.state;
|
|
475
|
+
const {
|
|
476
|
+
copyLink,
|
|
477
|
+
dialogPlacement,
|
|
478
|
+
config,
|
|
479
|
+
isFetchingConfig,
|
|
480
|
+
loadUserOptions,
|
|
481
|
+
shareFormTitle,
|
|
482
|
+
shareFormHelperMessage,
|
|
483
|
+
bottomMessage,
|
|
484
|
+
submitButtonLabel,
|
|
485
|
+
product,
|
|
486
|
+
productAttributes,
|
|
487
|
+
customFooter,
|
|
488
|
+
enableSmartUserPicker,
|
|
489
|
+
loggedInAccountId,
|
|
490
|
+
cloudId,
|
|
491
|
+
orgId,
|
|
492
|
+
shareFieldsFooter,
|
|
493
|
+
dialogZIndex,
|
|
494
|
+
isPublicLink,
|
|
495
|
+
tabIndex,
|
|
496
|
+
copyTooltipText,
|
|
497
|
+
integrationMode,
|
|
498
|
+
shareIntegrations,
|
|
499
|
+
additionalTabs,
|
|
500
|
+
builtInTabContentWidth,
|
|
501
|
+
isBrowseUsersDisabled,
|
|
502
|
+
userPickerOptions,
|
|
503
|
+
isSubmitShareDisabled
|
|
504
|
+
} = this.props;
|
|
505
|
+
const footer = resolveShareFooter(integrationMode, this.state.tabIndex, customFooter);
|
|
506
|
+
|
|
507
|
+
// for performance purposes, we may want to have a loadable content i.e. ShareForm
|
|
508
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
509
|
+
xcss: cx(styles.shareButtonWrapperStyles, typeof tabIndex !== 'undefined' && tabIndex >= 0 && styles.outlineNone),
|
|
510
|
+
tabIndex: tabIndex,
|
|
511
|
+
onKeyDown: this.handleKeyDown
|
|
512
|
+
}, /*#__PURE__*/React.createElement(Popup, {
|
|
513
|
+
content: () => /*#__PURE__*/React.createElement("div", {
|
|
514
|
+
ref: this.containerRef
|
|
515
|
+
}, /*#__PURE__*/React.createElement(LazyShareFormLazy, {
|
|
516
|
+
Content: selectedIntegration && selectedIntegration.Content,
|
|
517
|
+
selectedIntegration: selectedIntegration,
|
|
518
|
+
copyLink: copyLink,
|
|
519
|
+
showIntegrationForm: showIntegrationForm,
|
|
520
|
+
bottomMessage: bottomMessage,
|
|
521
|
+
customFooter: footer,
|
|
522
|
+
loadOptions: loadUserOptions,
|
|
523
|
+
isSharing: isSharing,
|
|
524
|
+
shareFormTitle: shareFormTitle,
|
|
525
|
+
showTitle: integrationMode !== 'tabs' || !shareIntegrations || !shareIntegrations.length,
|
|
526
|
+
shareFormHelperMessage: shareFormHelperMessage,
|
|
527
|
+
shareError: shareError,
|
|
528
|
+
defaultValue: defaultValue,
|
|
529
|
+
config: config,
|
|
530
|
+
isFetchingConfig: isFetchingConfig,
|
|
531
|
+
setIsLoading: this.setIsLoading,
|
|
532
|
+
submitButtonLabel: submitButtonLabel,
|
|
533
|
+
product: product,
|
|
534
|
+
productAttributes: productAttributes,
|
|
535
|
+
enableSmartUserPicker: enableSmartUserPicker,
|
|
536
|
+
loggedInAccountId: loggedInAccountId,
|
|
537
|
+
cloudId: cloudId,
|
|
538
|
+
orgId: orgId,
|
|
539
|
+
onUserSelectionChange: this.handleOnUserSelectionChange,
|
|
540
|
+
shareFieldsFooter: shareFieldsFooter,
|
|
541
|
+
isPublicLink: isPublicLink,
|
|
542
|
+
copyTooltipText: copyTooltipText,
|
|
543
|
+
integrationMode: integrationMode,
|
|
544
|
+
shareIntegrations: shareIntegrations,
|
|
545
|
+
additionalTabs: additionalTabs,
|
|
546
|
+
builtInTabContentWidth: builtInTabContentWidth,
|
|
547
|
+
isMenuItemSelected: isMenuItemSelected,
|
|
548
|
+
isSubmitShareDisabled: isSubmitShareDisabled
|
|
549
|
+
// actions
|
|
550
|
+
,
|
|
551
|
+
onLinkCopy: this.handleCopyLink,
|
|
552
|
+
onSubmit: this.handleShareSubmit,
|
|
553
|
+
onDismiss: this.handleFormDismiss,
|
|
554
|
+
onDialogClose: this.handleCloseDialog,
|
|
555
|
+
onTabChange: this.onTabChange,
|
|
556
|
+
onMenuItemChange: this.onMenuItemChange
|
|
557
|
+
//ref
|
|
558
|
+
,
|
|
559
|
+
selectPortalRef: this.selectPortalRef,
|
|
560
|
+
isBrowseUsersDisabled: isBrowseUsersDisabled,
|
|
561
|
+
userPickerOptions: userPickerOptions
|
|
562
|
+
})),
|
|
563
|
+
isOpen: isDialogOpen,
|
|
564
|
+
onClose: this.handleCloseDialog,
|
|
565
|
+
placement: dialogPlacement,
|
|
566
|
+
trigger: this.renderShareTriggerButton,
|
|
567
|
+
zIndex: dialogZIndex,
|
|
568
|
+
label: this.props.intl.formatMessage(messages.sharePopupLabel),
|
|
569
|
+
role: "dialog"
|
|
570
|
+
// TODO: remove after https://hello.atlassian.net/wiki/x/SoEGzQ experiment is finished
|
|
571
|
+
,
|
|
572
|
+
offset: this.calculatePopupOffset({
|
|
573
|
+
isMenuItemSelected,
|
|
574
|
+
dialogPlacement
|
|
575
|
+
}),
|
|
576
|
+
shouldRenderToParent: fg('enable-appropriate-reading-order-in-share-dialog')
|
|
577
|
+
}), /*#__PURE__*/React.createElement(Portal, {
|
|
578
|
+
zIndex: generateSelectZIndex(dialogZIndex)
|
|
579
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
580
|
+
ref: this.selectPortalRef
|
|
581
|
+
})));
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
_defineProperty(ShareDialogWithTriggerInternal, "defaultProps", {
|
|
585
|
+
isDisabled: false,
|
|
586
|
+
dialogPlacement: 'bottom-end',
|
|
587
|
+
shouldCloseOnEscapePress: true,
|
|
588
|
+
triggerButtonAppearance: 'subtle',
|
|
589
|
+
triggerButtonStyle: 'icon-only',
|
|
590
|
+
triggerButtonTooltipPosition: 'top',
|
|
591
|
+
dialogZIndex: layers.modal()
|
|
592
|
+
});
|
|
593
|
+
export const ShareDialogWithTrigger = withAnalyticsEvents()(injectIntl(ShareDialogWithTriggerInternal));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
._11c81vlj{font:var(--ds-font-body-small,normal 400 11px/1pc ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,system-ui,"Helvetica Neue",sans-serif)}
|
|
2
|
+
._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
|
|
3
|
+
._18zrutpp{padding-inline:var(--ds-space-150,9pt)}
|
|
4
|
+
._195g10v4{margin-inline:var(--ds-space-negative-300,-24px)}
|
|
5
|
+
._1moux0bf{margin-block:var(--ds-space-negative-100,-8px)}
|
|
6
|
+
._1rjcze3t{padding-block:var(--ds-space-0,0)}
|
|
7
|
+
._18u01wug{margin-left:auto}
|
|
8
|
+
._19pku2gc{margin-top:var(--ds-space-100,8px)}
|
|
9
|
+
._1bah1y6m{justify-content:flex-start}
|
|
10
|
+
._1bsb1osq{width:100%}
|
|
11
|
+
._1bsb1w81{width:150px}
|
|
12
|
+
._1e0c1txw{display:flex}
|
|
13
|
+
._1wpz1h6o{align-self:center}
|
|
14
|
+
._2hwx1b66{margin-right:var(--ds-space-050,4px)}
|
|
15
|
+
._4cvr1h6o{align-items:center}
|
|
16
|
+
._4cvr1y6m{align-items:flex-start}
|
|
17
|
+
._otyr196n{margin-bottom:var(--ds-space-negative-075,-6px)}
|
|
18
|
+
._otyrpxbi{margin-bottom:var(--ds-space-200,1pc)}
|
|
19
|
+
._otyrutpp{margin-bottom:var(--ds-space-150,9pt)}
|
|
20
|
+
._syaz1fxt{color:var(--ds-text,#172b4d)}
|
|
21
|
+
._syaz1n3s{color:var(--ds-text-subtle,#5e6c84)}
|