Skip to content

Commit

Permalink
[WIP] first stab at Boa addon ux
Browse files Browse the repository at this point in the history
  • Loading branch information
felliott committed Oct 19, 2023
1 parent a9b403d commit 822c9a3
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/osf-components/addon/components/file-actions-menu/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import StorageManager from 'osf-components/components/storage-provider-manager/s
interface Args {
item: File;
onDelete: () => void;
onSubmitToBoa: () => void;
manager?: StorageManager; // No manager for file-detail page
}

Expand All @@ -19,6 +20,7 @@ export default class FileActionsMenu extends Component<Args> {
@tracked moveModalOpen = false;
@tracked useCopyModal = false;
@tracked renameModalOpen = false;
@tracked isSubmitToBoaModalOpen = false;

@action
closeDeleteModal() {
Expand All @@ -34,4 +36,14 @@ export default class FileActionsMenu extends Component<Args> {
openRenameModal() {
this.renameModalOpen = true;
}

@action
closeSubmitToBoaModal() {
this.isSubmitToBoaModalOpen = false;
}

@action
openSubmitToBoaModal() {
this.isSubmitToBoaModalOpen = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { inject as service } from '@ember/service';
import { waitFor } from '@ember/test-waiters';
import Component from '@glimmer/component';
import { task } from 'ember-concurrency';
import { taskFor } from 'ember-concurrency-ts';
import IntlService from 'ember-intl/services/intl';
import File from 'ember-osf-web/packages/files/file';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

interface Args {
file: File;
closeModal: () => {};
onSubmitToBoa: () => {};
}

export default class SubmitToBoaModal extends Component<Args> {
@service toast!: Toastr;
@service intl!: IntlService;

@task
@waitFor
async confirmSubmitToBoa() {
try {
await taskFor(this.args.file.submitToBoa).perform();
this.args.closeModal();
this.args.onSubmitToBoa();
} catch (e) {
captureException(e);
this.toast.error(getApiErrorMessage(e),
this.intl.t('osf-components.file-browser.submit_to_boa_fail', { fileName: this.args.file.name }));
}
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<OsfDialog @isOpen={{@isOpen}} @onClose={{@closeModal}} as |dialog|>
<dialog.heading>
{{t 'osf-components.file-browser.submit_to_boa'}}
</dialog.heading>
<dialog.main>
{{t 'osf-components.file-browser.confirm_submit_to_boa' fileName=@file.name}}
</dialog.main>
<dialog.footer>
<Button
{{on 'click' (fn (mut @isOpen) false)}}
>
{{t 'general.cancel'}}
</Button>
<Button
@type='destroy'
disabled={{this.confirmSubmitToBoa.isRunning}}
{{on 'click' (perform this.confirmSubmitToBoa)}}
>
{{t 'osf-components.file-browser.confirm_submit_to_boa_yes'}}
</Button>
</dialog.footer>
</OsfDialog>
24 changes: 24 additions & 0 deletions lib/osf-components/addon/components/file-actions-menu/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@
{{t 'general.copy'}}
</Button>
{{/if}}
{{#if @item.currentUserCanDelete}}
{{#if @allowRename}}
<Button
@layout='fake-link'
data-test-submit-to-boa
data-analytics-name='Submit to Boa'
local-class='DropdownItem'
{{on 'click' (queue
dropdown.close
this.openSubmitToBoaModal
)}}
>
<FaIcon @icon='upload' />
{{t 'file_actions_menu.submit_to_boa'}}
</Button>
{{/if}}
{{/if}}
{{/if}}
</dropdown.content>
</ResponsiveDropdown>
Expand All @@ -121,6 +138,13 @@
@manager={{@manager}}
@filesToMove={{array @item}}
/>
<FileActionsMenu::SubmitToBoaModal
@file={{@item}}
@isOpen={{this.isSubmitToBoaModalOpen}}
@closeModal={{this.closeSubmitToBoaModal}}
@manager={{@manager}}
@onSubmit={{@onSubmitToBoa}}
/>
{{/if}}
{{#if @allowRename}}
<FileBrowser::FileRenameModal
Expand Down
5 changes: 5 additions & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ file_actions_menu:
error_message: 'Could not copy to clipboard'
rename: 'Rename'
rename_aria: 'Open rename link'
submit_to_boa: 'Submit to Boa'
node_categories:
analysis: Analysis
communication: Communication
Expand Down Expand Up @@ -2215,6 +2216,10 @@ osf-components:
delete_success: '{itemCount, plural, one {# item} other {# items}} deleted successfully'
deleting: 'Deleting {itemCount, plural, one {# item} other {# items}}'
retry: 'retry delete'
submit_to_boa: 'Submit file to Boa?'
confirm_submit_to_boa: 'Are you sure you want to submit "{fileName}" to Boa?'
confirm_submit_to_boa_yes: 'Submit'
submit_to_boa_fail: 'Failed to submit "{fileName}" to Boa'
help_modal:
heading: 'Using the OSF Files Browser'
providers: 'See All Files in a Provider'
Expand Down

0 comments on commit 822c9a3

Please sign in to comment.