9c0f85d7b6
This partially addresses #7799. Task state filesystems are contained within a subdirectory of their parent allocation, so almost everything that existed for browsing task state filesystems was applicable to browsing allocations, just without the task name prepended to the path. I aimed to push this differential handling into as few contained places as possible. The tests also have significant overlap, so this includes an extracted behavior to run the same tests for allocations and task states.
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
import Component from '@ember/component';
|
|
import { computed } from '@ember/object';
|
|
import { filterBy } from '@ember/object/computed';
|
|
|
|
export default Component.extend({
|
|
tagName: '',
|
|
|
|
model: null,
|
|
|
|
allocation: computed('model', function() {
|
|
if (this.model.allocation) {
|
|
return this.model.allocation;
|
|
} else {
|
|
return this.model;
|
|
}
|
|
}),
|
|
|
|
task: computed('model', function() {
|
|
if (this.model.allocation) {
|
|
return this.model;
|
|
}
|
|
}),
|
|
|
|
type: computed('task', function() {
|
|
if (this.task) {
|
|
return 'task';
|
|
} else {
|
|
return 'allocation';
|
|
}
|
|
}),
|
|
|
|
directories: filterBy('directoryEntries', 'IsDir'),
|
|
files: filterBy('directoryEntries', 'IsDir', false),
|
|
|
|
sortedDirectoryEntries: computed(
|
|
'directoryEntries.[]',
|
|
'sortProperty',
|
|
'sortDescending',
|
|
function() {
|
|
const sortProperty = this.sortProperty;
|
|
|
|
const directorySortProperty = sortProperty === 'Size' ? 'Name' : sortProperty;
|
|
|
|
const sortedDirectories = this.directories.sortBy(directorySortProperty);
|
|
const sortedFiles = this.files.sortBy(sortProperty);
|
|
|
|
const sortedDirectoryEntries = sortedDirectories.concat(sortedFiles);
|
|
|
|
if (this.sortDescending) {
|
|
return sortedDirectoryEntries.reverse();
|
|
} else {
|
|
return sortedDirectoryEntries;
|
|
}
|
|
}
|
|
),
|
|
|
|
});
|