Skip to content

Commit

Permalink
don't show root folder selector for computing addons
Browse files Browse the repository at this point in the history
 * Add hasRootFolder getter to detect if root folder selector should
   be shown.

 * Rename `selectedAccount` to `authorizedAccount` to match the
   invocation syntax.
  • Loading branch information
felliott committed Dec 30, 2024
1 parent 54d61fc commit bbe7889
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
}

Expand All @@ -23,12 +24,16 @@ export default class ConfiguredAddonEdit extends Component<Args> {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,104 +28,106 @@
@startingFolderId={{this.selectedFolder}}
as |fileManager|
>
<div local-class='current-path'>
<Button
data-test-go-to-root
data-analytics-name='Go to root folder'
@layout='fake-link'
aria-label={{t 'addons.configure.go-to-root'}}
{{on 'click' fileManager.goToRoot}}
>
<FaIcon @icon='home' />
{{t 'general.home'}}
</Button>
{{#each fileManager.currentPath as |pathItem|}}
{{#if this.hasRootFolder }}
<div local-class='current-path'>
<Button
data-test-folder-path-option='{{pathItem.itemName}}'
data-analytics-name='Go to ancestor folder'
data-test-go-to-root
data-analytics-name='Go to root folder'
@layout='fake-link'
aria-label={{t 'addons.configure.go-to-folder' folderName=pathItem.itemName}}
{{on 'click' (fn fileManager.goToFolder pathItem)}}
aria-label={{t 'addons.configure.go-to-root'}}
{{on 'click' fileManager.goToRoot}}
>
<FaIcon @icon='chevron-right' />
{{pathItem.itemName}}
<FaIcon @icon='home' />
{{t 'general.home'}}
</Button>
{{/each}}
</div>
<table local-class='file-tree-table'>
<thead>
<tr>
<th>{{t 'addons.configure.table-headings.folder-name'}}</th>
<th>{{t 'addons.configure.table-headings.select'}}</th>
</tr>
</thead>
<tbody local-class='table-body'>
{{#if fileManager.isLoading}}
<LoadingIndicator @dark={{true}} />
{{else if fileManager.isError}}
{{#each fileManager.currentPath as |pathItem|}}
<Button
data-test-folder-path-option='{{pathItem.itemName}}'
data-analytics-name='Go to ancestor folder'
@layout='fake-link'
aria-label={{t 'addons.configure.go-to-folder' folderName=pathItem.itemName}}
{{on 'click' (fn fileManager.goToFolder pathItem)}}
>
<FaIcon @icon='chevron-right' />
{{pathItem.itemName}}
</Button>
{{/each}}
</div>
<table local-class='file-tree-table'>
<thead>
<tr>
<td colspan='2'>{{t 'addons.configure.error-loading-items'}}</td>
<th>{{t 'addons.configure.table-headings.folder-name'}}</th>
<th>{{t 'addons.configure.table-headings.select'}}</th>
</tr>
{{else}}
{{#each fileManager.currentItems as |folder|}}
</thead>
<tbody local-class='table-body'>
{{#if fileManager.isLoading}}
<LoadingIndicator @dark={{true}} />
{{else if fileManager.isError}}
<tr>
<td>
{{#if folder.mayContainRootCandidates}}
<Button
data-test-folder-link='{{folder.itemName}}'
data-analytics-name='Go to folder'
@layout='fake-link'
aria-label={{t 'addons.configure.go-to-folder' folderName=folder.itemName}}
{{on 'click' (fn fileManager.goToFolder folder)}}
>
<td colspan='2'>{{t 'addons.configure.error-loading-items'}}</td>
</tr>
{{else}}
{{#each fileManager.currentItems as |folder|}}
<tr>
<td>
{{#if folder.mayContainRootCandidates}}
<Button
data-test-folder-link='{{folder.itemName}}'
data-analytics-name='Go to folder'
@layout='fake-link'
aria-label={{t 'addons.configure.go-to-folder' folderName=folder.itemName}}
{{on 'click' (fn fileManager.goToFolder folder)}}
>
<span local-class='item-name'>
<FaIcon @icon='folder' />
{{folder.itemName}}
</span>
</Button>
{{else}}
<span local-class='item-name'>
<FaIcon @icon='folder' />
{{folder.itemName}}
</span>
</Button>
{{else}}
<span local-class='item-name'>
<FaIcon @icon='folder' />
{{folder.itemName}}
</span>
{{/if}}
</td>
<td>
{{#if folder.canBeRoot}}
<input
data-test-root-folder-option='{{folder.itemName}}'
data-analytics-name='Select folder'
type='radio'
name='folder'
value={{folder.itemName}}
aria-label={{t 'addons.configure.select-folder' folderName=folder.itemName}}
{{on 'change'(fn this.selectFolder folder)}}
{{/if}}
</td>
<td>
{{#if folder.canBeRoot}}
<input
data-test-root-folder-option='{{folder.itemName}}'
data-analytics-name='Select folder'
type='radio'
name='folder'
value={{folder.itemName}}
aria-label={{t 'addons.configure.select-folder' folderName=folder.itemName}}
{{on 'change'(fn this.selectFolder folder)}}
>
{{/if}}
</td>
</tr>
{{else}}
<tr>
<td colspan='2'>{{t 'addons.configure.no-folders'}}</td>
</tr>
{{/each}}
{{#if fileManager.hasMore}}
<tr>
<td colspan='2'>
<Button
data-test-load-more-folders
data-analytics-name='Load more folders'
@layout='fake-link'
{{on 'click' fileManager.getMore}}
>
{{/if}}
</td>
</tr>
{{else}}
<tr>
<td colspan='2'>{{t 'addons.configure.no-folders'}}</td>
</tr>
{{/each}}
{{#if fileManager.hasMore}}
<tr>
<td colspan='2'>
<Button
data-test-load-more-folders
data-analytics-name='Load more folders'
@layout='fake-link'
{{on 'click' fileManager.getMore}}
>
{{t 'general.load_more'}}
</Button>
</td>
</tr>
{{t 'general.load_more'}}
</Button>
</td>
</tr>
{{/if}}
{{/if}}
{{/if}}
</tbody>
</table>
</tbody>
</table>
{{/if}}
<div local-class='footer-buttons-wrapper'>
<Button
data-test-root-folder-save
Expand Down

0 comments on commit bbe7889

Please sign in to comment.