Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
import Intl from 'ember-intl/services/intl';
import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response';

interface Args {
revision: SchemaResponseModel;
isModeratorMode: boolean;
index: number;
totalRevisions: number;
}

export default class ListItem extends Component<Args> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the class for items that populate the dropdown and defines which revisions should appaer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This class is responsible for making the decision on whether or not to show a given revision in the dropdown in the overview page

@service intl!: Intl;

get shouldShow() {
const { revision, isModeratorMode } = this.args;
const visibleStates = [RevisionReviewStates.Approved];
if (isModeratorMode) {
visibleStates.push(RevisionReviewStates.RevisionPendingModeration);
}
return revision.isOriginalResponse || visibleStates.includes(revision.reviewsState);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{#if this.shouldShow}}
<div data-test-revision-link={{@index}} local-class='UpdateContainer'>
{{!-- Using LinkTo instead of OsfLink due to how queryParams are buggy for setting active state --}}
<LinkTo @route='overview.index' @query={{hash revisionId=@revision.id}} local-class='UpdateLink'>
<Registries::UpdateDropdown::UpdateLabel
@totalRevisions={{@totalRevisions}}
@index={{@index}}
/>
</LinkTo>
</div>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
local-class='UpdateText'
>
{{#if (gt this.selectedRevisionIndex -1)}}
<Registries::UpdateDropdown::UpdateItem
<Registries::UpdateDropdown::UpdateLabel
@totalRevisions={{this.totalRevisions}}
@index={{this.selectedRevisionIndex}}
/>
Expand All @@ -26,17 +26,12 @@
<div data-test-list-view local-class='UpdatesList'>
{{#if this.revisions}}
{{#each this.revisions as |revision index|}}
{{#if (eq revision.reviewsState 'approved')}}
<div data-test-revision-link={{index}} local-class='UpdateContainer'>
{{!-- Using LinkTo instead of OsfLink due to how queryParams are buggy for setting active state --}}
<LinkTo @route='overview.index' @query={{hash revisionId=revision.id}} local-class='UpdateLink'>
<Registries::UpdateDropdown::UpdateItem
@totalRevisions={{this.totalRevisions}}
@index={{index}}
/>
</LinkTo>
</div>
{{/if}}
<Registries::UpdateDropdown::ListItem
@revision={{revision}}
@isModeratorMode={{@isModeratorMode}}
@totalRevisions={{this.totalRevisions}}
@index={{index}}
/>
{{/each}}
{{#if this.shouldShowLoadMore}}
<div data-test-update-dropdown-show-more local-class='InfinityLoader' {{in-viewport onEnter=(perform this.getRevisionList)}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Args {
index: number;
}

export default class UpdateItem extends Component<Args> {
export default class UpdateLabel extends Component<Args> {
@service intl!: Intl;

get label() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'osf-components/components/registries/update-dropdown/update-label/component';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'osf-components/components/registries/update-dropdown/update-label/template';
Original file line number Diff line number Diff line change
Expand Up @@ -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<Args> {
Expand Down Expand Up @@ -126,7 +127,7 @@ export default class MakeDecisionDropdown extends Component<Args> {
SchemaResponseActionTrigger.RejectRevision, SchemaResponseActionTrigger.AcceptRevision,
] as Array<SchemaResponseActionTrigger | ReviewActionTrigger>).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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<Registries::UpdateDropdown
@registration={{@registration}}
@selectedRevisionId={{@selectedRevisionId}}
@isModeratorMode={{@isModeratorMode}}
/>
</div>
{{#if (and @isModeratorMode (not @registration.isAnonymous))}}
Expand Down