"Fossies" - the Fresh Open Source Software Archive 
Member "jitsi-meet-7550/react/features/recording/components/Recording/AbstractStartRecordingDialogContent.tsx" (26 Sep 2023, 9496 Bytes) of package /linux/misc/jitsi-meet-7550.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TSX (TypeScript with React) source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 import { Component } from 'react';
2 import { WithTranslation } from 'react-i18next';
3
4 import { createRecordingDialogEvent } from '../../../analytics/AnalyticsEvents';
5 import { sendAnalytics } from '../../../analytics/functions';
6 import { IReduxState, IStore } from '../../../app/types';
7 import ColorSchemeRegistry from '../../../base/color-scheme/ColorSchemeRegistry';
8 import { _abstractMapStateToProps } from '../../../base/dialog/functions';
9 import { isLocalParticipantModerator } from '../../../base/participants/functions';
10 import { authorizeDropbox, updateDropboxToken } from '../../../dropbox/actions';
11 import { isVpaasMeeting } from '../../../jaas/functions';
12 import { RECORDING_TYPES } from '../../constants';
13 import { supportsLocalRecording } from '../../functions';
14
15 /**
16 * The type of the React {@code Component} props of
17 * {@link AbstractStartRecordingDialogContent}.
18 */
19 export interface IProps extends WithTranslation {
20
21 /**
22 * Style of the dialogs feature.
23 */
24 _dialogStyles: any;
25
26 /**
27 * Whether to hide the storage warning or not.
28 */
29 _hideStorageWarning: boolean;
30
31 /**
32 * Whether local participant is moderator.
33 */
34 _isModerator: boolean;
35
36 /**
37 * Whether local recording is available or not.
38 */
39 _localRecordingAvailable: boolean;
40
41 /**
42 * Whether local recording is enabled or not.
43 */
44 _localRecordingEnabled: boolean;
45
46 /**
47 * Whether we won't notify the other participants about the recording.
48 */
49 _localRecordingNoNotification: boolean;
50
51 /**
52 * Whether self local recording is enabled or not.
53 */
54 _localRecordingSelfEnabled: boolean;
55
56 /**
57 * The color-schemed stylesheet of this component.
58 */
59 _styles: any;
60
61 /**
62 * The redux dispatch function.
63 */
64 dispatch: IStore['dispatch'];
65
66 /**
67 * Whether to show file recordings service, even if integrations
68 * are enabled.
69 */
70 fileRecordingsServiceEnabled: boolean;
71
72 /**
73 * Whether to show the possibility to share file recording with other people (e.g. Meeting participants), based on
74 * the actual implementation on the backend.
75 */
76 fileRecordingsServiceSharingEnabled: boolean;
77
78 /**
79 * If true the content related to the integrations will be shown.
80 */
81 integrationsEnabled: boolean;
82
83 /**
84 * <tt>true</tt> if we have valid oauth token.
85 */
86 isTokenValid: boolean;
87
88 /**
89 * <tt>true</tt> if we are in process of validating the oauth token.
90 */
91 isValidating: boolean;
92
93 /**
94 * Whether or not the current meeting is a vpaas one.
95 */
96 isVpaas: boolean;
97
98 /**
99 * Whether or not we should only record the local streams.
100 */
101 localRecordingOnlySelf?: boolean;
102
103 /**
104 * The function will be called when there are changes related to the
105 * switches.
106 */
107 onChange: Function;
108
109 /**
110 * Callback to change the local recording only self setting.
111 */
112 onLocalRecordingSelfChange?: () => void;
113
114 /**
115 * Callback to be invoked on sharing setting change.
116 */
117 onSharingSettingChanged: () => void;
118
119 /**
120 * The currently selected recording service of type: RECORDING_TYPES.
121 */
122 selectedRecordingService: string | null;
123
124 /**
125 * Boolean to set file recording sharing on or off.
126 */
127 sharingSetting: boolean;
128
129 /**
130 * Number of MiB of available space in user's Dropbox account.
131 */
132 spaceLeft?: number;
133
134 /**
135 * The display name of the user's Dropbox account.
136 */
137 userName?: string;
138 }
139
140 /**
141 * React Component for getting confirmation to start a file recording session.
142 *
143 * @augments Component
144 */
145 class AbstractStartRecordingDialogContent<P extends IProps> extends Component<P> {
146 /**
147 * Initializes a new {@code AbstractStartRecordingDialogContent} instance.
148 *
149 * @inheritdoc
150 */
151 constructor(props: P) {
152 super(props);
153
154 // Bind event handler; it bounds once for every instance.
155 this._onSignIn = this._onSignIn.bind(this);
156 this._onSignOut = this._onSignOut.bind(this);
157 this._onDropboxSwitchChange = this._onDropboxSwitchChange.bind(this);
158 this._onRecordingServiceSwitchChange = this._onRecordingServiceSwitchChange.bind(this);
159 this._onLocalRecordingSwitchChange = this._onLocalRecordingSwitchChange.bind(this);
160 }
161
162 /**
163 * Implements the Component's componentDidMount method.
164 *
165 * @inheritdoc
166 */
167 componentDidMount() {
168 if (!this._shouldRenderNoIntegrationsContent()
169 && !this._shouldRenderIntegrationsContent()
170 && !this._shouldRenderFileSharingContent()) {
171 this._onLocalRecordingSwitchChange();
172 }
173 }
174
175 /**
176 * Implements {@code Component#componentDidUpdate}.
177 *
178 * @inheritdoc
179 */
180 componentDidUpdate(prevProps: P) {
181 // Auto sign-out when the use chooses another recording service.
182 if (prevProps.selectedRecordingService === RECORDING_TYPES.DROPBOX
183 && this.props.selectedRecordingService !== RECORDING_TYPES.DROPBOX && this.props.isTokenValid) {
184 this._onSignOut();
185 }
186 }
187
188 /**
189 * Whether the file sharing content should be rendered or not.
190 *
191 * @returns {boolean}
192 */
193 _shouldRenderFileSharingContent() {
194 const {
195 fileRecordingsServiceEnabled,
196 fileRecordingsServiceSharingEnabled,
197 isVpaas,
198 selectedRecordingService
199 } = this.props;
200
201 if (!fileRecordingsServiceEnabled
202 || !fileRecordingsServiceSharingEnabled
203 || isVpaas
204 || selectedRecordingService !== RECORDING_TYPES.JITSI_REC_SERVICE) {
205 return false;
206 }
207
208 return true;
209 }
210
211 /**
212 * Whether the no integrations content should be rendered or not.
213 *
214 * @returns {boolean}
215 */
216 _shouldRenderNoIntegrationsContent() {
217 // show the non integrations part only if fileRecordingsServiceEnabled
218 // is enabled
219 if (!this.props.fileRecordingsServiceEnabled) {
220 return false;
221 }
222
223 return true;
224 }
225
226 /**
227 * Whether the integrations content should be rendered or not.
228 *
229 * @returns {boolean}
230 */
231 _shouldRenderIntegrationsContent() {
232 if (!this.props.integrationsEnabled) {
233 return false;
234 }
235
236 return true;
237 }
238
239 /**
240 * Handler for onValueChange events from the Switch component.
241 *
242 * @returns {void}
243 */
244 _onRecordingServiceSwitchChange() {
245 const {
246 onChange,
247 selectedRecordingService
248 } = this.props;
249
250 // act like group, cannot toggle off
251 if (selectedRecordingService === RECORDING_TYPES.JITSI_REC_SERVICE) {
252 return;
253 }
254
255 onChange(RECORDING_TYPES.JITSI_REC_SERVICE);
256 }
257
258 /**
259 * Handler for onValueChange events from the Switch component.
260 *
261 * @returns {void}
262 */
263 _onDropboxSwitchChange() {
264 const {
265 isTokenValid,
266 onChange,
267 selectedRecordingService
268 } = this.props;
269
270 // act like group, cannot toggle off
271 if (selectedRecordingService === RECORDING_TYPES.DROPBOX) {
272 return;
273 }
274
275 onChange(RECORDING_TYPES.DROPBOX);
276
277 if (!isTokenValid) {
278 this._onSignIn();
279 }
280 }
281
282 /**
283 * Handler for onValueChange events from the Switch component.
284 *
285 * @returns {void}
286 */
287 _onLocalRecordingSwitchChange() {
288 const {
289 _localRecordingAvailable,
290 onChange,
291 selectedRecordingService
292 } = this.props;
293
294 if (!_localRecordingAvailable) {
295 return;
296 }
297
298 // act like group, cannot toggle off
299 if (selectedRecordingService
300 === RECORDING_TYPES.LOCAL) {
301 return;
302 }
303
304 onChange(RECORDING_TYPES.LOCAL);
305 }
306
307 /**
308 * Sings in a user.
309 *
310 * @returns {void}
311 */
312 _onSignIn() {
313 sendAnalytics(createRecordingDialogEvent('start', 'signIn.button'));
314 this.props.dispatch(authorizeDropbox());
315 }
316
317 /**
318 * Sings out an user from dropbox.
319 *
320 * @returns {void}
321 */
322 _onSignOut() {
323 sendAnalytics(createRecordingDialogEvent('start', 'signOut.button'));
324 this.props.dispatch(updateDropboxToken());
325 }
326 }
327
328 /**
329 * Maps part of the redux state to the props of this component.
330 *
331 * @param {Object} state - The Redux state.
332 * @returns {IProps}
333 */
334 export function mapStateToProps(state: IReduxState) {
335 const { localRecording, recordingService } = state['features/base/config'];
336 const _localRecordingAvailable
337 = !localRecording?.disable && supportsLocalRecording();
338
339 return {
340 ..._abstractMapStateToProps(state),
341 isVpaas: isVpaasMeeting(state),
342 _hideStorageWarning: Boolean(recordingService?.hideStorageWarning),
343 _isModerator: isLocalParticipantModerator(state),
344 _localRecordingAvailable,
345 _localRecordingEnabled: !localRecording?.disable,
346 _localRecordingSelfEnabled: !localRecording?.disableSelfRecording,
347 _localRecordingNoNotification: !localRecording?.notifyAllParticipants,
348 _styles: ColorSchemeRegistry.get(state, 'StartRecordingDialogContent')
349 };
350 }
351
352 export default AbstractStartRecordingDialogContent;