neon/firefly/assets/publish/firefly/store/getters.js   F
last analyzed

Complexity

Total Complexity 77
Complexity/F 1.22

Size

Lines of Code 375
Function Count 63

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 77
eloc 109
mnd 14
bc 14
fnc 63
dl 0
loc 375
rs 2.24
bpm 0.2222
cpm 1.2222
noi 45
c 0
b 0
f 0

How to fix   Complexity   

Complexity

Complex classes like neon/firefly/assets/publish/firefly/store/getters.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
FIREFLY.GETTERS = {
0 ignored issues
show
Bug introduced by
The variable FIREFLY seems to be never declared. If this is a global, consider adding a /** global: FIREFLY */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2
3
	/**
4
	 * Get the path the user is currently viewing e.g /team/profile
5
	 *
6
	 * @param state
7
	 * @param getters
8
	 * @return String
9
	 */
10
	getPath: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
11
		return state.pickers[picker].path;
12
	},
13
14
	/**
15
	 * Get a unique directory name for the current directory (current directory defined by the path)
16
	 *
17
	 * @param state
18
	 * @param getters
19
	 */
20
	getUniqueDirName: (state, getters) => (picker) => {
21
		var untitledFolder = 'untitled folder';
22
		var name = untitledFolder
23
		var i = 1;
24
		var path = getters.getPath(picker);
25
		while (_.find(getters.getItems(picker), {path: getters.sanitizePath(path + '/' + name)})) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
26
			name = untitledFolder + ' ' + i;
27
			i ++;
28
		}
29
		return getters.sanitizePath(path + '/' + name);
30
	},
31
32
	/**
33
	 * Sanitize a path (remove double //)
34
	 *
35
	 * @param state
36
	 * @param getters
37
	 */
38
	sanitizePath: (state, getters) => (path) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter state is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
39
		return path.replace('//', '/')
40
	},
41
42
	/**
43
	 * Gets a folder name from it's path
44
	 *
45
	 * @param state
46
	 * @param getters
47
	 */
48
	getNameFromPath:  (state, getters) => (path) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter state is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
49
		if (path === '/') {
50
			return 'Media';
51
		}
52
		return path.split('/').pop();
53
	},
54
55
	/**
56
	 * Compile breadcrumb objects from the current path
57
	 *
58
	 * @param state
59
	 * @param getters
60
	 * @return {{name:String, path: String}[]} - An array of path bit objects containing name, and path property
61
	 */
62
	getPathBits: (state, getters) => (picker) => {
63
		var parts = [];
64
		var here = getters.getPath(picker).split('/');
65
		for( var i = 0; i < here.length; i++ ) {
66
			var part = here[i];
67
			var link = here.slice( 0, i + 1 ).join('/');
68
			if (link !== '') parts.push({"name": part, "path": link});
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
69
		}
70
		return parts;
71
	},
72
73
	/**
74
	 * Get parent path
75
	 * @param state
76
	 * @param getters
77
	 */
78
	getParent: (state, getters) => (picker) => {
79
		var bits = getters.getPathBits(picker);
80
		return bits[bits.length-2];
81
	},
82
83
	/**
84
	 * Get the currently selected firefly file/directory item
85
	 *
86
	 * @param state
87
	 * @param getters
88
	 * @return Object
89
	 */
90
	getSelectedItem: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
91
		// selected item can be the last item in the list of selected.
92
		// Therefore the last item to be selected is the singular selectedItem (if more than one)
93
		var selected = state.pickers[picker].selected;
94
		return selected[selected.length-1];
95
		// return state.pickers[picker].selectedItem;
96
	},
97
98
	/**
99
	 * Whether there is currently a selected item defined for this picker
100
	 *
101
	 * @return boolean
102
	 */
103
	getHasSelectedItem: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
104
		return _.isDefined(state.pickers[picker].selectedItem);
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
105
	},
106
107
	/**
108
	 * Get all selected items
109
	 *
110
	 * @param state
111
	 * @param getters
112
	 * @return Object
113
	 */
114
	getSelectedItems: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
115
		return state.pickers[picker].selected;
116
	},
117
118
	/**
119
	 * Get the items currently loaded into the view (under the current path)
120
	 *
121
	 * @param state
122
	 * @param getters
123
	 * @return Function(pciker) Array of firefly media item Objects
124
	 */
