Skip to content

Commit 1840768

Browse files
adliusfuta-ikedachth0n1xAshley Robinsonfabmiz
authored
Merge versioning feature branch into develop. (#1350)
* Foundation: Mirage * mirage factory initial work * model changes * rename schema-response fac to revision fac * partial * More mirage work * Rewire overview-form-renderer to take responses off of registration or revision * query param fun * [ENG-3034] Add version-metadata component and tests (#1239) * Add version-metadata component and tests * Fix test * prelim for edit-revision route * moar * index route redirect + new isPendingCurrentUser field to revision model * Mirage work for revision-actions * Update models * right nav component * moar * more & more * more edit route fun * mobile * Modal for admin requesting more edits * [ENG-3032] Added UpdateDropdown component for Outcome Reporting (#1244) * resolving merge confilcts. * Removing the deleteRevision() task * Removed extra space * added unit and acceptance tests for versioning. * changed template translation string to Updates, added revisions to Mirage. * Changed translation string to Current per UX Consult meeting. * currently ignoring these lint errors; fixed in upstream commits. * linting. * resolving merge conflicts during rebase. * added translation strings to en-us.yml file. * linting. * improved button layout by changing type from show to create, relocated translation string and favicon. * uncommented Args to reinstate the RegistrationModel. * readding the update-dropdown translations. * proofreading, adding logic for admin or initiatedBy user. * replaced let with const for revisions. * removed extra whitespace. * added CSS formatting for list, removed extra revision. * added function call for allRevisions. * added semicolon, removed unused import. * fixed unused imports, functions. * removed unused functions. Co-authored-by: Ashley Robinson <ashleyrobinson@Admins-MacBook-Pro.local> Co-authored-by: Ashley Robinson <ashley@cos.io> * [ENG-3031] Revisions permissions (#1260) * Add permission handling logic to edit-revision * Update draft submission workflow to match revisions * Add more tests * More updates to tests * Fix a whoopsie-doo * Looking for permissions in all the wrong places * [ENG-3036] Updates to registries moderation (#1263) * Updates to registries moderation * Picking a whoopsie-daisy * More updates for moderation * Add tests * removed unused functionality. * Minor updates before demo * Update dropdown work * updated versionNumber to revisionNumber. * updated translation string for component with no revisions. * readded sort(), fixed versionNumber to revisionNumber. * linting. * updates to the version-metadata logic * demo feedback * update-dropdown paginatioon, moderation updates, demo feedback * WIP tests * Improve registrationlist loading state logic * Rename revision model to schemaResponse * Rename revision-actions to schema-response-actions * changed revision language to update(s), shortened length of messages. * Model changes and update-dropdown modifications * reviewState -> reviewsState * [ENG-3218] Revision files widget (#1282) * Hide file add/remove options for revisions * Update some logic * Make test better * CR feedback * Add in a very important exclamation point * [ENG-3242] Add Justification route to registration edit workflow (#1318) * Add Justification route to registration edit workflow * Fix tests * Fix tests and add new transform for revisedResponses * renamed revisionstates * add isOriginal field * Merge develop into feature branch (#1320) * Add bulk upload widget (#1307) * Add `settings` route, nest `notifications` + bulk upload widget under `settings` * Add bulk upload component * Add tests * Bump ember-template-lint * Bump app version to v21.8.0 * Update Changelog v21.8.0 Co-authored-by: Fabrice Mizero <fabrice@cos.io> * Hide pending updates tab in moderation if provider does not allow updates * Change how revisions in progress are shown in Overview page dropdown (#1321) * Change how revisions in progress are shown * Fix logic * Tests * Better logic * Rename revisedResponses to updatedResponseKeys to match API implementation * misc changes (#1323) * Update trigger names to match API * Update moderator reject trigger * change trigger (#1324) * show correct message when isOriginalResponse (#1325) * Show revisions when registration is pending or initial + Fix moderation actions posting to original revision only (#1326) * Update (again) how we show updates * Post moderator decisions to correct revision * Remove unneeded checks to registration state * Cleaner logic * Reroute users out of edit-revision route when needed (#1328) * Reroute users out of edit-revision route when needed * Remove comments * Another comment removed * Add normalize method to SchemaResponse serializer (#1327) * add normalize method to serializer * Serialize file references Co-authored-by: Futa Ikeda <futa.ikeda@gmail.com> * Restructure moderation tab (#1330) * Restructure moderation tab + tests * Fix tests and other borken bits * Minor updates for versioning (#1333) * Refine update-dropdown for moderator mode * Update wording for registration states * Tweak embargo language * Add loading state logic for revisionstate * Tests * Fix moderator mode tests * Revert uunneeded pdate-label logic changes * 50 cents worth of changes * Update feature branch with latest develop. (#1344) * Add bulk upload widget (#1307) * Add `settings` route, nest `notifications` + bulk upload widget under `settings` * Add bulk upload component * Add tests * Bump ember-template-lint * Bump app version to v21.8.0 * Update Changelog v21.8.0 * A11y fixes (#1246) - Ticket: [ENG-2969](https://openscience.atlassian.net/browse/ENG-2969) - Feature flag: n/a ## Purpose Fixes for accessibility issues on the registries discover page, including the navbar. ## Summary of Changes 1. Navbar auth-dropdown gets an aria-label 2. Sort dropdown gets a role 3. Search bar gets an aria-label ## QA Notes Just needs to be run through the selenium tests for accessibility again. * Fix colors of links on the sign-up page (#1267) - Ticket: [ENG-3169](https://openscience.atlassian.net/browse/ENG-3169) - Feature flag: n/a ## Purpose Fix the link colors on the Sign-Up Page ## Summary of Changes 1. Use $color-link-dark instead of the standard color for links on this form. ## Side Effects No ## QA Notes This change is isolated to the form. * Fix accessibility issues on institutions landing page (#1249) - Ticket: [ENG-3013](https://openscience.atlassian.net/browse/ENG-3013) - Feature flag: n/a ## Purpose Fix accessibility issues on the institutional landing page. ## Summary of Changes 1. Add a 'main' landmark 2. Add an aria label to the load more button 3. Add translation string for the load more button's aria label ## QA Notes This should just need selenium testing to verify the fixes are all good there. * Fix contrast problems on project analytics and registrations tabs (#1269) Tickets: - [ENG-3160](https://openscience.atlassian.net/browse/ENG-3160) - [ENG-3162](https://openscience.atlassian.net/browse/ENG-3162) ## Purpose Fix a couple of contrast problems from the Project:Analytics tab and the Project:Registrations tab. ## Summary of Changes 1. Make active text brighter on the node navbar 2. Make the text darker on the analytics headers ## Side Effects Anywhere else that might use the node navbar styling will have the brighter text, but that shouldn't be used anywhere else, and will hardly be noticeable if it is. ## QA Notes This should just be regression tested with the a11y tools. * Update broken help guid link (#1317) - Ticket: [ENG-3245](https://openscience.atlassian.net/browse/ENG-3245) - Feature flag: n/a ## Purpose Update the help guide link on the project registrations page to one that is not broken. ## Summary of Changes 1. Update the link in both places it's used. ## Side Effects Nope ## QA Notes Make sure the new link goes to a help page for registrations. * Replace bstabs on project-registrations page with ember-aria-tabs (#1271) - Ticket: [ENG-3159](https://openscience.atlassian.net/browse/ENG-3159) - Feature flag: n/a ## Purpose Fix a11y problems on the project/registrations page's tabs by replacing them with better tabs. ## Summary of Changes 1. Add ember-aria-tabs to project 2. Replace BSTabs with ember-aria-tabs on the project/registrations page 3. Fix test selectors 4. Remove unused tab tracking code 5. Ensure proper tracking information is sent to GA 6. Fix styling ## Side Effects The color on the inactive tab changed from blue to black because on BSTabs the tabs are `<a>` tags, but they aren't really functioning as links, so I didn't carry over the color scheme. ## QA Notes This ticket just fixes the tabs. The other issue from this ticket was covered by #1268 Also, there is a lot of functionality in the vicinity of these tabs. Nothing should be broken as it's fairly well tested in our code (and I poked around at it as well), but just so you know. * [ENG-3206] No link if no wiki (#1283) - Ticket: [ENG-3206](https://openscience.atlassian.net/browse/ENG-3206) - Feature flag: n/a ## Purpose Hide the wiki link if there's no wiki on a registration so that we don't have a bad link on the page ## Summary of Changes 1. Add wikiEnabled to model and mirage 2. Use wikiEnabled to determine if we should show the wiki link 3. Test ## Side Effects No, this is fairly isolated ## QA Notes To test, make a project, disable its wiki in the settings, and make a registration of that project. Then visit the registration's page to verify that there's no wiki link. Also verify that registrations with wikis have wiki links. * Make registries landing page more accessible (#1284) - Tickets: [ENG-3176](https://openscience.atlassian.net/browse/ENG-3176) [ENG-3177](https://openscience.atlassian.net/browse/ENG-3177) [ENG-2903](https://openscience.atlassian.net/browse/ENG-2903) - Feature flag: n/a ## Purpose Make the registries landing page more accessible. Two of the items from ENG-3176 should have been handled already by ENG-2969 as mentioned in the ticket. ## Summary of Changes 1. Darken 'See more' link color 2. Darken background of registry services section 3. Add aria-labels to the registry services 4. Trace outline of registry service logos in white 5. Remove RIDIE from registry services list ## Side Effects No, these are pretty isolated, unless the images were being used somewhere else for some reason. ## QA Notes These just need to be run through the accessibility checks again. * Replace bs-tabs with aria-tabs (#1285) - Ticket: [ENG-3181](https://openscience.atlassian.net/browse/ENG-3181) - Feature flag: n/a ## Purpose Make the My Registrations page more accessible by replacing the bs-tabs with ember-aria-tabs. ## Summary of Changes 1. Add ember-aria-tabs to repo and to registries engine 2. Replace bs-tabs with ember-aria-tabs 3. Update test with new selectors 4. Update styles ## Side Effects Should be isolated ## QA Notes This need standard check with your a11y tool, plus a bit of light regression to make sure the tabs still work. * [ENG-3183] Use more contrasty color for active element (#1286) - Ticket: [ENG-3183](https://openscience.atlassian.net/browse/ENG-3183) - Feature flag: n/a ## Purpose Make Add New Registration page more accessible by making the highlighted color more contrasty. ## Summary of Changes 1. Make the text color darker ## Side Effects No, this is isolated to this component. ## QA Notes Should just need a11y testing. * Darken color of upload placeholder text and icon for a11y (#1287) - Ticket: [ENG-3184](https://openscience.atlassian.net/browse/ENG-3184) - Feature flag: n/a ## Purpose Fix the accessibility of the file upload widget by making the placeholder text darker. ## Summary of Changes 1. Darken color of file upload placeholder. ## Side Effects This should be isolated to this widget ## QA Notes Should just need running through accessibility testing. This should also fix every other instance of this component. * A11y fixes (#1289) - Tickets: [ENG-3198](https://openscience.atlassian.net/browse/ENG-3198) [ENG-3199](https://openscience.atlassian.net/browse/ENG-3199) - Feature flag: n/a ## Purpose Fix the accessibility problems on the submitted registration page. ## Summary of Changes 1. Add aria-labels to the forks, bookmarks, and sharing icons on the top-right 2. Increase the contrast of the counts on the left sidebar links 3. This was not in the tickets, but was found by my accessibility checker, so I fixed it here: don't nest interactive controls. There was a dropdown control with a role='button' and a button was nested inside of that. So I changed the nested button to a div, moved the interaction markers (data-test selector and data-analytics), and did a little fixing of the css and tests. This was for the hamburger menu next to the summary in the center section (see second screenshot below) ## Side Effects Shouldn't be. ## QA Notes Just needs checking on the accessibility. * Accessibility fixes for meetings landing page (#1304) - Tickets: [ENG-3211](https://openscience.atlassian.net/browse/ENG-3211) [ENG-3212](https://openscience.atlassian.net/browse/ENG-3212) - Feature flag: n/a ## Purpose Make the meetings landing page more accessible. ## Summary of Changes 1. Darken the link in the register box 2. Add an aria label to the search input ## Side Effects These should be completely isolated. ## QA Notes No functionality should be altered with these changes, so just make sure the accessibility problems go away. * [ENG-3225] Get provider types instead of all registration types (#1302) - Ticket: [ENG-3225](https://openscience.atlassian.net/browse/ENG-3225) - Feature flag: n/a ## Purpose Instead of grabbing the top-level schemas, grab only the provider schemas for the search facet. ## Summary of Changes Aside from just using the provider endpoint, I had to get the OSF provider if we were on a page that doesn't have one. As the component is currently used, there will never be a provider, because it's only visible on the roll-up discover page, and only when the OSF Registries registry is a selected facet. However, there is likely going to be a request in the near future to allow faceting for providers, and the easiest way to do that will be to show the component on provider-specific discover pages. So I made it easy to work with that if we go that direction, otherwise there'll be a little logic in here that's more complicated than it needs to be. ## Side Effects The analytics tracking is going to include the OSF registry provider where it did not before, because there's always going to be a provider now. ## QA Notes This component should only show the schema types that are listed in the admin as being valid for OSF Registries (well, plus the ERPC schema type). * Add aria label to download button (#1305) - Ticket: [ENG-3214](https://openscience.atlassian.net/browse/ENG-3214) - Feature flag: n/a ## Purpose Fix a11y problem on the meetings detail page ## Summary of Changes 1. Add aria-label to download button ## Side Effects Nope ## QA Notes This shouldn't affect functionality, so just needs accessibility testing. * Use text-black instead of brand's primary color for sort-by control (#1306) - Ticket: [ENG-3202](https://openscience.atlassian.net/browse/ENG-3202) - Feature flag: n/a ## Purpose Fix the accessibility problem on some brands' registries discover page ## Summary of Changes 1. Override use of brand primary color on the sort-by control and use text-black instead. ## Side Effects This should be isolated to that control, but it will affect all brands. ## QA Notes Shouldn't affect functionality, just accessibility. * [No ticket] Cache providerIsDefault to avoid problem where this.provider is undefined (#1339) - Ticket: n/a - Feature flag: n/a ## Purpose When doing a search from the registries landing page, we would get an error on the discover page that we couldn't load the registration types. This happened because provider was becoming undefined after the await L45 in the diff for this PR was executed. ## Summary of Changes 1. Wait for attrs to load before running task (h/t @aaxelb) ## Side Effects This should be pretty isolated ## QA Notes Original error was when performing a search from the registries landing page, the error above would show on the discover page. This should no longer happen. * Replace draft metadata's BsTab with ember-aria-tabs (#1247) - Ticket: [ENG-3018](https://openscience.atlassian.net/browse/ENG-3018) - Feature flag: n/a ## Purpose Fix the accessibility problems with the usage of Bootstrap Tabs on the draft metadata page. ## Summary of Changes 1. Replace the BsTab with ember-aria-tabs ## Side Effects Should be all localized to that page and control. I had to do a little work to keep from re-styling the list of subjects. ## QA Notes Make sure the tabs still work, and make sure the aria problems are fixed. * [ENG-3233][ENG-3235] Fix a11y problems on collections discover page (#1309) - Tickets: [ENG-3233](https://openscience.atlassian.net/browse/ENG-3233) [ENG-3235](https://openscience.atlassian.net/browse/ENG-3235) - Feature flag: n/a ## Purpose Fix accessibility problems on the Collections discover page. ## Summary of Changes 1. Add aria-label to search input 2. Remove unnecessary aria-label from drop-down icon 3. Make active Facet marker more contrasty 4. Make "No search results" text more contrasty 5. Move aria label from span around the 'remove' button to the 'remove' button itself. ## Side Effects No, these should be isolated. ## QA Notes These changes shouldn't affect functionality, just accessibility. * Add aria label to search box on meetings detail page (#1337) - Ticket: [https://openscience.atlassian.net/browse/ENG-3214] - Feature flag: n/a ## Purpose Add an aria label to the search box on the meetings detail page. Apparently last time I got the meeting list page, but not the detail page's search box. ## Summary of Changes 1. Add aria label ## Side Effects No ## QA Notes Just needs a11y testing. * Un-mute the description text for accessibility (#1340) - Ticket: [ENG-3235](https://openscience.atlassian.net/browse/ENG-3235) - Feature flag: n/a ## Purpose The description text on the collections discover page was not passing accessibility standards of contrast. This fixes that. ## Summary of Changes 1. Un-mute the text ## Side Effects None ## QA Notes Just needs to run through accessibility testing. * [ENG-3237][ENG-3238] Fix accessibility problems on collections submission page (#1315) - Tickets: [ENG-3237](https://openscience.atlassian.net/browse/ENG-3237) [ENG-3238](https://openscience.atlassian.net/browse/ENG-3238) - Feature flag: n/a ## Purpose Fix the accessibility problems on the Collections submission page ## Summary of Changes 1. Darken header text for each input section 2. Add aria label to search text input 3. Add aria label to search action button 4. Remove hidden label from bibliographic checkboxes 5. Add aria label to bibliographic checkboxes ## Side Effects No, these should be isolated ## QA Notes Functionality shouldn't be affected, only accessibility. * [No ticket] Overview subject search (#1336) - Ticket: [No ticket] - Feature flag: n/a ## Purpose - Fix the registries overview's subject search widget ## Summary of Changes - Load the registration provider before querying its subjects - Update types accordingly ## Side Effects - None ## QA Notes - The subject search widget on the registration overview page should work as-expected now - Registration admins editing the Registration's Metadata using the Metadata panel on the right should be able to search for subjects and apply those subjects onto the registration * bump package.json version; update CHANGELOG Co-authored-by: Fabrice Mizero <fabrice@cos.io> Co-authored-by: Brian J. Geiger <bgeiger@cos.io> Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> * Merge diff-manager feature branch into versioning feature branch. (#1345) * Begin pseudo-code on diff-manager * Other initial groundwork * added logic to diff manager for revision and base revision. * Move diff-manager to a component * added logic for diff manager for updated keys, template file logic. * begin modifying overview form renderer * Add updated to SBGroups and pass @Updated to renderer * some modifications for unified control using DiffManager * filter out unapproved schema-responses * some bug fixes * flipped * fix some tests * fix more tests * test fixing cont. * Some modifications for unified loading of `revision` using DiffManager (#1338) * some modifications for unified control using DiffManager * filter out unapproved schema-responses * some bug fixes * flipped * fix some tests * fix more tests * test fixing cont. * Check if diff is looking at an array Co-authored-by: Futa Ikeda <futa.ikeda@gmail.com> Co-authored-by: Ashley Robinson <ashley@cos.io> * Update registration cards (#1346) * added translation file, resolved merge conflicts. * added Update button to registries/my-registrations endpoint, updated translation file for button. * added CSS to local-class for buttons, removed inline CSS. * added asserts methods for update button for my registrations, updated translation file for multiple buttons, added schema response to registration for rendering hbs. * added Update button to registries/my-registrations endpoint, updated translation file for button. * added CSS to local-class for buttons, removed inline CSS. * added router service to node card, updated route to registries.edit-revision.index, changed type of button to create, added transitionTo function with createNewSchemaResponse on card view. * updated schema response variables in mirage file. * linting: removed comment. * added error message to translation file. * no-verifying using unless until computed is ready. * no-verifying using unless until computed is ready. * added logic for whether dropdown should show if registration review state is accepted or embargo. * using unless. * linting, using unless. * updated local class selectors for scss update button changes. * removed unnecessary logic, user-agent CSS for node card. * updated translation file for no previous available revised responses. * linting. * linting. * linting. * updated translation file: readded bulk upload translations. * Reverting file to original revisionState * Reverting revisionState variable * fixed translation strings for revision state, fixed mirage scenarios for testing. * Update lib/osf-components/addon/components/node-card/template.hbs Updating logic for if user should be able to create an update with on click mouse event. Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> * removed createDOI attribute on Registration model, removed delete button for update links, and improved logic to include embargo states, if user is admin. * readding deleted import from make-decision-dropdown. * linting with unless. * modify some of the functionalities * remove extra * fix tests Co-authored-by: Ashley Robinson <ashley@cos.io> Co-authored-by: chth0n1x <82047646+chth0n1x@users.noreply.github.com> Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> * Feature/registries delete revision button (#1348) * added translation file, resolved merge conflicts. * added delete button to registries side nav, mirage to test, and proper template strings. * move delete button to edit-revision route * minor fixes Co-authored-by: Ashley Robinson <ashley@cos.io> * remove Latest Update label for node-card (#1349) * revert some changes Co-authored-by: Futa Ikeda <futa.ikeda@gmail.com> Co-authored-by: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Co-authored-by: chth0n1x <82047646+chth0n1x@users.noreply.github.com> Co-authored-by: Ashley Robinson <ashleyrobinson@Admins-MacBook-Pro.local> Co-authored-by: Ashley Robinson <ashley@cos.io> Co-authored-by: Fabrice Mizero <fabrice@cos.io> Co-authored-by: Brian J. Geiger <bgeiger@cos.io>
1 parent 54456f0 commit 1840768

File tree

162 files changed

+5329
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+5329
-380
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import OsfAdapter from './osf-adapter';
2+
3+
export default class SchemaResponseActionAdapter extends OsfAdapter {
4+
parentRelationship = 'target';
5+
}
6+
7+
declare module 'ember-data/types/registries/adapter' {
8+
export default interface AdapterRegistry {
9+
'schema-response-action': SchemaResponseActionAdapter;
10+
} // eslint-disable-line semi
11+
}

app/adapters/schema-response.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import OsfAdapter from './osf-adapter';
2+
3+
export default class SchemaResponseAdapter extends OsfAdapter {
4+
}
5+
6+
declare module 'ember-data/types/registries/adapter' {
7+
export default interface AdapterRegistry {
8+
'schema-response': SchemaResponseAdapter;
9+
} // eslint-disable-line semi
10+
}

app/models/node.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ export default class NodeModel extends AbstractNodeModel.extend(Validations, Col
218218
return Array.isArray(this.currentUserPermissions) && this.currentUserPermissions.includes(Permission.Read);
219219
}
220220

221+
@computed('currentUserPermissions.length')
222+
get currentUserIsReadOnly() {
223+
return Array.isArray(this.currentUserPermissions) && this.currentUserPermissions.includes(Permission.Read)
224+
&& this.currentUserPermissions.length === 1;
225+
}
226+
221227
/**
222228
* The type of this node.
223229
*/

app/models/provider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default abstract class ProviderModel extends OsfModel {
5050
@attr('string') facebookAppId!: string;
5151
@attr('boolean') allowSubmissions!: boolean;
5252
@attr('boolean') allowCommenting!: boolean;
53+
@attr('boolean') allowUpdates!: boolean;
5354
@attr('fixstring') reviewsWorkflow!: string | null;
5455
@attr('boolean') reviewsCommentsAnonymous!: boolean | null;
5556
@attr() assets?: Partial<Assets>; // TODO: camelize in transform

app/models/registration.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { buildValidations, validator } from 'ember-cp-validations';
33

44
import DraftRegistrationModel from 'ember-osf-web/models/draft-registration';
55
import ReviewActionModel, { ReviewActionTrigger } from 'ember-osf-web/models/review-action';
6+
import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response';
67
import { RegistrationResponse } from 'ember-osf-web/packages/registration-schema';
78

89
import CommentModel from './comment';
@@ -11,6 +12,7 @@ import InstitutionModel from './institution';
1112
import NodeModel from './node';
1213
import RegistrationProviderModel from './registration-provider';
1314
import RegistrationSchemaModel, { RegistrationMetadata } from './registration-schema';
15+
import { SchemaResponseActionTrigger } from './schema-response-action';
1416
import UserModel from './user';
1517

1618
export enum RegistrationReviewStates {
@@ -25,11 +27,29 @@ export enum RegistrationReviewStates {
2527
PendingWithdraw = 'pending_withdraw',
2628
}
2729

28-
type NonActionableStates = RegistrationReviewStates.Initial
30+
export type NonActionableRegistrationStates = RegistrationReviewStates.Initial
2931
| RegistrationReviewStates.Withdrawn | RegistrationReviewStates.Rejected;
3032

31-
export type ReviewsStateToDecisionMap = Exclude<RegistrationReviewStates, NonActionableStates>;
32-
export const reviewsStateToDecisionMap: { [index in ReviewsStateToDecisionMap]: ReviewActionTrigger[] } = {
33+
export type ActionableRevisionStates = RevisionReviewStates.RevisionPendingModeration;
34+
35+
export type ReviewsStateToDecisionMap =
36+
Exclude<RegistrationReviewStates, NonActionableRegistrationStates> | RevisionReviewStates.RevisionPendingModeration;
37+
export const reviewsStateToDecisionMap: {
38+
[index in ReviewsStateToDecisionMap]: Array<
39+
Exclude<
40+
ReviewActionTrigger,
41+
ReviewActionTrigger.Submit
42+
| ReviewActionTrigger.RequestWithdrawal
43+
| ReviewActionTrigger.RequestEmbargoTermination>
44+
|
45+
Exclude<
46+
SchemaResponseActionTrigger,
47+
SchemaResponseActionTrigger.SubmitRevision
48+
| SchemaResponseActionTrigger.AdminApproveRevision
49+
| SchemaResponseActionTrigger.AdminRejectRevision
50+
>
51+
>
52+
} = {
3353
[RegistrationReviewStates.Accepted]: [ReviewActionTrigger.ForceWithdraw],
3454
[RegistrationReviewStates.Embargo]: [ReviewActionTrigger.ForceWithdraw],
3555
[RegistrationReviewStates.Pending]:
@@ -38,6 +58,8 @@ export const reviewsStateToDecisionMap: { [index in ReviewsStateToDecisionMap]:
3858
[ReviewActionTrigger.AcceptWithdrawal, ReviewActionTrigger.RejectWithdrawal],
3959
[RegistrationReviewStates.PendingWithdrawRequest]: [ReviewActionTrigger.ForceWithdraw],
4060
[RegistrationReviewStates.PendingEmbargoTermination]: [ReviewActionTrigger.ForceWithdraw],
61+
[RevisionReviewStates.RevisionPendingModeration]:
62+
[SchemaResponseActionTrigger.AcceptRevision, SchemaResponseActionTrigger.RejectRevision],
4163
};
4264

4365
const Validations = buildValidations({
@@ -79,9 +101,10 @@ export default class RegistrationModel extends NodeModel.extend(Validations) {
79101
@attr('fixstring') articleDoi!: string | null;
80102
@attr('object') registeredMeta!: RegistrationMetadata;
81103
@attr('registration-responses') registrationResponses!: RegistrationResponse;
82-
@attr('fixstring') reviewsState?: RegistrationReviewStates;
104+
@attr('fixstring') reviewsState!: RegistrationReviewStates;
83105
@attr('fixstring') iaUrl?: string;
84106
@attr('array') providerSpecificMetadata!: ProviderMetadata[];
107+
@attr('fixstring') revisionState!: RevisionReviewStates;
85108
@attr('boolean') wikiEnabled!: boolean;
86109

87110
// Write-only attributes
@@ -121,6 +144,9 @@ export default class RegistrationModel extends NodeModel.extend(Validations) {
121144
@hasMany('review-action', { inverse: 'target' })
122145
reviewActions!: AsyncHasMany<ReviewActionModel> | ReviewActionModel[];
123146

147+
@hasMany('schema-response', { inverse: 'registration' })
148+
schemaResponses!: AsyncHasMany<SchemaResponseModel> | SchemaResponseModel[];
149+
124150
// Write-only relationships
125151
@belongsTo('draft-registration', { inverse: null })
126152
draftRegistration!: DraftRegistrationModel;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { attr, belongsTo, AsyncBelongsTo } from '@ember-data/model';
2+
import { computed } from '@ember/object';
3+
import { inject as service } from '@ember/service';
4+
import Intl from 'ember-intl/services/intl';
5+
import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response';
6+
import UserModel from 'ember-osf-web/models/user';
7+
import OsfModel from './osf-model';
8+
9+
export enum SchemaResponseActionTrigger {
10+
SubmitRevision = 'submit',
11+
AdminApproveRevision = 'approve',
12+
AdminRejectRevision = 'admin_reject',
13+
AcceptRevision = 'accept',
14+
RejectRevision = 'moderator_reject',
15+
}
16+
17+
const TriggerToPastTenseTranslationKey: Record<SchemaResponseActionTrigger, string> = {
18+
submit: 'registries.schemaResponseActions.triggerPastTense.submit',
19+
approve: 'registries.schemaResponseActions.triggerPastTense.approve',
20+
admin_reject: 'registries.schemaResponseActions.triggerPastTense.admin_reject',
21+
accept: 'registries.schemaResponseActions.triggerPastTense.accept',
22+
moderator_reject: 'registries.schemaResponseActions.triggerPastTense.moderator_reject',
23+
};
24+
25+
export default class SchemaResponseActionModel extends OsfModel {
26+
@service intl!: Intl;
27+
28+
@attr('string') actionTrigger!: SchemaResponseActionTrigger;
29+
@attr('fixstring') comment!: string;
30+
@attr('string') fromState!: RevisionReviewStates;
31+
@attr('string') toState!: RevisionReviewStates;
32+
@attr('date') dateCreated!: Date;
33+
@attr('date') dateModified!: Date;
34+
@attr('boolean') visible!: boolean;
35+
36+
@belongsTo('user', { inverse: null })
37+
creator!: AsyncBelongsTo<UserModel> & UserModel;
38+
39+
@belongsTo('schema-response', { inverse: 'actions' })
40+
target!: AsyncBelongsTo<SchemaResponseModel> & SchemaResponseModel;
41+
42+
@computed('actionTrigger')
43+
get triggerPastTense(): string {
44+
const key = TriggerToPastTenseTranslationKey[this.actionTrigger] || '';
45+
return key ? this.intl.t(key) : '';
46+
}
47+
}
48+
49+
declare module 'ember-data/types/registries/model' {
50+
export default interface ModelRegistry {
51+
'schema-response-action': SchemaResponseActionModel;
52+
} // eslint-disable-line semi
53+
}

app/models/schema-response.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { AsyncBelongsTo, AsyncHasMany, attr, belongsTo, hasMany } from '@ember-data/model';
2+
import RegistrationModel from 'ember-osf-web/models/registration';
3+
import RegistrationSchemaModel from 'ember-osf-web/models/registration-schema';
4+
import SchemaResponseActionModel from 'ember-osf-web/models/schema-response-action';
5+
import UserModel from 'ember-osf-web/models/user';
6+
import { RegistrationResponse } from 'ember-osf-web/packages/registration-schema';
7+
8+
import OsfModel from './osf-model';
9+
10+
export enum RevisionReviewStates {
11+
Unapproved = 'unapproved',
12+
RevisionInProgress = 'in_progress',
13+
RevisionPendingModeration = 'pending_moderation',
14+
Approved = 'approved',
15+
}
16+
17+
export default class SchemaResponseModel extends OsfModel {
18+
@attr('fixstring') reviewsState!: RevisionReviewStates;
19+
@attr('date') dateCreated!: Date;
20+
@attr('date') dateModified!: Date;
21+
@attr('fixstring') revisionJustification!: string;
22+
@attr('registration-response-key-array') updatedResponseKeys!: string[];
23+
@attr('registration-responses') revisionResponses!: RegistrationResponse;
24+
@attr('boolean') isOriginalResponse!: boolean;
25+
@attr('boolean') isPendingCurrentUserApproval!: boolean;
26+
27+
@belongsTo('user') initiatedBy!: AsyncBelongsTo<UserModel> & UserModel;
28+
@belongsTo('registration') registration!: AsyncBelongsTo<RegistrationModel> & RegistrationModel;
29+
@belongsTo('registration-schema')
30+
registrationSchema!: AsyncBelongsTo<RegistrationSchemaModel> & RegistrationSchemaModel;
31+
@hasMany('schema-response-action', { inverse: 'target' })
32+
actions!: AsyncHasMany<SchemaResponseActionModel> | SchemaResponseActionModel[];
33+
}
34+
35+
declare module 'ember-data/types/registries/model' {
36+
export default interface ModelRegistry {
37+
'schema-response': SchemaResponseModel;
38+
} // eslint-disable-line semi
39+
}

app/packages/registration-schema/get-schema-block-group.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function isEmpty(input?: string | null) {
88
return false;
99
}
1010

11-
export function getSchemaBlockGroups(blocks: SchemaBlock[] | undefined) {
11+
export function getSchemaBlockGroups(blocks: SchemaBlock[], updatedGroupKeys?: string[]) {
1212
if (!blocks) {
1313
assert('getSchemaBlockGroups() requires blocks');
1414
return undefined;
@@ -52,6 +52,9 @@ export function getSchemaBlockGroups(blocks: SchemaBlock[] | undefined) {
5252
schemaBlockGroup.inputBlock = block;
5353
schemaBlockGroup.registrationResponseKey = block.registrationResponseKey;
5454
schemaBlockGroup.groupType = block.blockType;
55+
if (updatedGroupKeys && updatedGroupKeys.includes(schemaBlockGroup.registrationResponseKey!)) {
56+
schemaBlockGroup.updated = true;
57+
}
5558
break;
5659
case 'select-input-option':
5760
if (schemaBlockGroup.inputBlock) {

app/packages/registration-schema/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export { getPages } from './get-pages';
22
export { getSchemaBlockGroups } from './get-schema-block-group';
33
export { SchemaBlock, SchemaBlockType } from './schema-block';
44
export { SchemaBlockGroup } from './schema-block-group';
5-
export { buildValidation, buildMetadataValidations } from './validations';
5+
export { buildValidation, buildMetadataValidations, buildSchemaResponseValidations } from './validations';
66
export {
77
FileReference,
88
RegistrationResponse,

app/packages/registration-schema/schema-block-group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export interface SchemaBlockGroup {
99
registrationResponseKey?: string | null;
1010
groupType?: string;
1111
blocks?: SchemaBlock[];
12+
updated?: boolean;
1213
}

0 commit comments

Comments
 (0)