|
@@ -1,5 +1,3 @@
|
1
|
|
-/* global config */
|
2
|
|
-
|
3
|
1
|
import Tabs from '@atlaskit/tabs';
|
4
|
2
|
import React, { Component } from 'react';
|
5
|
3
|
import { connect } from 'react-redux';
|
|
@@ -33,12 +31,7 @@ const TAB_CONFIGURATIONS = [
|
33
|
31
|
type: 'window'
|
34
|
32
|
}
|
35
|
33
|
];
|
36
|
|
-const CONFIGURED_TYPES = config.desktopSharingChromeSources || [];
|
37
|
34
|
const VALID_TYPES = TAB_CONFIGURATIONS.map(c => c.type);
|
38
|
|
-const TABS_TO_POPULATE
|
39
|
|
- = TAB_CONFIGURATIONS.filter(
|
40
|
|
- c => CONFIGURED_TYPES.includes(c.type) && VALID_TYPES.includes(c.type));
|
41
|
|
-const TYPES_TO_FETCH = TABS_TO_POPULATE.map(c => c.type);
|
42
|
35
|
|
43
|
36
|
/**
|
44
|
37
|
* React component for DesktopPicker.
|
|
@@ -63,6 +56,11 @@ class DesktopPicker extends Component {
|
63
|
56
|
*/
|
64
|
57
|
onSourceChoose: React.PropTypes.func,
|
65
|
58
|
|
|
59
|
+ /**
|
|
60
|
+ * An object with options related to desktop sharing.
|
|
61
|
+ */
|
|
62
|
+ options: React.PropTypes.object,
|
|
63
|
+
|
66
|
64
|
/**
|
67
|
65
|
* An object with arrays of DesktopCapturerSources. The key should be
|
68
|
66
|
* the source type.
|
|
@@ -85,7 +83,9 @@ class DesktopPicker extends Component {
|
85
|
83
|
super(props);
|
86
|
84
|
|
87
|
85
|
this.state = {
|
88
|
|
- selectedSource: {}
|
|
86
|
+ selectedSource: {},
|
|
87
|
+ tabsToPopulate: [],
|
|
88
|
+ typesToFetch: []
|
89
|
89
|
};
|
90
|
90
|
|
91
|
91
|
this._poller = null;
|
|
@@ -102,6 +102,10 @@ class DesktopPicker extends Component {
|
102
|
102
|
* @inheritdoc
|
103
|
103
|
*/
|
104
|
104
|
componentWillMount() {
|
|
105
|
+ const options = this.props.options || {};
|
|
106
|
+
|
|
107
|
+ this._onSourceTypesConfigChanged(
|
|
108
|
+ options.desktopSharingSources);
|
105
|
109
|
this._updateSources();
|
106
|
110
|
this._startPolling();
|
107
|
111
|
}
|
|
@@ -125,6 +129,11 @@ class DesktopPicker extends Component {
|
125
|
129
|
}
|
126
|
130
|
});
|
127
|
131
|
}
|
|
132
|
+
|
|
133
|
+ const options = this.props.options || {};
|
|
134
|
+
|
|
135
|
+ this._onSourceTypesConfigChanged(
|
|
136
|
+ options.desktopSharingSources);
|
128
|
137
|
}
|
129
|
138
|
|
130
|
139
|
/**
|
|
@@ -166,7 +175,7 @@ class DesktopPicker extends Component {
|
166
|
175
|
* the onSourceChoose callback.
|
167
|
176
|
* @returns {void}
|
168
|
177
|
*/
|
169
|
|
- _onCloseModal(id, type) {
|
|
178
|
+ _onCloseModal(id = '', type) {
|
170
|
179
|
this.props.onSourceChoose(id, type);
|
171
|
180
|
this.props.dispatch(hideDialog());
|
172
|
181
|
}
|
|
@@ -209,19 +218,20 @@ class DesktopPicker extends Component {
|
209
|
218
|
const { selectedSource } = this.state;
|
210
|
219
|
const { sources, t } = this.props;
|
211
|
220
|
const tabs
|
212
|
|
- = TABS_TO_POPULATE.map(({ defaultSelected, label, type }) => {
|
213
|
|
- return {
|
214
|
|
- content: <DesktopPickerPane
|
215
|
|
- key = { type }
|
216
|
|
- onClick = { this._onPreviewClick }
|
217
|
|
- onDoubleClick = { this._onCloseModal }
|
218
|
|
- selectedSourceId = { selectedSource.id }
|
219
|
|
- sources = { sources[type] || [] }
|
220
|
|
- type = { type } />,
|
221
|
|
- defaultSelected,
|
222
|
|
- label: t(label)
|
223
|
|
- };
|
224
|
|
- });
|
|
221
|
+ = this.state.tabsToPopulate.map(
|
|
222
|
+ ({ defaultSelected, label, type }) => {
|
|
223
|
+ return {
|
|
224
|
+ content: <DesktopPickerPane
|
|
225
|
+ key = { type }
|
|
226
|
+ onClick = { this._onPreviewClick }
|
|
227
|
+ onDoubleClick = { this._onCloseModal }
|
|
228
|
+ selectedSourceId = { selectedSource.id }
|
|
229
|
+ sources = { sources[type] || [] }
|
|
230
|
+ type = { type } />,
|
|
231
|
+ defaultSelected,
|
|
232
|
+ label: t(label)
|
|
233
|
+ };
|
|
234
|
+ });
|
225
|
235
|
|
226
|
236
|
return <Tabs tabs = { tabs } />;
|
227
|
237
|
}
|
|
@@ -248,6 +258,25 @@ class DesktopPicker extends Component {
|
248
|
258
|
this._poller = null;
|
249
|
259
|
}
|
250
|
260
|
|
|
261
|
+ /**
|
|
262
|
+ * Handles changing of allowed desktop sharing source types.
|
|
263
|
+ *
|
|
264
|
+ * @param {Array<string>} desktopSharingSourceTypes - The types that will be
|
|
265
|
+ * fetched and displayed.
|
|
266
|
+ * @returns {void}
|
|
267
|
+ */
|
|
268
|
+ _onSourceTypesConfigChanged(desktopSharingSourceTypes = []) {
|
|
269
|
+ const tabsToPopulate = TAB_CONFIGURATIONS.filter(
|
|
270
|
+ c => desktopSharingSourceTypes.includes(c.type)
|
|
271
|
+ && VALID_TYPES.includes(c.type)
|
|
272
|
+ );
|
|
273
|
+
|
|
274
|
+ this.setState({
|
|
275
|
+ tabsToPopulate,
|
|
276
|
+ typesToFetch: tabsToPopulate.map(c => c.type)
|
|
277
|
+ });
|
|
278
|
+ }
|
|
279
|
+
|
251
|
280
|
/**
|
252
|
281
|
* Dispatches an action to get currently available DesktopCapturerSources.
|
253
|
282
|
*
|
|
@@ -256,7 +285,7 @@ class DesktopPicker extends Component {
|
256
|
285
|
*/
|
257
|
286
|
_updateSources() {
|
258
|
287
|
this.props.dispatch(obtainDesktopSources(
|
259
|
|
- TYPES_TO_FETCH,
|
|
288
|
+ this.state.typesToFetch,
|
260
|
289
|
{
|
261
|
290
|
THUMBNAIL_SIZE
|
262
|
291
|
}
|