From 5d63aadba0669809ec3de09c23d20d82c97613a7 Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Tue, 12 Oct 2021 17:54:46 -0400 Subject: [PATCH 1/4] Update (again) how we show updates --- .../update-dropdown/list-item/component.ts | 30 +++++++++++++++++++ .../update-dropdown/list-item/styles.scss | 27 +++++++++++++++++ .../update-dropdown/list-item/template.hbs | 11 +++++++ .../registries/update-dropdown/styles.scss | 28 ----------------- .../registries/update-dropdown/template.hbs | 20 +++++-------- .../component.ts | 2 +- .../template.hbs | 0 .../{update-item => list-item}/component.js | 2 +- .../{update-item => list-item}/template.js | 2 +- .../update-dropdown/update-label/component.js | 1 + .../update-dropdown/update-label/template.js | 1 + .../-components/overview-topbar/template.hbs | 1 + 12 files changed, 82 insertions(+), 43 deletions(-) create mode 100644 lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts create mode 100644 lib/osf-components/addon/components/registries/update-dropdown/list-item/styles.scss create mode 100644 lib/osf-components/addon/components/registries/update-dropdown/list-item/template.hbs rename lib/osf-components/addon/components/registries/update-dropdown/{update-item => update-label}/component.ts (92%) rename lib/osf-components/addon/components/registries/update-dropdown/{update-item => update-label}/template.hbs (100%) rename lib/osf-components/app/components/registries/update-dropdown/{update-item => list-item}/component.js (62%) rename lib/osf-components/app/components/registries/update-dropdown/{update-item => list-item}/template.js (63%) create mode 100644 lib/osf-components/app/components/registries/update-dropdown/update-label/component.js create mode 100644 lib/osf-components/app/components/registries/update-dropdown/update-label/template.js diff --git a/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts b/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts new file mode 100644 index 00000000000..4792aa14089 --- /dev/null +++ b/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts @@ -0,0 +1,30 @@ +import { inject as service } from '@ember/service'; +import Component from '@glimmer/component'; +import Intl from 'ember-intl/services/intl'; +import RegistrationModel, { RegistrationReviewStates } from 'ember-osf-web/models/registration'; +import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response'; + +interface Args { + registration: RegistrationModel; + revision: SchemaResponseModel; + isModeratorMode: boolean; + index: number; + totalRevisions: number; +} + +export default class ListItem extends Component { + @service intl!: Intl; + + get shouldShow() { + const { registration, revision, isModeratorMode } = this.args; + if ([RegistrationReviewStates.Pending, RegistrationReviewStates.Initial].includes(registration.reviewsState) + && revision.isOriginalResponse) { + return true; + } + if (isModeratorMode) { + return [RevisionReviewStates.RevisionPendingModeration, + RevisionReviewStates.Approved].includes(revision.reviewsState); + } + return revision.reviewsState === RevisionReviewStates.Approved; + } +} diff --git a/lib/osf-components/addon/components/registries/update-dropdown/list-item/styles.scss b/lib/osf-components/addon/components/registries/update-dropdown/list-item/styles.scss new file mode 100644 index 00000000000..26f516ea603 --- /dev/null +++ b/lib/osf-components/addon/components/registries/update-dropdown/list-item/styles.scss @@ -0,0 +1,27 @@ +.UpdateContainer { + padding-right: 10px; + padding-left: 10px; + padding-top: 10px; + padding-bottom: 10px; + + &:hover { + background-color: rgba(#337ab7, 0.2); + } + + svg { + margin-right: 15px; + } +} + +.UpdateLink { + display: flex; + text-decoration: none; + + &:global(.active) { + font-weight: bold; + } + + &:hover { + text-decoration: none; + } +} diff --git a/lib/osf-components/addon/components/registries/update-dropdown/list-item/template.hbs b/lib/osf-components/addon/components/registries/update-dropdown/list-item/template.hbs new file mode 100644 index 00000000000..49e24b7378c --- /dev/null +++ b/lib/osf-components/addon/components/registries/update-dropdown/list-item/template.hbs @@ -0,0 +1,11 @@ +{{#if this.shouldShow}} +
+ {{!-- Using LinkTo instead of OsfLink due to how queryParams are buggy for setting active state --}} + + + +
+{{/if}} diff --git a/lib/osf-components/addon/components/registries/update-dropdown/styles.scss b/lib/osf-components/addon/components/registries/update-dropdown/styles.scss index 6f8a62dac74..5989a5f91bd 100644 --- a/lib/osf-components/addon/components/registries/update-dropdown/styles.scss +++ b/lib/osf-components/addon/components/registries/update-dropdown/styles.scss @@ -32,35 +32,7 @@ } } -.UpdateContainer { - padding-right: 10px; - padding-left: 10px; - padding-top: 10px; - padding-bottom: 10px; - - &:hover { - background-color: rgba(#337ab7, 0.2); - } - - svg { - margin-right: 15px; - } -} - .UpdateContainerText { display: flex; flex-direction: column; } - -.UpdateLink { - display: flex; - text-decoration: none; - - &:global(.active) { - font-weight: bold; - } - - &:hover { - text-decoration: none; - } -} diff --git a/lib/osf-components/addon/components/registries/update-dropdown/template.hbs b/lib/osf-components/addon/components/registries/update-dropdown/template.hbs index f6d24caf90f..82f38e8afd9 100644 --- a/lib/osf-components/addon/components/registries/update-dropdown/template.hbs +++ b/lib/osf-components/addon/components/registries/update-dropdown/template.hbs @@ -10,7 +10,7 @@ local-class='UpdateText' > {{#if (gt this.selectedRevisionIndex -1)}} - @@ -26,17 +26,13 @@
{{#if this.revisions}} {{#each this.revisions as |revision index|}} - {{#if (eq revision.reviewsState 'approved')}} -
- {{!-- Using LinkTo instead of OsfLink due to how queryParams are buggy for setting active state --}} - - - -
- {{/if}} + {{/each}} {{#if this.shouldShowLoadMore}}
diff --git a/lib/osf-components/addon/components/registries/update-dropdown/update-item/component.ts b/lib/osf-components/addon/components/registries/update-dropdown/update-label/component.ts similarity index 92% rename from lib/osf-components/addon/components/registries/update-dropdown/update-item/component.ts rename to lib/osf-components/addon/components/registries/update-dropdown/update-label/component.ts index 578bbcfee93..981434431de 100644 --- a/lib/osf-components/addon/components/registries/update-dropdown/update-item/component.ts +++ b/lib/osf-components/addon/components/registries/update-dropdown/update-label/component.ts @@ -7,7 +7,7 @@ interface Args { index: number; } -export default class UpdateItem extends Component { +export default class UpdateLabel extends Component { @service intl!: Intl; get label() { diff --git a/lib/osf-components/addon/components/registries/update-dropdown/update-item/template.hbs b/lib/osf-components/addon/components/registries/update-dropdown/update-label/template.hbs similarity index 100% rename from lib/osf-components/addon/components/registries/update-dropdown/update-item/template.hbs rename to lib/osf-components/addon/components/registries/update-dropdown/update-label/template.hbs diff --git a/lib/osf-components/app/components/registries/update-dropdown/update-item/component.js b/lib/osf-components/app/components/registries/update-dropdown/list-item/component.js similarity index 62% rename from lib/osf-components/app/components/registries/update-dropdown/update-item/component.js rename to lib/osf-components/app/components/registries/update-dropdown/list-item/component.js index 1b34743d926..0dbcb0fdd0a 100644 --- a/lib/osf-components/app/components/registries/update-dropdown/update-item/component.js +++ b/lib/osf-components/app/components/registries/update-dropdown/list-item/component.js @@ -1 +1 @@ -export { default } from 'osf-components/components/registries/update-dropdown/update-item/component'; +export { default } from 'osf-components/components/registries/update-dropdown/list-item/component'; diff --git a/lib/osf-components/app/components/registries/update-dropdown/update-item/template.js b/lib/osf-components/app/components/registries/update-dropdown/list-item/template.js similarity index 63% rename from lib/osf-components/app/components/registries/update-dropdown/update-item/template.js rename to lib/osf-components/app/components/registries/update-dropdown/list-item/template.js index c798467c930..1cfe810150e 100644 --- a/lib/osf-components/app/components/registries/update-dropdown/update-item/template.js +++ b/lib/osf-components/app/components/registries/update-dropdown/list-item/template.js @@ -1 +1 @@ -export { default } from 'osf-components/components/registries/update-dropdown/update-item/template'; +export { default } from 'osf-components/components/registries/update-dropdown/list-item/template'; diff --git a/lib/osf-components/app/components/registries/update-dropdown/update-label/component.js b/lib/osf-components/app/components/registries/update-dropdown/update-label/component.js new file mode 100644 index 00000000000..dd77105f00c --- /dev/null +++ b/lib/osf-components/app/components/registries/update-dropdown/update-label/component.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/registries/update-dropdown/update-label/component'; diff --git a/lib/osf-components/app/components/registries/update-dropdown/update-label/template.js b/lib/osf-components/app/components/registries/update-dropdown/update-label/template.js new file mode 100644 index 00000000000..56df5cbab3a --- /dev/null +++ b/lib/osf-components/app/components/registries/update-dropdown/update-label/template.js @@ -0,0 +1 @@ +export { default } from 'osf-components/components/registries/update-dropdown/update-label/template'; diff --git a/lib/registries/addon/overview/-components/overview-topbar/template.hbs b/lib/registries/addon/overview/-components/overview-topbar/template.hbs index f32c4da9c6a..2ef7bd8df64 100644 --- a/lib/registries/addon/overview/-components/overview-topbar/template.hbs +++ b/lib/registries/addon/overview/-components/overview-topbar/template.hbs @@ -11,6 +11,7 @@
{{#if (and @isModeratorMode (not @registration.isAnonymous))}} From a87d60a845a74af80e3afd09b6a1e458a2ecae81 Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Wed, 13 Oct 2021 08:46:26 -0400 Subject: [PATCH 2/4] Post moderator decisions to correct revision --- .../addon/components/make-decision-dropdown/component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/registries/addon/components/make-decision-dropdown/component.ts b/lib/registries/addon/components/make-decision-dropdown/component.ts index 7b7a52cf5ea..7b216f9d6ed 100644 --- a/lib/registries/addon/components/make-decision-dropdown/component.ts +++ b/lib/registries/addon/components/make-decision-dropdown/component.ts @@ -24,6 +24,7 @@ import { SchemaResponseActionTrigger } from 'ember-osf-web/models/schema-respons interface Args { registration: RegistrationModel; + selectedRevisionId: string; } export default class MakeDecisionDropdown extends Component { @@ -126,7 +127,7 @@ export default class MakeDecisionDropdown extends Component { SchemaResponseActionTrigger.RejectRevision, SchemaResponseActionTrigger.AcceptRevision, ] as Array).includes(this.decisionTrigger); const actionType = isSchemaResponseAction ? 'schema-response-action' : 'review-action'; - const target = isSchemaResponseAction ? this.args.registration.schemaResponses.lastObject + const target = isSchemaResponseAction ? this.args.registration.schemaResponses.firstObject : this.args.registration; const newAction = this.store.createRecord(actionType, { actionTrigger: this.decisionTrigger, From c05ea6c7c12f344208824f7e01eaf2ffc454bc41 Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Wed, 13 Oct 2021 13:17:18 -0400 Subject: [PATCH 3/4] Remove unneeded checks to registration state --- .../registries/update-dropdown/list-item/component.ts | 10 ++-------- .../components/registries/update-dropdown/template.hbs | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts b/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts index 4792aa14089..4c5cac71cda 100644 --- a/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts +++ b/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts @@ -1,11 +1,9 @@ import { inject as service } from '@ember/service'; import Component from '@glimmer/component'; import Intl from 'ember-intl/services/intl'; -import RegistrationModel, { RegistrationReviewStates } from 'ember-osf-web/models/registration'; import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response'; interface Args { - registration: RegistrationModel; revision: SchemaResponseModel; isModeratorMode: boolean; index: number; @@ -16,15 +14,11 @@ export default class ListItem extends Component { @service intl!: Intl; get shouldShow() { - const { registration, revision, isModeratorMode } = this.args; - if ([RegistrationReviewStates.Pending, RegistrationReviewStates.Initial].includes(registration.reviewsState) - && revision.isOriginalResponse) { - return true; - } + const { revision, isModeratorMode } = this.args; if (isModeratorMode) { return [RevisionReviewStates.RevisionPendingModeration, RevisionReviewStates.Approved].includes(revision.reviewsState); } - return revision.reviewsState === RevisionReviewStates.Approved; + return revision.isOriginalResponse || revision.reviewsState === RevisionReviewStates.Approved; } } diff --git a/lib/osf-components/addon/components/registries/update-dropdown/template.hbs b/lib/osf-components/addon/components/registries/update-dropdown/template.hbs index 82f38e8afd9..06abe74ba0e 100644 --- a/lib/osf-components/addon/components/registries/update-dropdown/template.hbs +++ b/lib/osf-components/addon/components/registries/update-dropdown/template.hbs @@ -27,7 +27,6 @@ {{#if this.revisions}} {{#each this.revisions as |revision index|}} Date: Wed, 13 Oct 2021 14:57:24 -0400 Subject: [PATCH 4/4] Cleaner logic --- .../registries/update-dropdown/list-item/component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts b/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts index 4c5cac71cda..dc7c38392ed 100644 --- a/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts +++ b/lib/osf-components/addon/components/registries/update-dropdown/list-item/component.ts @@ -15,10 +15,10 @@ export default class ListItem extends Component { get shouldShow() { const { revision, isModeratorMode } = this.args; + const visibleStates = [RevisionReviewStates.Approved]; if (isModeratorMode) { - return [RevisionReviewStates.RevisionPendingModeration, - RevisionReviewStates.Approved].includes(revision.reviewsState); + visibleStates.push(RevisionReviewStates.RevisionPendingModeration); } - return revision.isOriginalResponse || revision.reviewsState === RevisionReviewStates.Approved; + return revision.isOriginalResponse || visibleStates.includes(revision.reviewsState); } }