-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-6460] [ENG-6640] Add new preprint version workflow (#2427)
- Ticket: [ENG-6460] [ENG-6640] - Feature flag: n/a ## Purpose - Add a new workflow to create a new preprint version ## Summary of Changes - Add a new `preprint.new-version` route - Add a new `newVersion` argument to the submission-flow component - Invoke `submission-flow` component in the new-version route
- Loading branch information
1 parent
5515ddc
commit 701f265
Showing
21 changed files
with
399 additions
and
78 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
2 changes: 1 addition & 1 deletion
2
app/preprints/-components/submit/preprint-state-machine/status-flow/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
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
7 changes: 4 additions & 3 deletions
7
app/preprints/-components/submit/submission-flow/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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Controller from '@ember/controller'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class PreprintNewVersionController extends Controller { | ||
@action | ||
noop() { | ||
return; | ||
} | ||
} |
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,78 @@ | ||
import Store from '@ember-data/store'; | ||
import Route from '@ember/routing/route'; | ||
import RouterService from '@ember/routing/router-service'; | ||
import { inject as service } from '@ember/service'; | ||
import Toast from 'ember-toastr/services/toast'; | ||
import Intl from 'ember-intl/services/intl'; | ||
|
||
import Theme from 'ember-osf-web/services/theme'; | ||
import MetaTags, { HeadTagDef } from 'ember-osf-web/services/meta-tags'; | ||
import PreprintModel from 'ember-osf-web/models/preprint'; | ||
|
||
export default class PreprintNewVersionRoute extends Route { | ||
@service store!: Store; | ||
@service theme!: Theme; | ||
@service router!: RouterService; | ||
@service metaTags!: MetaTags; | ||
@service toast!: Toast; | ||
@service intl!: Intl; | ||
|
||
|
||
headTags?: HeadTagDef[]; | ||
|
||
buildRouteInfoMetadata() { | ||
return { | ||
osfMetrics: { | ||
providerId: this.theme.id, | ||
}, | ||
}; | ||
} | ||
|
||
async model(args: any) { | ||
try { | ||
const provider = await this.store.findRecord('preprint-provider', args.provider_id); | ||
this.theme.providerType = 'preprint'; | ||
this.theme.id = args.provider_id; | ||
|
||
const preprint: PreprintModel = await this.store.findRecord('preprint', args.guid); | ||
|
||
// TODO: Re-evaluate if re-route logic is necessary | ||
// if (!preprint.canCreateNewVersion) { | ||
// let message = this.intl.t('preprints.submit.new-version.redirect.latest-published', | ||
// { preprintWord: provider.documentType.singular }); | ||
// if (!preprint.currentUserIsAdmin) { | ||
// message = this.intl.t('preprints.submit.new-version.redirect.permission', | ||
// { preprintWord: provider.documentType.singular }); | ||
// } | ||
|
||
// const title = this.intl.t('preprints.submit.new-version.redirect.title'); | ||
// this.toast.info(message, title); | ||
// this.router.transitionTo('preprints.detail', args.provider_id, args.guid); | ||
// return null; | ||
// } | ||
|
||
return { | ||
provider, | ||
preprint, | ||
brand: provider.brand.content, | ||
}; | ||
} catch (e) { | ||
this.router.transitionTo('not-found', `preprints/${args.provider_id}`); | ||
return null; | ||
} | ||
} | ||
|
||
afterModel(model: any) { | ||
const {provider} = model; | ||
if (provider && provider.assets && provider.assets.favicon) { | ||
const headTags = [{ | ||
type: 'link', | ||
attrs: { | ||
rel: 'icon', | ||
href: provider.assets.favicon, | ||
}, | ||
}]; | ||
this.set('headTags', headTags); | ||
} | ||
} | ||
} |
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,9 @@ | ||
<Preprints::-Components::submit::submission-flow | ||
@provider={{this.model.provider}} | ||
@brand={{this.model.brand}} | ||
@newVersion={{true}} | ||
@preprint={{this.model.preprint}} | ||
@header='preprints.submit.title-new-version' | ||
@setPageDirty={{this.noop}} | ||
@resetPageDirty={{this.noop}} | ||
/> |
Oops, something went wrong.