Skip to content

Commit

Permalink
Merge branch 'release/23.02.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Jan 30, 2023
2 parents da93274 + 6e1421b commit 6adacc3
Show file tree
Hide file tree
Showing 80 changed files with 4,775 additions and 322 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [23.02.0] - 2023-01-30
### Added
- GUID metadata

## [23.01.0] - 2023-01-25
### Changed
- Collections Moderation bug and improvements
Expand Down Expand Up @@ -1889,6 +1893,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Quick Files

[23.02.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.02.0
[23.01.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.01.0
[22.11.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/22.11.0
[22.10.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/22.10.0
Expand Down
31 changes: 31 additions & 0 deletions app/adapters/crossref-adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import DS from 'ember-data';
import ModelRegistry from 'ember-data/types/registries/model';
import config from 'ember-get-config';

const { support: { supportEmail } } = config;

export default class CrossrefAdapter extends JSONAPIAdapter {
host = 'https://api.crossref.org';

get headers() {
return {
Accept: '*/*',
};
}

query(_: any, __: any, q: any) {
return super.query(_, __, { ...q, mailto: supportEmail });
}

buildURL<K extends keyof ModelRegistry>(
modelName?: K,
id?: string | null,
snapshot?: DS.Snapshot<K> | null,
requestType?: string,
query?: {},
): string {
const url = super.buildURL(modelName, id, snapshot, requestType, query);
return url;
}
}
7 changes: 7 additions & 0 deletions app/adapters/crossref-funder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import CrossrefAdapter from 'ember-osf-web/adapters/crossref-adapter';

export default class CrossrefFunderAdapter extends CrossrefAdapter {
pathForType() {
return 'funders';
}
}
10 changes: 10 additions & 0 deletions app/adapters/custom-file-metadata-record.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfAdapter from './osf-adapter';

export default class CustomFileMetadataRecordAdapter extends OsfAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'custom-file-metadata-record': CustomFileMetadataRecordAdapter;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/adapters/custom-item-metadata-record.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfAdapter from './osf-adapter';

export default class CustomItemMetadataRecordAdapter extends OsfAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'custom-item-metadata-record': CustomItemMetadataRecordAdapter;
} // eslint-disable-line semi
}
20 changes: 8 additions & 12 deletions app/guid-file/-components/file-detail-layout/styles.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.Container {
.container {
display: flex;
flex-direction: row;
flex-grow: 1;
}

.MainColumn {
.main-column {
flex-grow: 3;
z-index: 1;

Expand All @@ -16,17 +16,20 @@
}
}

.RightColumn {
flex-grow: 1;
.right-column {
border-left: 1px solid #ddd;
display: inline-flex;
flex-basis: 300px;
flex-direction: column;
flex-grow: 1;
width: 28vw;

&.is-closed {
display: none;
}
}

.RightButtons {
.right-buttons {
@media (max-width: 767px) {
display: flex;
flex-direction: row;
Expand All @@ -40,13 +43,6 @@
z-index: 1;
}

.Slider {
position: absolute;
width: 100%;
height: 100%;
transform: translateX(-100%);
}

.slide-in {
animation: slide-in 0.5s forwards;
}
Expand Down
12 changes: 6 additions & 6 deletions app/guid-file/-components/file-detail-layout/template.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div local-class='Container'>
<div local-class='container'>
{{#if @isMobile}}
<div local-class='MainColumn'>
<div local-class='main-column'>
{{yield to='header'}}
<div local-class='RightButtons'>
<div local-class='right-buttons'>
{{yield to='rightButtons'}}
</div>
<div>
Expand All @@ -14,14 +14,14 @@
</div>
</div>
{{else}}
<div local-class='MainColumn'>
<div local-class='main-column'>
{{yield to='header'}}
{{yield to='body'}}
</div>
<div local-class='RightColumn {{if @rightColumnClosed 'is-closed'}}'>
<div local-class='right-column {{if @rightColumnClosed 'is-closed'}}'>
{{yield to='right'}}
</div>
<div local-class='RightButtons'>
<div local-class='right-buttons'>
{{yield to='rightButtons'}}
</div>
{{/if}}
Expand Down
30 changes: 30 additions & 0 deletions app/guid-file/-components/resource-help-dialog/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<OsfDialog
@isOpen={{@isOpen}}
@onClose={{action (mut @isOpen) false}}
@closeOnOutsideClick={{true}}
as |dialog|
>
<dialog.heading>
{{t 'file_detail.resource-help-dialog.heading'}}
</dialog.heading>
<dialog.main tabindex='0'>
{{#if @userCanEdit}}
{{t 'file_detail.resource-help-dialog.write-permission'
htmlSafe=true
parentNodeType=@parentNodeType
}}
{{else}}
{{t 'file_detail.resource-help-dialog.read-only'
htmlSafe=true
}}
{{/if}}
</dialog.main>
<dialog.footer>
<Button
@type='secondary'
{{on 'click' dialog.close}}
>
{{t 'general.close'}}
</Button>
</dialog.footer>
</OsfDialog>
44 changes: 42 additions & 2 deletions app/guid-file/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import RouterService from '@ember/routing/router-service';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { taskFor } from 'ember-concurrency-ts';
import Intl from 'ember-intl/services/intl';
import Media from 'ember-responsive';
import Toast from 'ember-toastr/services/toast';

export default class GuidFile extends Controller {
@service media!: Media;
@service toast!: Toast;
@service router!: RouterService;
@service intl!: Intl;

@tracked revisionsOpened = false;
@tracked tagsOpened = false;
@tracked metadataOpened = !this.isMobile;
@tracked resourceHelpOpen = false;

@tracked viewedVersion?: number;

get rightColumnClosed() {
return !(this.revisionsOpened || this.tagsOpened);
return !(this.revisionsOpened || this.tagsOpened || this.metadataOpened);
}

get isMobile() {
Expand All @@ -29,6 +33,14 @@ export default class GuidFile extends Controller {
return this.media.isTablet;
}

get nodeTypeTranslation() {
const { target } = this.model.fileModel;
const translationKeyBase = 'general';
const translationNode = target.get('isRegistration') ? 'registration'
: target.get('isRoot') ? 'project' : 'component';
return this.intl.t(`${translationKeyBase}.${translationNode}`);
}

@action
changeVersion(version: number) {
this.viewedVersion = version;
Expand All @@ -42,10 +54,14 @@ export default class GuidFile extends Controller {
if (this.isMobile) {
this.revisionsOpened = true;
this.tagsOpened = false;
this.metadataOpened = false;
} else {
if (this.tagsOpened) {
this.tagsOpened = false;
}
if (this.metadataOpened) {
this.metadataOpened = false;
}
this.toggleProperty('revisionsOpened');
}
}
Expand All @@ -55,26 +71,50 @@ export default class GuidFile extends Controller {
if (this.isMobile) {
this.tagsOpened = true;
this.revisionsOpened = false;
this.metadataOpened = false;
} else {
if (this.revisionsOpened) {
this.revisionsOpened = false;
}
if (this.metadataOpened) {
this.metadataOpened = false;
}
this.toggleProperty('tagsOpened');
}
}

@action
toggleMetadata() {
if (this.isMobile) {
this.tagsOpened = false;
this.revisionsOpened = false;
this.metadataOpened = true;
} else {
if (this.revisionsOpened) {
this.revisionsOpened = false;
}
if (this.tagsOpened) {
this.tagsOpened = false;
}
this.toggleProperty('metadataOpened');
}
}

@action
toggleFileRenderer() {
if (this.isMobile) {
this.tagsOpened = false;
this.revisionsOpened = false;
this.metadataOpened = false;
} else {
if (this.rightColumnClosed) {
this.revisionsOpened = true;
this.metadataOpened = true;
this.revisionsOpened = false;
this.tagsOpened = false;
} else {
this.revisionsOpened = false;
this.tagsOpened = false;
this.metadataOpened = false;
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion app/guid-file/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { waitFor } from '@ember/test-waiters';
import HeadTagsService from 'ember-cli-meta-tags/services/head-tags';
import { task } from 'ember-concurrency';
import { taskFor } from 'ember-concurrency-ts';
import Intl from 'ember-intl/services/intl';
import moment from 'moment';

import Institution from 'ember-osf-web/models/institution';
Expand All @@ -23,14 +24,17 @@ import OwnCloudFile from 'ember-osf-web/packages/files/own-cloud-file';
import S3File from 'ember-osf-web/packages/files/s3-file';
import CurrentUserService from 'ember-osf-web/services/current-user';
import RegistrationModel from 'ember-osf-web/models/registration';
import CustomFileMetadataRecordModel from 'ember-osf-web/models/custom-file-metadata-record';

export default class GuidFile extends Route {
@service('head-tags') headTagsService!: HeadTagsService;
@service intl!: Intl;
@service metaTags!: MetaTags;
@service ready!: Ready;
@service currentUser!: CurrentUserService;

headTags?: HeadTagDef[];
metadata!: CustomFileMetadataRecordModel;

@task
@waitFor
Expand All @@ -40,11 +44,15 @@ export default class GuidFile extends Route {
const dateModified = model.dateModified;
const institutions = await model.target.get('affiliatedInstitutions');
const metaTagsData = {
title: model.name,
title: this.metadata.title ? this.metadata.title : model.name,
identifier: model.guid,
publishedDate: dateCreated ? moment(dateCreated).format('YYYY-MM-DD') : undefined,
modifiedDate: dateModified ? moment(dateModified).format('YYYY-MM-DD') : undefined,
institution: institutions.map((institution: Institution) => institution.get('name')),
description: this.metadata.description ?
this.metadata.description :
this.intl.t('general.presented_by_osf'),
language: this.metadata.language ? this.metadata.language : undefined,
};
this.set('headTags', this.metaTags.getHeadTags(metaTagsData));
this.headTagsService.collectHeadTags();
Expand All @@ -55,6 +63,8 @@ export default class GuidFile extends Route {
const { guid } = params;
try {
const file = await this.store.findRecord('file', guid, {include: 'target'});
this.metadata = await this.store.findRecord('custom-file-metadata-record', guid);

const target = await file.target as unknown as RegistrationModel;
if (target.withdrawn === true) {
this.transitionTo('guid-registration', target.id);
Expand Down
Loading

0 comments on commit 6adacc3

Please sign in to comment.