Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5e3f4e9
added translation file, resolved merge conflicts.
chth0n1x Oct 12, 2021
74b720c
added Update button to registries/my-registrations endpoint, updated …
chth0n1x Sep 1, 2021
9b8e603
added CSS to local-class for buttons, removed inline CSS.
chth0n1x Sep 2, 2021
f697b75
added asserts methods for update button for my registrations, updated…
chth0n1x Sep 24, 2021
4034249
added Update button to registries/my-registrations endpoint, updated …
chth0n1x Sep 1, 2021
21d67d1
added CSS to local-class for buttons, removed inline CSS.
chth0n1x Sep 2, 2021
d5ba846
added router service to node card, updated route to registries.edit-r…
chth0n1x Sep 28, 2021
c50f2ce
updated schema response variables in mirage file.
chth0n1x Sep 29, 2021
8c84a9d
linting: removed comment.
chth0n1x Sep 29, 2021
b596680
added error message to translation file.
chth0n1x Oct 1, 2021
4d80146
no-verifying using unless until computed is ready.
chth0n1x Oct 7, 2021
a34df18
no-verifying using unless until computed is ready.
chth0n1x Oct 8, 2021
ae57d9a
added logic for whether dropdown should show if registration review s…
chth0n1x Oct 8, 2021
87f8058
using unless.
chth0n1x Oct 11, 2021
90a9593
linting, using unless.
chth0n1x Oct 13, 2021
c8c17b0
updated local class selectors for scss update button changes.
chth0n1x Oct 19, 2021
eb4ec84
removed unnecessary logic, user-agent CSS for node card.
chth0n1x Oct 22, 2021
3b708f7
removed unused assignment in make decision dropdown componenet for re…
chth0n1x Oct 22, 2021
801c4bc
updated translation file for no previous available revised responses.
chth0n1x Oct 22, 2021
df38a17
linting.
chth0n1x Oct 22, 2021
7c989ba
linting.
chth0n1x Oct 22, 2021
144238b
linting.
chth0n1x Oct 22, 2021
260a97e
updated translation file: readded bulk upload translations.
chth0n1x Oct 25, 2021
431fa29
Reverting file to original revisionState
chth0n1x Nov 3, 2021
ce4e77a
Reverting revisionState variable
chth0n1x Nov 3, 2021
51ae967
fixed translation strings for revision state, fixed mirage scenarios …
chth0n1x Nov 3, 2021
0f5eb80
Merge branch 'feature/my-registrations-update-button' of https://gith…
chth0n1x Nov 3, 2021
dc2797d
Update lib/osf-components/addon/components/node-card/template.hbs
chth0n1x Nov 3, 2021
18a0c77
removed createDOI attribute on Registration model, removed delete but…
chth0n1x Nov 3, 2021
8e73b8a
Merge branch 'feature/my-registrations-update-button' of https://gith…
chth0n1x Nov 3, 2021
6d0ad80
readding deleted import from make-decision-dropdown.
chth0n1x Nov 3, 2021
b6aed2e
Merge branch 'feature/versioning-mirage' of https://github.com/Center…
chth0n1x Nov 10, 2021
7e1b1a8
linting with unless.
chth0n1x Nov 10, 2021
771f45e
modify some of the functionalities
adlius Nov 11, 2021
695bcc4
Merge branch 'feature/versioning-mirage' into update-registration-cards
adlius Nov 11, 2021
3befd8a
remove extra
adlius Nov 11, 2021
f4f10c7
fix tests
adlius Nov 11, 2021
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
71 changes: 67 additions & 4 deletions lib/osf-components/addon/components/node-card/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,39 @@ import Component from '@ember/component';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import config from 'ember-get-config';
import Store from '@ember-data/store';

import { layout } from 'ember-osf-web/decorators/component';
import Node, { NodeType } from 'ember-osf-web/models/node';
import Registration from 'ember-osf-web/models/registration';
import Registration, { RegistrationReviewStates } from 'ember-osf-web/models/registration';
import Analytics from 'ember-osf-web/services/analytics';
import pathJoin from 'ember-osf-web/utils/path-join';
import Toast from 'ember-toastr/services/toast';

