Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6276][ENG-6277][ENG-6278] Add Preprints table #2370

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
63 changes: 63 additions & 0 deletions app/institutions/dashboard/preprints/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import Intl from 'ember-intl/services/intl';

import { ResourceTypeFilterValue } from 'osf-components/components/search-page/component';
import { ObjectListColumn } from '../-components/object-list/component';

export default class InstitutionDashboardPreprints extends Controller {
@service intl!: Intl;

columns: ObjectListColumn[] = [
{ // Title
name: this.intl.t('institutions.dashboard.object-list.table-headers.title'),
getValue: searchResult => searchResult.displayTitle,
},
{ // Link
name: this.intl.t('institutions.dashboard.object-list.table-headers.link'),
type: 'link',
getHref: searchResult => searchResult.indexCard.get('osfIdentifier'),
getLinkText: searchResult => searchResult.indexCard.get('osfGuid'),
},
{ // Date created
name: this.intl.t('institutions.dashboard.object-list.table-headers.created_date'),
getValue: searchResult => searchResult.getResourceMetadataField('dateCreated'),
sortKey: 'dateCreated',
},
{ // Date modified
name: this.intl.t('institutions.dashboard.object-list.table-headers.modified_date'),
getValue: searchResult => searchResult.getResourceMetadataField('dateModified'),
sortKey: 'dateModified',
},
{ // DOI
name: this.intl.t('institutions.dashboard.object-list.table-headers.doi'),
type: 'doi',
},
{ // License
name: this.intl.t('institutions.dashboard.object-list.table-headers.license'),
getValue: searchResult => searchResult.license?.name,
},
{ // Contributor name + permissions
name: this.intl.t('institutions.dashboard.object-list.table-headers.contributor_name'),
type: 'contributors',
},
{ // View count
name: this.intl.t('institutions.dashboard.object-list.table-headers.view_count'),
getValue: searchResult => searchResult.usageMetrics.viewCount,
},
{ // Download count
name: this.intl.t('institutions.dashboard.object-list.table-headers.download_count'),
getValue: searchResult => searchResult.usageMetrics.downloadCount,
},
];

get defaultQueryOptions() {
const identifiers = this.model.institution.iris.join(',');
return {
cardSearchFilter: {
affiliation: identifiers,
resourceType: ResourceTypeFilterValue.Preprints,
},
};
}
}
4 changes: 4 additions & 0 deletions app/institutions/dashboard/preprints/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Route from '@ember/routing/route';

export default class InstitutionsDashboardPreprintsRoute extends Route {
}
14 changes: 6 additions & 8 deletions app/institutions/dashboard/preprints/template.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Institutions::Dashboard::-Components::InstitutionalDashboardWrapper @institution={{this.model.institution}} as |wrapper|>
<wrapper.main>
<div>
{{t 'institutions.dashboard.tabs.preprints'}}
</div>
{{t 'institutions.dashboard.content-placeholder'}}
</wrapper.main>
</Institutions::Dashboard::-Components::InstitutionalDashboardWrapper>
<Institutions::Dashboard::-Components::ObjectList
@institution={{this.model.institution}}
@defaultQueryOptions={{this.defaultQueryOptions}}
@columns={{this.columns}}
@objectType={{t 'institutions.dashboard.object-type-word.preprints'}}
/>
4 changes: 2 additions & 2 deletions tests/acceptance/institutions/dashboard-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ module(moduleName, hooks => {
assert.dom('[data-test-page-tab="preprints"]').hasClass('active', 'Preprints tab is active');
});

test('institutions dashboard: projects and registrations tab', async function(assert) {
test('institutions dashboard: projects, registrations, and preprints tab', async function(assert) {
server.create('institution', {
id: 'has-users',
}, 'withMetrics');

await visit('/institutions/has-users/dashboard');

for (const tab of ['projects', 'registrations']) {
for (const tab of ['projects', 'registrations', 'preprints']) {
await click(`[data-test-page-tab=${tab}]`);

assert.dom(`[data-test-page-tab=${tab}]`).hasClass('active', `${tab} tab is active`);
Expand Down
Loading