-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make boa modal findable * save WIP on dataset select * futa wisdom attained/accepted * add action; fetch parents properly * enabled addons enabled * cleanups; fix closemodal
- Loading branch information
Showing
14 changed files
with
233 additions
and
2 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 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
99 changes: 99 additions & 0 deletions
99
lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/component.ts
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,99 @@ | ||
import { inject as service } from '@ember/service'; | ||
import { waitFor } from '@ember/test-waiters'; | ||
import Component from '@glimmer/component'; | ||
import { task } from 'ember-concurrency'; | ||
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'; | ||
import config from 'ember-osf-web/config/environment'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
interface Args { | ||
file: File; | ||
isOpen: boolean; | ||
closeModal: () => {}; | ||
} | ||
|
||
export default class SubmitToBoaModal extends Component<Args> { | ||
@service toast!: Toastr; | ||
@service intl!: IntlService; | ||
datasets?: string[]; | ||
@tracked selectedDataset?: string; | ||
|
||
datasets = [ | ||
'2022 Jan/Java', | ||
'2022 Feb/Python', | ||
'2021 Method Chains', | ||
'2021 Aug/Python', | ||
'2021 Aug/Kotlin (small)', | ||
'2021 Aug/Kotlin', | ||
'2021 Jan/ML-Verse', | ||
'2020 August/Python-DS', | ||
'2019 October/GitHub (small)', | ||
'2019 October/GitHub (medium)', | ||
'2019 October/GitHub', | ||
'2015 September/GitHub', | ||
'2013 September/SF (small)', | ||
'2013 September/SF (medium)', | ||
'2013 September/SF', | ||
'2013 May/SF', | ||
'2013 February/SF', | ||
'2012 July/SF', | ||
]; | ||
|
||
@action | ||
onDatasetChange(newDataset: string) { | ||
this.selectedDataset = newDataset; | ||
} | ||
|
||
@task | ||
@waitFor | ||
async confirmSubmitToBoa() { | ||
try { | ||
const file = this.args.file; | ||
const fileModel = file.fileModel; | ||
const parentFolder = await fileModel.get('parentFolder'); | ||
const grandparentFolder = await parentFolder.get('parentFolder'); | ||
const endpoint = config.OSF.url + 'api/v1/project/' + fileModel.target.get('id') + '/boa/submit-job/'; | ||
const payload = { | ||
data: { | ||
nodeId: fileModel.target.get('id'), | ||
name: file.name, | ||
materialized: fileModel.materializedPath, | ||
links: { | ||
download: file.links.download, | ||
upload: file.links.upload, | ||
}, | ||
}, | ||
parent: { | ||
links: { | ||
upload: parentFolder.get('links').upload, | ||
}, | ||
isAddonRoot: !grandparentFolder, | ||
}, | ||
dataset: this.selectedDataset, | ||
}; | ||
await this.args.file.currentUser.authenticatedAJAX({ | ||
url: endpoint, | ||
type: 'POST', | ||
data: JSON.stringify(payload), | ||
xhrFields: { withCredentials: true }, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
this.args.closeModal(); | ||
} 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 })); | ||
return; | ||
} | ||
|
||
this.toast.success( | ||
this.intl.t('osf-components.file-browser.submit_to_boa_success', { fileName: this.args.file.name }), | ||
); | ||
} | ||
} |
Empty file.
33 changes: 33 additions & 0 deletions
33
lib/osf-components/addon/components/file-actions-menu/submit-to-boa-modal/template.hbs
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,33 @@ | ||
<OsfDialog @isOpen={{@isOpen}} @onClose={{@closeModal}} as |dialog|> | ||
<dialog.heading> | ||
{{t 'osf-components.file-browser.submit_to_boa'}} | ||
</dialog.heading> | ||
<dialog.main> | ||
|
||
<p>{{t 'osf-components.file-browser.boa_dataset_spiel'}}</p> | ||
<PowerSelect | ||
@options={{this.datasets}} | ||
@selected={{this.selectedDataset}} | ||
@onChange={{this.onDatasetChange}} | ||
as |dataset| | ||
> | ||
{{dataset}} | ||
</PowerSelect> | ||
<p>{{t 'osf-components.file-browser.confirm_submit_to_boa' fileName=@file.name}}</p> | ||
|
||
</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> |
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
1 change: 1 addition & 0 deletions
1
lib/osf-components/app/components/file-actions-menu/submit-to-boa-modal/component.js
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 @@ | ||
export { default } from 'osf-components/components/file-actions-menu/submit-to-boa-modal/component'; |
1 change: 1 addition & 0 deletions
1
lib/osf-components/app/components/file-actions-menu/submit-to-boa-modal/template.js
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 @@ | ||
export { default } from 'osf-components/components/file-actions-menu/submit-to-boa-modal/template'; |
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