import styles from './styles';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency';
import { waitFor } from '@ember/test-waiters';
import RouterService from '@ember/routing/router-service';
import SchemaResponseModel, { RevisionReviewStates } from 'ember-osf-web/models/schema-response';
import Intl from 'ember-intl/services/intl';
import RegistrationModel from 'ember-osf-web/models/registration';
import { taskFor } from 'ember-concurrency-ts';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';
import { assert } from '@ember/debug';
import template from './template';
import styles from './styles';


const { OSF: { url: baseURL } } = config;

@layout(template, styles)
@tagName('')
export default class NodeCard extends Component {
@service analytics!: Analytics;

@service router!: RouterService;
@service store!: Store;
@service toast!: Toast;
@service intl!: Intl;
// Optional parameters
node?: Node | Registration;
delete?: (node: Node) => void;
Expand All @@ -28,9 +44,56 @@ export default class NodeCard extends Component {

// Private properties
searchUrl = pathJoin(baseURL, 'search');

@tracked latestSchemaResponse!: SchemaResponseModel;
@tracked showNewUpdateModal = false;
@computed('readOnly', 'node', 'node.{nodeType,userHasWritePermission}')
get showDropdown() {
return !this.readOnly && this.node && this.node.nodeType === NodeType.Fork && this.node.userHasWritePermission;
}

@task
@waitFor
async getLatestRevision(registration: RegistrationModel) {
assert('getLatestRevision requires a registration', registration);
if (
registration.reviewsState === RegistrationReviewStates.Accepted ||
registration.reviewsState === RegistrationReviewStates.Embargo
) {
try {
const revisions = await registration.queryHasMany('schemaResponses');
if (revisions) {
this.latestSchemaResponse = revisions[0];
}
} catch (e) {
const errorMessage = this.intl.t('node_card.schema_response_error');
captureException(e, {errorMessage});
this.toast.error(getApiErrorMessage(e), errorMessage);
}
}
}

didReceiveAttrs() {
if (this.node?.isRegistration) {
taskFor(this.getLatestRevision).perform(this.node as Registration);
}
}

get shouldShowViewChangesButton() {
if (this.node instanceof RegistrationModel) {
return this.node.revisionState === RevisionReviewStates.RevisionInProgress ||
this.node.revisionState === RevisionReviewStates.RevisionPendingModeration;
}
return false;
}

get shouldShowUpdateButton() {
if (this.node instanceof RegistrationModel) {
return this.node.revisionState === RevisionReviewStates.Approved &&
(
this.node.reviewsState === RegistrationReviewStates.Accepted ||
this.node.reviewsState === RegistrationReviewStates.Embargo
);
}
return false;
}
}
2 changes: 1 addition & 1 deletion lib/osf-components/addon/components/node-card/styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.NodeCard {
margin: 10px 0;
margin: 10px;
}

.NodeCard__heading {
Expand Down
75 changes: 56 additions & 19 deletions lib/osf-components/addon/components/node-card/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
{{#if @node.archiving}}
<span class='label label-primary'>{{t 'node_card.registration.statuses.archiving'}}</span> |
{{/if}}

{{#if (eq @node.revisionState 'unapproved')}}
<span class='label label-danger'>{{t 'node_card.registration.statuses.revision_unapproved'}}</span> |
{{else if (eq @node.revisionState 'in_progress')}}
<span class='label label-danger'>{{t 'node_card.registration.statuses.revision_in_progress'}}</span> |
{{else if (eq @node.revisionState 'pending_moderation')}}
<span class='label label-danger'>{{t 'node_card.registration.statuses.revision_pending_moderation'}}</span> |
{{else if (eq @node.revisionState 'approved')}}
<span class='label label-danger'>{{t 'node_card.registration.statuses.revision_approved'}}</span> |
{{/if}}

{{node-card/node-icon category=@node.category}}
<OsfLink
data-analytics-name='Title'
Expand Down Expand Up @@ -79,15 +90,6 @@
{{t 'general.settings'}}
</OsfLink>
</menu.item>
<menu.item role='menuitem'>
<BsButton
data-analytics-scope='Delete'
local-class='NodeCard__dropdown-link'
@onClick={{action @delete @node}}
>
{{t 'general.delete'}}
</BsButton>
</menu.item>
</dd.menu>
</BsDropdown>
</div>
Expand Down Expand Up @@ -157,20 +159,55 @@
</dd>
{{/if}}
</dl>
<OsfLink
data-analytics-name='View registration'
data-test-view-button='{{@node.id}}'
@route='resolve-guid'
@models={{array @node.id}}
>
<Button>
{{t 'node_card.view'}}
</Button>
</OsfLink>
<div local-class='MyRegistrationsButtons'>
<OsfLink
data-analytics-name='View registration'
data-test-view-button='{{@node.id}}'
@route='resolve-guid'
@models={{array @node.id}}
>
<Button
local-class='RegistrationCard_view'
>
{{t 'node_card.view_button'}}
</Button>
</OsfLink>
{{#if this.latestSchemaResponse}}
{{#if this.shouldShowViewChangesButton}}
<OsfLink
data-analytics-name='View changes'
data-test-view-changes-button={{@node.id}}
@route='registries.edit-revision.review'
@models={{array this.latestSchemaResponse.id}}
>
<Button
{{!-- local-class='RegistrationCard_update' --}}
>
{{t 'node_card.view_changes_button'}}
</Button>
</OsfLink>
{{/if}}
{{/if}}
{{#if this.shouldShowUpdateButton}}
<Button
data-test-update-button={{@node.id}}
{{on 'click' (fn (mut this.showNewUpdateModal) true)}}
>
{{t 'node_card.update_button'}}
</Button>
{{/if}}
</div>
{{else}}
<ContentPlaceholders as |placeholder|>
<placeholder.text @lines={{2}} />
</ContentPlaceholders>
{{/if}}
</div>
</div>
{{#if @node.isRegistration}}
<Registries::NewUpdateModal
@isOpen={{this.showNewUpdateModal}}
@onClose={{fn (mut this.showNewUpdateModal) false}}
@registration={{@node}}
/>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { layout } from 'ember-osf-web/decorators/component';

import { assert } from '@ember/debug';
import DraftRegistrationModel from 'ember-osf-web/models/draft-registration';
import RevisionModel from 'ember-osf-web/models/revision';
import { PageManager } from 'ember-osf-web/packages/registration-schema/page-manager';
import SchemaResponseModel from 'ember-osf-web/models/schema-response';
import styles from './styles';
import template from './template';

Expand All @@ -16,7 +16,7 @@ export default class PageRenderer extends Component {
// Required param
pageManager!: PageManager;
draftRegistration?: DraftRegistrationModel;
revision?: RevisionModel;
revision?: SchemaResponseModel;

init() {
super.init();
Expand Down
24 changes: 19 additions & 5 deletions mirage/scenarios/registrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,27 @@ export function registrationScenario(
const currentUserWrite = server.create('registration', {
id: 'writr',
registrationSchema: server.schema.registrationSchemas.find('prereg_challenge'),
currentUserPermissions: [Permission.Read, Permission.Write],
reviewsState: RegistrationReviewStates.Accepted,
revisionState: RevisionReviewStates.Approved,
currentUserPermissions: [Permission.Admin],
providerSpecificMetadata: [
{ field_name: 'Metadata field 1', field_value: '' },
{ field_name: 'Another Field', field_value: 'Value 2' },
],
});

server.create('schema-response', {
id: 'copyEditWritr1',
revisionJustification: 'Copy Edit',
reviewsState: RevisionReviewStates.RevisionInProgress,
revisionResponses: {
q1: 'Hello',
q2: ['List of greetings'],
},
initiatedBy: currentUser,
registration: currentUserWrite,
});

server.create('contributor', { users: currentUser, node: currentUserWrite });

const registrationResponses = {
Expand Down Expand Up @@ -144,7 +158,7 @@ export function registrationScenario(
}, 'withContributors', 'withReviewActions');

server.create('schema-response', {
id: 'copyEdit',
id: 'copyEditSilicon',
revisionJustification: 'Copy Edit',
revisionResponses: {
q1: 'Good Morning',
Expand All @@ -159,9 +173,9 @@ export function registrationScenario(
title: 'Revision Model: Contributor View (non-Admin/Mod)',
registrationSchema: server.schema.registrationSchemas.find('testSchema'),
provider: egap,
reviewsState: RegistrationReviewStates.Accepted,
reviewsState: RegistrationReviewStates.Withdrawn,
registeredBy: currentUser,
revisionState: RevisionReviewStates.Approved,
revisionState: RevisionReviewStates.RevisionInProgress,
currentUserPermissions: [Permission.Write],
providerSpecificMetadata: [
{ field_name: 'IP Address', field_value: '127.0.0.1' },
Expand All @@ -174,7 +188,7 @@ export function registrationScenario(
}, 'withContributors', 'withReviewActions');

server.create('schema-response', {
id: 'copyEdit',
id: 'copyEditTungsten',
revisionJustification: 'Copy Edit',
revisionResponses: {
q1: 'Good Morning',
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/components/node-card/component-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setupIntl, TestContext } from 'ember-intl/test-support';
import { setupIntl, t, TestContext } from 'ember-intl/test-support';
import { RevisionReviewStates } from 'ember-osf-web/models/schema-response';
import { setupRenderingTest } from 'ember-qunit';
import moment from 'moment';
import { module, test } from 'qunit';
Expand All @@ -23,6 +24,7 @@ module('Integration | Component | node-card', hooks => {
const registration = server.create('registration', {
tags: ['a', 'b', 'c'],
description: 'Through the night',
revisionState: RevisionReviewStates.Approved,
});
server.create('contributor', { node: registration, index: 0, bibliographic: true });
server.create('contributor', { node: registration, index: 1, bibliographic: true });
Expand Down Expand Up @@ -104,5 +106,8 @@ module('Integration | Component | node-card', hooks => {
assert.dom(`[data-test-tags-widget-tag='${tag}']`).hasText(tag, 'Tag is correct');
}
assert.dom(`[data-test-view-button='${registration.id}']`).exists('View button exists');

assert.dom('[data-test-update-button]').exists('Update button exists.');
assert.dom('[data-test-update-button]').hasText(t('node_card.update_button').toString());
});
});
16 changes: 13 additions & 3 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,11 @@ node_card:
private_tooltip: 'This registration is private'
timestamp_label: 'Registered:'
statuses:
pending_registration_approval: 'Pending registration'
pending_registration_approval: 'Pending registration approval'
revision_pending_moderation: 'Pending moderation'
revision_in_progress: 'Revision in progress'
revision_unapproved: 'Revision unapproved'
revision_approved: 'Latest Update'
pending_embargo_approval: 'Pending embargo'
pending: 'Pending moderation'
embargo: Embargoed
Expand All @@ -596,7 +600,11 @@ node_card:
last_updated: 'Last updated:'
registry: 'Registry:'
options: Options
view: 'View'
view_button: 'View'
update_button: 'Update'
view_changes_button: 'View changes'
schema_response_error: 'Updates irretreivable.'

forks:
fork: Fork
title: Forks
Expand Down Expand Up @@ -1206,6 +1214,8 @@ registries:
warning: 'This will cancel any approvals from other admin contributors and return the registration back to its draft form for additional changes.'
reason: 'What additional changes need to be made and why?'
submit: 'Submit'


index:
lead: 'The <span class="f-w-lg">open</span> registries network'
see_example: 'See an example'
Expand Down Expand Up @@ -1589,7 +1599,7 @@ registries:
modalBodyFirst: 'Updates to registration responses can be updated by clicking “Next”.<br>Edits to metadata including Description, Category, License, Publication DOI, and Tags are done on the registration by clicking the '
modalBodySecond: ' icon.'
modalBodyNoUpdates: 'The {registryName} does not allow updates for this registration template.<br>Contact their registy if you have any questions.'
learnMore: 'Read NEEDS LINK to learn more'
learnMore: 'Click <a href="https://help.osf.io/hc/en-us/articles/360035806634-Edit-Registration-Metadata" target="_blank">here</a> to learn more'
next: Next
meetings:
index:
Expand Down