Files
nomad/ui/app/components/fs/browser.js
Buck Doyle 67e9690b7d Convert to angle bracket invocation (#8075)
This is mostly a direct application of the ember-angle-brackets-codemod.
I manually restored newlines in multi-line component invocations, usually
preserving file line length except for now-non-positional link-to @route.

I needed to rename task to taskState in some cases to avoid Ember
Concurrency naming conflicts.
2020-06-01 14:03:56 -05:00

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;
}
}),
taskState: computed('model', function() {
if (this.model.allocation) {
return this.model;
}
}),
type: computed('taskState', function() {
if (this.taskState) {
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;
}
}
),
});