Skip to content

Commit

Permalink
Merge pull request #693 from datacite/fabrica-improvements-main
Browse files Browse the repository at this point in the history
Fabrica improvements - Final Review
  • Loading branch information
svogt0511 authored Jan 26, 2023
2 parents 56233e6 + d6654e5 commit ddd7973
Show file tree
Hide file tree
Showing 124 changed files with 2,704 additions and 1,642 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
path: test_build/

- name: Cypress Testing
uses: cypress-io/github-action@v3
uses: cypress-io/github-action@v5.0.5
with:
install: false
config: defaultCommandTimeout=15000
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
path: test_build/

- name: Cypress Testing
uses: cypress-io/github-action@v3
uses: cypress-io/github-action@v5.0.5
with:
install: false
config: defaultCommandTimeout=15000
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
path: test_build/

- name: Cypress Testing
uses: cypress-io/github-action@v3
uses: cypress-io/github-action@v5.0.5
with:
install: false
config: defaultCommandTimeout=15000
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
id: extract_variables

- name: Vercel deploy
uses: amondnet/vercel-action@v20.0.0
uses: amondnet/vercel-action@v25.1.0
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
path: test_build/

- name: Cypress Testing
uses: cypress-io/github-action@v3
uses: cypress-io/github-action@v5.0.5
with:
install: false
config: defaultCommandTimeout=15000
Expand Down
4 changes: 2 additions & 2 deletions app/abilities/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ export default Ability.extend({
),
canCreate: computed(
'currentUser.{role_id,client_id}',
'model.{id,query.client-id}',
'model.{id,query.client-id,repository.id}',
function () {
switch (this.get('currentUser.role_id')) {
case 'staff_admin':
return true;
case 'client_admin':
return (
this.get('currentUser.client_id') ===
this.get('model.query.client-id') || this.get('model.id')
this.get('model.query.client-id') || this.get('model.id') || this.get('model.repository.id')
);
default:
return false;
Expand Down
18 changes: 18 additions & 0 deletions app/components/application-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default Component.extend({
title: null,
home: '/',
user: true,
showLogo: true,
navBgColor: '',
navButtonColor: '',

init(...args) {
this._super(...args);
Expand Down Expand Up @@ -59,6 +62,21 @@ export default Component.extend({
} else {
this.set('settings', null);
}

let route = this.router.currentRouteName;

if (route === 'index' || route === 'sign-in' || route === '404') {
this.showLogo = false;
}

let role = this.currentUser.get('roleName');
if (role === 'Member') {
this.set('navBgColor', 'navbar-member');
this.set('navButtonColor', 'navbar-button-member');
} else if (role === 'Consortium') {
this.set('navBgColor', 'navbar-consortium');
this.set('navButtonColor', 'navbar-button-consortium');
}
},

actions: {
Expand Down
2 changes: 2 additions & 0 deletions app/components/bar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { A } from '@ember/array';
export default Component.extend({
tagName: 'div',
classNames: ['col-lg-3', 'col-md-4'],
classNameBindings: ['offset:col-lg-offset-3'],
offset: false,
data: null,
count: computed('data', 'summarize', 'currentYear', function () {
if (this.data) {
Expand Down
14 changes: 14 additions & 0 deletions app/components/create-doi-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';

export default Component.extend({
currentUser: service(),

classNames: [],

didReceiveAttrs() {
this._super(...arguments);

this.set('currentUser', this.currentUser);
},
});
18 changes: 18 additions & 0 deletions app/components/doi-citation-body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Component from '@ember/component';

export default Component.extend({
tagName: 'div',

didReceiveAttrs() {
this._super(...arguments);

},

didRender() {
this._super(...arguments);

window.MathJax.typesetClear([this.get('element')]);
this.element.innerHTML = this.text
window.MathJax.typeset([this.get('element')]);
}
});
7 changes: 6 additions & 1 deletion app/components/doi-citation.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@ export default Component.extend({
style = style === undefined ? 'apa' : style;
this.selectStyle(style);
}
}
},

didRender() {
this._super(...arguments);

},
});
48 changes: 42 additions & 6 deletions app/components/doi-format.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { isBlank } from '@ember/utils';
import mime from 'mime/lite'

const FORMATS = Object.keys(mime._extensions)

function getMatchingFormats(input) {
const matchingFormats = FORMATS.filter(ext => ext.includes(input.toLowerCase()))
return matchingFormats
}

export default Component.extend({
store: service(),

init(...args) {
this._super(...args);
this.formats = FORMATS;

this.selected = this.selected || [];
},
didReceiveAttrs() {
this._super(...arguments);
},

actions: {
updateFormat(value) {
this.set('fragment', value);
createOnEnter(select, e) {
if (
e.keyCode === 13 &&
select.isOpen &&
!select.highlighted &&
!isBlank(select.searchText)
) {
if (!this.selected.includes(select.searchText)) {
this.formats.push(select.searchText);
select.actions.choose(select.searchText);
this.model.get('formats').replace(this.index, 1, [ select.searchText ]);
this.set('formats', FORMATS);
}
}
},
searchFormat(query) {
this.set('formats', getMatchingFormats(query))
},
selectFormat() {
this.model.get('formats').replace(this.index, 1, [ this.fragment ]);
selectFormat(formatExtension) {
this.model.get('formats').replace(this.index, 1, [ formatExtension ]);
},
deleteFormat() {
this.model.get('formats').removeAt(this.index);
},
},
}
}
});
39 changes: 32 additions & 7 deletions app/components/doi-language.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import ISO6391 from 'iso-639-1';

import { isBlank } from '@ember/utils';

const languageList = ISO6391.getAllNames();

Expand All @@ -12,21 +12,46 @@ export default Component.extend({
return ISO6391.getName(this.get('model.language')) !== '' ? ISO6391.getName(this.get('model.language')) : this.get('model.language');
}),

init(...args) {
this._super(...args);

this.selected = this.selected || [];
},

setLanguage(language) {
if (language ? ISO6391.getCode(language) : null) {
this.model.set('language', ISO6391.getCode(language));
} else if (language) {
this.model.set('language', language);
} else {
this.model.set('language', null);
}
},

actions: {
createOnEnter(select, e) {
if (
e.keyCode === 13 &&
select.isOpen &&
!select.highlighted &&
!isBlank(select.searchText)
) {
if (!this.selected.includes(select.searchText)) {
this.setLanguage(select.searchText)
this.languageList.push(select.searchText)
select.actions.choose(select.searchText);
}
}
},
searchLanguage(query) {
let languages = languageList.filter(function(language) {
return language.toLowerCase().startsWith(query.toLowerCase());
});
this.set('languages', languages);
},
selectLanguage(language) {
if (language) {
this.model.set('language', ISO6391.getCode(language));
} else {
this.model.set('language', null);
}
this.set('languages', languageList);
this.setLanguage(language);
this.set('languages', this.languageList);
},
},
});
2 changes: 1 addition & 1 deletion app/components/doi-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ export default Component.extend({
selectMetadata(metadata) {
this.showMetadata(metadata);
},
},
}
});
7 changes: 7 additions & 0 deletions app/components/doi-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ export default Component.extend({
isList: false,
store: service(),
isResearcherProfile: false,

didRender() {
this._super(...arguments);

window.MathJax.typeset([this.get('element')]);
},

});
41 changes: 41 additions & 0 deletions app/components/export-basic-metadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Component from '@ember/component';
import Papa from 'papaparse';
import FileSaver from 'file-saver';
import currentDate from '../utils/current-date';
import formatCreators from '../utils/format-creators';

export default Component.extend({
tagName: '',
classNames: [],

actions: {
exportBasicMetadata(model) {
let dois = [];

this.model.forEach(function(doi) {
dois.push({
"doi" : doi.doi,
"url" : doi.url,
"registered": doi.registered,
"state": doi.state,
"resourceTypeGeneral": doi.types.resourceTypeGeneral,
"resourceType": doi.types.resourceType,
"title": doi.title,
"author": formatCreators(doi.creators, {}),
"publisher": doi.publisher,
"publicationYear": doi.publicationYear
});
});

var csv = Papa.unparse(dois);

var FileSaver = require('file-saver');
var blob = new Blob([csv], {type: "text/csv;charset=utf-8"});
var filename = currentDate()
+ (this.client_id ? '-' + this.client_id : '-' + 'dois')
+ (this.page ? '-' + this.page : '')
+ ".csv";
FileSaver.saveAs(blob, filename);
}
}
})
1 change: 1 addition & 0 deletions app/components/model-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default Component.extend({
'-updated': 'Sort by Date Updated',
'-created': 'Sort by Date Created',
name: 'Sort by DOI',
'title': 'Sort Alphabetically',
relevance: 'Sort by Relevance'
});
} else if (this.modelName === 'Prefix') {
Expand Down
16 changes: 1 addition & 15 deletions app/components/repository-show.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,7 @@ import fetch from 'fetch';
import ENV from 'bracco/config/environment';
import { capitalize } from '@ember/string';
import langs from 'langs';

const clientTypeList = ['repository', 'periodical'];
const softwareList = [
'CKAN',
'Dataverse',
'DSpace',
'EPrints',
'Fedora',
'Invenio',
'Islandora',
'Nesstar',
'Open Journal Systems (OJS)',
'Samvera',
'Other'
];
import { clientTypeList, softwareList } from 'bracco/models/repository'

export default Component.extend({
currentUser: service(),
Expand Down
14 changes: 14 additions & 0 deletions app/components/user-role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';

export default Component.extend({
currentUser: service(),

init(...args) {
this._super(...args);
},

didReceiveAttrs() {
this._super(...arguments);
}
});
Loading

0 comments on commit ddd7973

Please sign in to comment.