Skip to content

Commit

Permalink
Merge pull request #220 from ror-community/ember-upgrade-without-v1
Browse files Browse the repository at this point in the history
Ember upgrade without v1
  • Loading branch information
lizkrznarich authored Dec 13, 2024
2 parents bfb7d91 + d9656dd commit 60835e1
Show file tree
Hide file tree
Showing 26 changed files with 1,406 additions and 1,746 deletions.
4 changes: 1 addition & 3 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
API_URL_V1=https://api.dev.ror.org/v1
API_URL_V2=https://api.dev.ror.org/v2
API_URL=https://api.dev.ror.org/v2
SENTRY_DSN=https://[email protected]/1422597
BASE_URL=https://dev.ror.org
LAUNCH_DARKLY_CLIENT_SIDE_ID=6390f62d05087a11e466bfc9
4 changes: 1 addition & 3 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
API_URL_V1=https://api.ror.org/v1
API_URL_V2=https://api.ror.org/v2
API_URL=https://api.ror.org/v2
SENTRY_DSN=https://[email protected]/1422597
BASE_URL=https://ror.org
LAUNCH_DARKLY_CLIENT_SIDE_ID=636d08a3d56cf611cc88019d
4 changes: 1 addition & 3 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
API_URL_V1=https://api.staging.ror.org/v1
API_URL_V2=https://api.staging.ror.org/v2
API_URL=https://api.staging.ror.org/v2
SENTRY_DSN=https://[email protected]/1422597
BASE_URL=https://staging.ror.org
LAUNCH_DARKLY_CLIENT_SIDE_ID=636d08a3d56cf611cc88019c
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
root: true,
parser: "babel-eslint",
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
Expand Down
7 changes: 1 addition & 6 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import ENV from 'ror-app/config/environment';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';

export default JSONAPIAdapter.extend({
launchDarkly: service(),
host: computed('launchDarkly.variation', function() {
return this.launchDarkly.variation('v2_ui') ? ENV.API_URL_V2 : ENV.API_URL_V1;
}),
host: ENV.API_URL
});
7 changes: 1 addition & 6 deletions app/adapters/organization.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import ENV from 'ror-app/config/environment';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';

