From bbe78892e69edfb1009e2a1cec17daaf760dbb3b Mon Sep 17 00:00:00 2001 From: Fitz Elliott Date: Mon, 30 Dec 2024 11:53:23 -0500 Subject: [PATCH] don't show root folder selector for computing addons * Add hasRootFolder getter to detect if root folder selector should be shown. * Rename `selectedAccount` to `authorizedAccount` to match the invocation syntax. --- .../configured-addon-edit/component.ts | 9 +- .../configured-addon-edit/template.hbs | 172 +++++++++--------- 2 files changed, 94 insertions(+), 87 deletions(-) diff --git a/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts b/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts index b1255dcaa5..29b7e08f52 100644 --- a/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts +++ b/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts @@ -5,12 +5,13 @@ import { TaskInstance } from 'ember-concurrency'; import { Item, ItemType } from 'ember-osf-web/models/addon-operation-invocation'; import AuthorizedAccountModel from 'ember-osf-web/models/authorized-account'; +import AuthorizedComputingAccountModel from 'ember-osf-web/models/authorized-computing-account'; import ConfiguredAddonModel from 'ember-osf-web/models/configured-addon'; interface Args { configuredAddon?: ConfiguredAddonModel; - selectedAccount?: AuthorizedAccountModel; + authorizedAccount?: AuthorizedAccountModel; onSave: TaskInstance; } @@ -23,12 +24,16 @@ export default class ConfiguredAddonEdit extends Component { itemType: ItemType.Folder, }; + get hasRootFolder() { + return !(this.args.authorizedAccount instanceof AuthorizedComputingAccountModel); + } + get invalidDisplayName() { return !this.displayName || this.displayName?.trim().length === 0; } get disableSave() { - return !this.selectedFolder || this.invalidDisplayName || this.args.onSave.isRunning; + return this.hasRootFolder && (!this.selectedFolder || this.invalidDisplayName || this.args.onSave.isRunning); } get onSaveArgs() { diff --git a/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs b/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs index 9a0f280226..75f159ac44 100644 --- a/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs +++ b/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs @@ -28,104 +28,106 @@ @startingFolderId={{this.selectedFolder}} as |fileManager| > -
- - {{#each fileManager.currentPath as |pathItem|}} + {{#if this.hasRootFolder }} +
- {{/each}} -
- - - - - - - - - {{#if fileManager.isLoading}} - - {{else if fileManager.isError}} + {{#each fileManager.currentPath as |pathItem|}} + + {{/each}} + +
{{t 'addons.configure.table-headings.folder-name'}}{{t 'addons.configure.table-headings.select'}}
+ - + + - {{else}} - {{#each fileManager.currentItems as |folder|}} + + + {{#if fileManager.isLoading}} + + {{else if fileManager.isError}} - + + {{else}} + {{#each fileManager.currentItems as |folder|}} + + - + + {{else}} + + + + {{/each}} + {{#if fileManager.hasMore}} + + - - {{else}} - - - - {{/each}} - {{#if fileManager.hasMore}} - - - + {{t 'general.load_more'}} + + + + {{/if}} {{/if}} - {{/if}} - -
{{t 'addons.configure.error-loading-items'}}{{t 'addons.configure.table-headings.folder-name'}}{{t 'addons.configure.table-headings.select'}}
- {{#if folder.mayContainRootCandidates}} - {{t 'addons.configure.error-loading-items'}}
+ {{#if folder.mayContainRootCandidates}} + + {{else}} {{folder.itemName}} - - {{else}} - - - {{folder.itemName}} - - {{/if}} - - {{#if folder.canBeRoot}} - + + {{#if folder.canBeRoot}} + + {{/if}} +
{{t 'addons.configure.no-folders'}}
+
{{t 'addons.configure.no-folders'}}
- -
+ + + {{/if}}