125
	getItems: (state, getters) => (picker) => {
126
		var uploadingItems = getters.getItemsUploadingInPath(picker);
127
		var addUploadItems = [];
128
		_.each(uploadingItems, function(item) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
129
			if (_.find(state.pickers[picker].items, item) == null) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Best Practice introduced by
Comparing _.find(state.pickers.picker.items, item) to null using the == operator is not safe. Consider using === instead.
Loading history...
130
				addUploadItems.push(item);
131
			}
132
		});
133
		// only add if they don't already exist
134
		var items = state.pickers[picker].items.concat(addUploadItems);
135
		// add sorting rules here
136
		return _.chain(items).sortBy('path').sortBy('file.path.name').sortBy('type').value()
137
	},
138
139
	getItemsDeleted: (state, getters) => (picker) => {
140
		return _.filter(getters.getItems(picker), {deleted:1})
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
141
	},
142
143
	/**
144
	 * Get items ordered by name
145
	 * This will order all folders by name first and position them to the tp of the list.
146
	 * The it filters all files
147
	 *
148
	 * @param state
149
	 * @param getters
150
	 * @return Array of firefly media item Objects
151
	 */
152
	getItemsOrderedByName: (state, getters) => (picker) => {
153
		var items = getters.getItems(picker);
154
		var folders = _.sortBy(_.filter(items, {type: 'dir'}), function(item) {
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
155
			return getters.getItemName(item);
156
		});
157
		var files = _.sortBy(_.filter(items, {type: 'file'}), function(item) {
158
			return getters.getItemName(item);
159
		});
160
		return folders.concat(files);
161
	},
162
163
	/**
164
	 * Get the start path of the picker specified by name
165
	 *
166
	 * @param state
167
	 * @param getters
168
	 * @return String - the start path
169
	 */
170
	getStartPath: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
171
		return state.pickers[picker].startPath;
172
	},
173
174
	/**
175
	 * Determine whether an item with the specified id exists in the picker items collection specified by name
176
	 *
177
	 * @param state
178
	 * @param getters
179
	 * @return Boolean
180
	 */
181
	getItemExists: (state, getters) => (picker, id) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
182
		return _.find(state.pickers[picker].items, {id: id});
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
183
	},
184
185
	/**
186
	 * Whether a picker state exists for the given picker name
187
	 *
188
	 * @param state
189
	 * @param getters
190
	 * @return {Boolean}
191
	 */
192
	getPickerExists: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
193
		return _.isDefined(state.pickers[picker]);
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
194
	},
195
196
	/**
197
	 * Whether the item (supplied item.id) is currenctly selected
198
	 *
199
	 * @param {string} picker - the picker name
200
	 * @param {string} itemId - the id of the item to check
201
	 * @return Boolean - whether the item is selected
202
	 */
203
	getIsSelected: (state, getters) => (picker, itemId) => {
204
		var selectedItem = getters.getSelectedItem(picker);
205
		if (_.isUndefined(selectedItem))
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
206
			return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
207
		return selectedItem.id == itemId ||
208
		// this is a bit narly
209
		_.isDefined(_.find(state.pickers[picker].selected, {id:itemId}))
210
	},
211
212
	/**
213
	 * Get whether the item has a registered editor component
214
	 *
215
	 * @param state
216
	 * @param getters
217
	 * @return Boolean
218
	 */
219
	getHasEditor: (state, getters) => (item) => {
220
		return (getters.getEditorForItem(item) !== 'firefly-editor-null');
221
	},
222
223
	/**
224
	 * Get the editor component for the specified item
225
	 *
226
	 * @param state
227
	 * @param getters
228
	 * @return {String} - component name
229
	 */
230
	getEditorForItem: (state, getters) => (item) => {
231
		if (getters.getIsItemImage(item))
232
			return 'firefly-editor-image';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
233
		return 'firefly-editor-null';
234
	},
235
236
	/**
237
	 * Whether the passed in item is an image file
238
	 *
239
	 * @param state
240
	 * @param getters
241
	 * @return {Boolean}
242
	 */
243
	getIsItemImage: (state, getters) => (item) => {
0 ignored issues
show
Unused Code introduced by
The parameter state is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
244
		if (_.isUndefined(item)) return false;
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
245
		if (!item['file']) return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
246
		if (!item['file']['mime_type']) return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
247
		if (item.file.mime_type === 'image/svg') return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
248
		return (item.file.mime_type.substr(0,5) == 'image');
249
	},
250
251
	/**
252
	 * Get the name of an item - a directory or a file
253
	 *
254
	 * @param state
255
	 * @param getters
256
	 * @return {String}
257
	 */
