diff --git a/lib/osf-components/addon/components/file-actions-menu/component.ts b/lib/osf-components/addon/components/file-actions-menu/component.ts index bc425f44d1b..2b0d39aaf76 100644 --- a/lib/osf-components/addon/components/file-actions-menu/component.ts +++ b/lib/osf-components/addon/components/file-actions-menu/component.ts @@ -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 } @@ -19,6 +20,7 @@ export default class FileActionsMenu extends Component { @tracked moveModalOpen = false; @tracked useCopyModal = false; @tracked renameModalOpen = false; + @tracked isSubmitToBoaModalOpen = false; @action closeDeleteModal() { @@ -34,4 +36,14 @@ export default class FileActionsMenu extends Component { openRenameModal() { this.renameModalOpen = true; } + + @action + closeSubmitToBoaModal() { + this.isSubmitToBoaModalOpen = false; + } + + @action + openSubmitToBoaModal() { + this.isSubmitToBoaModalOpen = true; + } } diff --git a/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/component.ts b/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/component.ts new file mode 100644 index 00000000000..76201c1f9eb --- /dev/null +++ b/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/component.ts @@ -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 { + @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 })); + } + } +} diff --git a/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/styles.scss b/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/styles.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/template.hbs b/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/template.hbs new file mode 100644 index 00000000000..dcbd032def4 --- /dev/null +++ b/lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/template.hbs @@ -0,0 +1,22 @@ + + + {{t 'osf-components.file-browser.submit_to_boa'}} + + + {{t 'osf-components.file-browser.confirm_submit_to_boa' fileName=@file.name}} + + + + + + \ No newline at end of file diff --git a/lib/osf-components/addon/components/file-actions-menu/template.hbs b/lib/osf-components/addon/components/file-actions-menu/template.hbs index 5ddbdf2af0e..b39a707e794 100644 --- a/lib/osf-components/addon/components/file-actions-menu/template.hbs +++ b/lib/osf-components/addon/components/file-actions-menu/template.hbs @@ -109,6 +109,23 @@ {{t 'general.copy'}} {{/if}} + {{#if @item.currentUserCanDelete}} + {{#if @allowRename}} + + {{/if}} + {{/if}} {{/if}} @@ -121,6 +138,13 @@ @manager={{@manager}} @filesToMove={{array @item}} /> + {{/if}} {{#if @allowRename}}