export default JSONAPIAdapter.extend({
launchDarkly: service(),
host: computed('launchDarkly.variation', function() {
return this.launchDarkly.variation('v2_ui') ? ENV.API_URL_V2 : ENV.API_URL_V1;
}),
host: ENV.API_URL,

urlForFindRecord(id, modelName) {
return `${this.host}/${modelName}s/ror.org/${id}`;
Expand Down
File renamed without changes.
79 changes: 0 additions & 79 deletions app/components/v1/organization-item.js

This file was deleted.

8 changes: 4 additions & 4 deletions app/router.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
});
class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function() {
this.route('organizations', { path: '/' }, function() {
Expand Down
11 changes: 2 additions & 9 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import Route from '@ember/routing/route';

export default Route.extend({
beforeModel(){
let user = {
key: 'user-key-123abc',
anonymous: true
};
return this.launchDarkly.initialize(user);
}
});
export default class ApplicationRoute extends Route {
}
10 changes: 5 additions & 5 deletions app/routes/error.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Route from '@ember/routing/route';
import ENV from 'ror-app/config/environment';

export default Route.extend({
redirect: function() {
window.location.replace(ENV.BASE_URL + "/error");
}
});
export default class ErrorRoute extends Route {
redirect() {
window.location.replace(ENV.BASE_URL + "/error");
}
}
5 changes: 3 additions & 2 deletions app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Route from '@ember/routing/route';

export default Route.extend({
});
export default class IndexRoute extends Route {

}
82 changes: 41 additions & 41 deletions app/routes/organizations/index.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default Route.extend({
model(params) {
/*Escape Elasticsearch reserved chars
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters*/
if(params.query){
let ror_id = ''
// eslint-disable-next-line
let re1 = new RegExp("^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$");
// eslint-disable-next-line
let re2 = new RegExp("^http(s)?:\/\/ror\.org\/0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$");
// eslint-disable-next-line
let re3 = new RegExp("^ror\.org\/0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$")
if(re1.test(params.query)){
ror_id = params.query
}
if(re2.test(params.query)){
// eslint-disable-next-line
ror_id = params.query.replace(/http(s)?:\/\/ror\.org\//g, '')
}
if(re3.test(params.query)){
// eslint-disable-next-line
ror_id = params.query.replace(/ror\.org\//g, '')
}
if(ror_id){
window.location.href = ror_id
return;
} else {
// eslint-disable-next-line
params.query = params.query.replace(/([\+\-\=\&\|\>\<\!\(\)\{\}\\\[\]\^\~\*\?\:\/])/g, "\\$1");
}
}
return this.store.query('organization', params).then(function(model) {
return model;
}).catch(function (reason) {
console.log(reason);
return [];
});
},
export default class OrganizationsIndexRoute extends Route {
@service store;

queryParams: {
queryParams = {
query: {
refreshModel: true
},
Expand All @@ -52,6 +17,41 @@ export default Route.extend({
filter: {
refreshModel: true
}
}
};

model(params) {
// Escape Elasticsearch reserved chars
if (params.query) {
let ror_id = '';
const re1 = new RegExp("^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$");
const re2 = new RegExp("^http(s)?:\/\/ror\.org\/0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$"); // eslint-disable-line no-useless-escape
const re3 = new RegExp("^ror\.org\/0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$"); // eslint-disable-line no-useless-escape

});
if (re1.test(params.query)) {
ror_id = params.query;
}

if (re2.test(params.query)) {
ror_id = params.query.replace(/http(s)?:\/\/ror\.org\//g, '');
}

if (re3.test(params.query)) {
ror_id = params.query.replace(/ror\.org\//g, '');
}

if (ror_id) {
window.location.href = ror_id;
return;
} else {
params.query = params.query.replace(/([\+\-\=\&\|\>\<\!\(\)\{\}\\\[\]\^\~\*\?\:\/])/g, "\\$1"); // eslint-disable-line no-useless-escape
}
}

return this.store.query('organization', params).then((model) => {
return model;
}).catch((reason) => {
console.log(reason);
return [];
});
}
}
18 changes: 7 additions & 11 deletions app/routes/organizations/show.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class OrganizationsShowRoute extends Route {
@service store;

export default Route.extend({
model(params) {
//let self = this;
return this.store.findRecord('organization', params.organization_id).then(function(organization) {
return organization;
})
},
actions: {
queryParamsDidChange() {
this.refresh();
}
const { organization_id } = params;
return this.store.findRecord('organization', organization_id);
}
});
}
3 changes: 1 addition & 2 deletions app/services/config-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ import Service from '@ember/service';
import config from '../config/environment';

export default Service.extend({
API_URL_V1: config.API_URL_V1,
API_URL_V2: config.API_URL_V2
API_URL: config.API_URL
});
1 change: 0 additions & 1 deletion app/services/global-search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Service, { inject as service } from '@ember/service';
// import { assign } from '@ember/polyfills';

export default Service.extend({
router: service(),
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/application-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img class="pl-0 pr-0" src="/assets/ror-logo.svg" alt="Research Organization Registry logo">
</a>
<div id="search">
<form {{action "search" this.query on="submit"}} class="form-inline mw-25" role="search">
<form {{on "submit" (fn this.actions.search this.query)}} class="form-inline mw-25" role="search">
<input name="query" value={{this.query}} id="query" class="form-control" placeholder="Search Registry..." escape-press={{action "clear"}} enter={{action "search"}} />
</form>
</div>
Expand Down Expand Up @@ -37,7 +37,7 @@
<p>Events</p>
</a>
</nav.item>

<nav.item>
<a class="nav-link" href="/blog/">
<p>Blog</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{{/if}}
{{/if}}
{{/each-in}}
<br><a target="_blank" rel="noopener" class="card-link mt-1" href="https://ror.readme.io/docs/ror-data-structure#status"><em>Learn more about {{model.status}} records</em></a>
<br><a target="_blank" rel="noopener" class="card-link mt-1" href="https://ror.readme.io/docs/ror-data-structure#status"><em>Learn more about {{this.model.status}} records</em></a>
</div>
{{/if}}
{{/if}}
Expand Down Expand Up @@ -139,7 +139,7 @@
<LinkTo @route="organizations.show" @model={{this.model.id}} class="btn btn-sm btn-round">View details</LinkTo>
{{/if}}
{{#if (not this.isSearch)}}
<p class="mt-3 mb-0"><i>Some record data is not displayed in this view. <a target="_blank" rel="noopener" href="{{configService.API_URL_V2}}/organizations/{{model.id}}">See JSON view for full record data</a></i></p>
<p class="mt-3 mb-0"><i>Some record data is not displayed in this view. <a target="_blank" rel="noopener" href="{{configService.API_URL}}/organizations/{{model.id}}">See JSON view for full record data</a></i></p>
<p class="mt-3 mb-0">
<i>
{{#if this.lastModifiedDate}}
Expand Down
Loading

0 comments on commit 60835e1

Please sign in to comment.