258
	getItemName: (state, getters) => (item) => {
0 ignored issues
show
Unused Code introduced by
The parameter state is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
259
		return FIREFLY.getItemName(item);
0 ignored issues
show
Bug introduced by
The variable FIREFLY seems to be never declared. If this is a global, consider adding a /** global: FIREFLY */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
260
	},
261
262
	/**
263
	 * Whether this item's name is being edited.
264
	 *
265
	 * @param state
266
	 * @param getters
267
	 */
268
	getIsEditingItemName: (state, getters) => (item) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
269
		return state.editingItemNameId === item.id;
270
	},
271
272
	/**
273
	 * Whether we are currently loading items
274
	 *
275
	 * @param state
276
	 * @param getters
277
	 */
278
	getItemsLoading: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
279
		return state.pickers[picker].items_loading;
280
	},
281
282
	/**
283
	 * Get an array of items currently being uploaded
284
	 *
285
	 * @param state
286
	 * @param getters
287
	 * @return Array
288
	 */
289
	getItemsUploading: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
290
		return state.pickers[picker].itemsUploading;
291
	},
292
293
	/**
294
	 * Get an array of items being uploaded in the current selected path
295
	 *
296
	 * @param state
297
	 * @param getters
298
	 * @return Array
299
	 */
300
	getItemsUploadingInPath: (state, getters) => (picker) => {
301
		return _.filter(getters.getItemsUploading(picker), {path: getters.getPath(picker)});
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
302
	},
303
304
	/**
305
	 * Get text showing information about a drop action
306
	 *
307
	 * @param state
308
	 * @param getters
309
	 * @return Object
310
	 */
311
	getDropMoveText: (state, getters) => (picker) => {
312
313
		var dropId = state.pickers[picker].dropOverItemId;
314
		if (!dropId)
315
			return '';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
316
		var item = _.find(state.pickers[picker].items, {id: dropId});
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
317
		var dirName = _.isUndefined(item) ? getters.getNameFromPath(dropId) : getters.getItemName(item);
318
		return 'Move to "' + dirName + '"';
319
	},
320
321
	/**
322
	 * Whether the specified item id is currently being dropped over
323
	 * *Note* the itemId could be the uuid or the full path string
324
	 *
325
	 * @param state
326
	 * @param getters
327
	 */
328
	getIsItemBeingDroppedOver: (state, getters) => (picker, itemId) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
329
		return state.pickers[picker].dropOverItemId == itemId;
330
	},
331
332
	/**
333
	 * Get upload stats
334
	 *
335
	 * @param state
336
	 * @param getters
337
	 * @return {Object} Object similar to pluploadQueue object http://www.plupload.com/docs/v2/QueueProgress
338
	 * {
339
	 *     size: 0, // Total queue file size.
340
	 *     loaded: 0, // Total bytes uploaded.
341
	 *     uploaded: 0, // Number of files uploaded.
342
	 *     failed: 0, // Number of files failed to upload.
343
	 *     queued: 0, // Number of files yet to be uploaded.
344
	 *     percent: 0, // Total percent of the uploaded bytes.
345
	 *     bytesPerSec: 0 // Bytes uploaded per second.
346
	 * }
347
	 */
348
	getUploadingInformation: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
349
		return state.pickers[picker].uploadStats;
350
	},
351
352
	getUploadingFilesStatus: (state, getters) => (picker) => {
353
		var data = getters.getUploadingInformation(picker);
354
		var total = data.uploaded + data.queued + data.failed;
355
		return (data.queued > 0)
356
			? 'Uploaded ' + data.uploaded + ' of ' + total + '. ' + _.formatBytes(data.loaded) + ' of ' + _.formatBytes(data.size)
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
357
			: false;
358
	},
359
360
	getTotalUploadPercent: (state, getters) => (picker) => {
361
		var data = getters.getUploadingInformation(picker);
362
		return data.percent;
363
	},
364
365
	/**
366
	 * Get the browserHistory boolean property - whether the current picker supports url browser history
367
	 * @param state
368
	 * @param getters
369
	 * @returns {function(*): boolean|{default: boolean, type: Boolean | BooleanConstructor}|firefly-media-browser.computed.browserHistory}
370
	 */
371
	getBrowserHistory: (state, getters) => (picker) => {
0 ignored issues
show
Unused Code introduced by
The parameter getters is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
372
		return state.pickers[picker].browserHistory;
373
	}
374
375
};
376