Skip to content

Commit

Permalink
Temporarily hide categories section on registrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Uditi Mehta authored and uditijmehta committed Oct 11, 2024
1 parent 5a9af29 commit e7aa290
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class RegistriesMetadata extends Component {
extendedFields?: boolean;

@tracked provider?: RegistrationProviderModel;
hideCategories = true;
// Private properties
expandCitations = false;

Expand Down
40 changes: 21 additions & 19 deletions lib/registries/addon/components/registries-metadata/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<ProviderMetadataDisplay @field={{metadataField}} @manager={{providerMetadataManager}} />
</field.display>
{{/each}}

</EditableField>
</EditableField::ProviderMetadataManager>
</div>
Expand All @@ -122,24 +122,26 @@
</div>
{{/if}}

<div local-class='Field'>
<EditableField::CategoryManager @node={{this.registration}} as |categoryManager|>
<EditableField
data-analytics-scope='Category'
@manager={{categoryManager}}
@title={{t 'registries.registration_metadata.category'}}
@name='category'
as |field|
>
<field.edit>
<NodeCategoryPicker @manager={{categoryManager}} />
</field.edit>
<field.display>
<NodeCategory @category={{categoryManager.category}} />
</field.display>
</EditableField>
</EditableField::CategoryManager>
</div>
{{#unless this.hideCategories}}
<div local-class='Field'>
<EditableField::CategoryManager @node={{this.registration}} as |categoryManager|>
<EditableField
data-analytics-scope='Category'
@manager={{categoryManager}}
@title={{t 'registries.registration_metadata.category'}}
@name='category'
as |field|
>
<field.edit>
<NodeCategoryPicker @manager={{categoryManager}} />
</field.edit>
<field.display>
<NodeCategory @category={{categoryManager.category}} />
</field.display>
</EditableField>
</EditableField::CategoryManager>
</div>
{{/unless}}

{{#if @extendedFields}}
{{#unless this.registration.isAnonymous}}
Expand Down
25 changes: 4 additions & 21 deletions tests/engines/registries/acceptance/overview/overview-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { capitalize } from '@ember/string';
import { click as untrackedClick, fillIn, settled, triggerKeyEvent } from '@ember/test-helpers';
import { ModelInstance } from 'ember-cli-mirage';
import { setupMirage } from 'ember-cli-mirage/test-support';
Expand Down Expand Up @@ -322,38 +321,22 @@ module('Registries | Acceptance | overview.overview', hooks => {
assert.dom('[data-test-edit-button="description"]').isNotVisible();
});

test('editable registration category', async function(assert) {
test('categories section is hidden on registration page', async function(assert) {
const reg = server.create('registration', {
currentUserPermissions: Object.values(Permission),
category: NodeCategory.Project,
});

await visit(`/${reg.id}/`);

await click('[data-test-edit-button="category"]');
assert.dom('[data-test-select-category] div[class~="ember-power-select-trigger"]')
.hasText(capitalize(reg.category));

await untrackedClick('[data-test-select-category] div[class~="ember-power-select-trigger"]');
assert.dom('.ember-power-select-option').exists({ count: Object.values(NodeCategory).length - 1 });

await selectChoose('[data-test-select-category]', capitalize(NodeCategory.Instrumentation));
await click('[data-test-save-edits]');

reg.reload();
assert.equal(reg.category, NodeCategory.Instrumentation);

// Read user cannot edit
reg.update({ currentUserPermissions: [Permission.Read] });

await visit(`/${reg.id}/`);
assert.dom('[data-test-edit-button="category"]').doesNotExist();
assert.dom('[data-test-select-category]').doesNotExist();

// Write user can edit
reg.update({ currentUserPermissions: [Permission.Read, Permission.Write] });

await visit(`/${reg.id}/`);
assert.dom('[data-test-edit-button="category"]').exists();
assert.dom('[data-test-edit-button="category"]').doesNotExist();
assert.dom('[data-test-select-category]').doesNotExist();
});

test('editable publication doi', async function(assert) {
Expand Down

0 comments on commit e7aa290

Please sign in to comment.