-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: add filesystem browsing for allocations (#7951)
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.
- Loading branch information
Showing
34 changed files
with
786 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { equal, or } from '@ember/object/computed'; | ||
|
||
export default Component.extend({ | ||
router: service(), | ||
|
||
tagName: '', | ||
|
||
fsIsActive: equal('router.currentRouteName', 'allocations.allocation.fs'), | ||
fsRootIsActive: equal('router.currentRouteName', 'allocations.allocation.fs-root'), | ||
|
||
filesLinkActive: or('fsIsActive', 'fsRootIsActive'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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; | ||
} | ||
} | ||
), | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
tagName: '', | ||
|
||
allocation: null, | ||
task: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import FSController from './fs'; | ||
|
||
export default FSController.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Controller from '@ember/controller'; | ||
import { computed } from '@ember/object'; | ||
|
||
export default Controller.extend({ | ||
queryParams: { | ||
sortProperty: 'sort', | ||
sortDescending: 'desc', | ||
}, | ||
|
||
sortProperty: 'Name', | ||
sortDescending: false, | ||
|
||
path: null, | ||
allocation: null, | ||
directoryEntries: null, | ||
isFile: null, | ||
stat: null, | ||
|
||
pathWithLeadingSlash: computed('path', function() { | ||
const path = this.path; | ||
|
||
if (path.startsWith('/')) { | ||
return path; | ||
} else { | ||
return `/${path}`; | ||
} | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import FSRoute from './fs'; | ||
|
||
export default FSRoute.extend({ | ||
templateName: 'allocations/allocation/fs', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Route from '@ember/routing/route'; | ||
import RSVP from 'rsvp'; | ||
import notifyError from 'nomad-ui/utils/notify-error'; | ||
|
||
export default Route.extend({ | ||
model({ path = '/' }) { | ||
const decodedPath = decodeURIComponent(path); | ||
const allocation = this.modelFor('allocations.allocation'); | ||
|
||
if (!allocation.isRunning) { | ||
return { | ||
path: decodedPath, | ||
allocation, | ||
}; | ||
} | ||
|
||
return RSVP.all([allocation.stat(decodedPath), allocation.get('node')]) | ||
.then(([statJson]) => { | ||
if (statJson.IsDir) { | ||
return RSVP.hash({ | ||
path: decodedPath, | ||
allocation, | ||
directoryEntries: allocation.ls(decodedPath).catch(notifyError(this)), | ||
isFile: false, | ||
}); | ||
} else { | ||
return { | ||
path: decodedPath, | ||
allocation, | ||
isFile: true, | ||
stat: statJson, | ||
}; | ||
} | ||
}) | ||
.catch(notifyError(this)); | ||
}, | ||
|
||
setupController(controller, { path, allocation, directoryEntries, isFile, stat } = {}) { | ||
this._super(...arguments); | ||
controller.setProperties({ path, allocation, directoryEntries, isFile, stat }); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.