From 13544cf82565e74806dd0587a7f0d2b2bf2bf4b5 Mon Sep 17 00:00:00 2001 From: Abram Booth Date: Fri, 21 Apr 2023 12:21:13 -0400 Subject: [PATCH 1/3] registries discover with local SHARE use existing environment variables instead of hard-coded URLs SHARE_BASE_URL SHARE_API_URL SHARE_SEARCH_URL --- .../addon/components/discover-page/component.ts | 7 ------- lib/collections/config/environment.d.ts | 1 - lib/collections/config/environment.js | 1 - lib/registries/addon/services/share-search.ts | 4 ++-- lib/registries/config/environment.d.ts | 4 ++-- lib/registries/config/environment.js | 4 ++-- mirage/config.ts | 5 +++-- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/collections/addon/components/discover-page/component.ts b/lib/collections/addon/components/discover-page/component.ts index 6ef8c2a811..9bc0db0f34 100644 --- a/lib/collections/addon/components/discover-page/component.ts +++ b/lib/collections/addon/components/discover-page/component.ts @@ -10,7 +10,6 @@ import { camelize } from '@ember/string'; import { waitFor } from '@ember/test-waiters'; import { keepLatestTask, timeout } from 'ember-concurrency'; import { taskFor } from 'ember-concurrency-ts'; -import config from 'ember-osf-web/config/environment'; import Media from 'ember-responsive'; import { layout } from 'ember-osf-web/decorators/component'; @@ -226,12 +225,6 @@ export default class DiscoverPage extends Component { return this.totalPages < maxPages ? this.totalPages : maxPages; } - @computed('currentUser.sessionKey') - get searchUrl() { - // Pulls SHARE search url from config file. - return `${config.OSF.shareSearchUrl}?preference=${this.currentUser.sessionKey}`; - } - // Total pages of search results @computed('numberOfResults', 'size') get totalPages(): number { diff --git a/lib/collections/config/environment.d.ts b/lib/collections/config/environment.d.ts index f59b21682e..e79fe9a370 100644 --- a/lib/collections/config/environment.d.ts +++ b/lib/collections/config/environment.d.ts @@ -3,7 +3,6 @@ declare const config: { hostAppName: string; modulePrefix: string; OSF: { - shareSearchUrl: string; url: string; }, whiteListedProviders: string[]; diff --git a/lib/collections/config/environment.js b/lib/collections/config/environment.js index a3cdcb7cc6..7a178bb57f 100644 --- a/lib/collections/config/environment.js +++ b/lib/collections/config/environment.js @@ -6,7 +6,6 @@ module.exports = function(environment) { hostAppName: 'collections', modulePrefix: 'collections', OSF: { - shareSearchUrl: 'https://share.osf.io/api/v2/search/creativeworks/_search', url: 'http://localhost:5000/', }, whiteListedProviders: [ diff --git a/lib/registries/addon/services/share-search.ts b/lib/registries/addon/services/share-search.ts index 27e791429c..f476caa7eb 100644 --- a/lib/registries/addon/services/share-search.ts +++ b/lib/registries/addon/services/share-search.ts @@ -127,7 +127,7 @@ export default class ShareSearch extends Search { osfProviders: SourceDescriptor[] = []; url(): string { - return `${config.shareSearchBaseURL}/creativeworks/_search`; + return config.shareSearchUrl; } extractTotal(response: any): number { @@ -201,7 +201,7 @@ export default class ShareSearch extends Search { let mainLink: string | undefined; const infoLinks: Array<{ type: string, uri: string }> = []; const hyperLinks: string[] = [ - `${config.shareBaseURL}/${r._source.type.replace(/ /g, '')}/${r._id}`, + `${config.shareBaseUrl}/${r._source.type.replace(/ /g, '')}/${r._id}`, ]; for (const identifier of (r._source.identifiers as string[])) { diff --git a/lib/registries/config/environment.d.ts b/lib/registries/config/environment.d.ts index c0046f15ee..73682e2958 100644 --- a/lib/registries/config/environment.d.ts +++ b/lib/registries/config/environment.d.ts @@ -3,8 +3,8 @@ declare const config: { hostAppName: string; indexPageRegistrationIds: string[]; modulePrefix: string; - shareBaseURL: string; - shareSearchBaseURL: string; + shareBaseUrl: string; + shareSearchUrl: string; externalRegistries: Array<{ name: string; https: boolean; diff --git a/lib/registries/config/environment.js b/lib/registries/config/environment.js index bb62e98267..fa84d8c9cc 100644 --- a/lib/registries/config/environment.js +++ b/lib/registries/config/environment.js @@ -30,8 +30,8 @@ module.exports = function(environment) { 'ember-cli-mirage': projectConfig['ember-cli-mirage'], // Engine specific settings - shareBaseURL: 'https://share.osf.io', - shareSearchBaseURL: 'https://share.osf.io/api/v2/search', + shareBaseUrl: projectConfig.OSF.shareBaseUrl, + shareSearchUrl: projectConfig.OSF.shareSearchUrl, indexPageRegistrationIds: ['6tsnj', 'aurjt', 'e94t8', '2tpy9', '2ds52'], externalRegistries: [{ https: true, diff --git a/mirage/config.ts b/mirage/config.ts index 28a7a631f9..e380d8f0fc 100644 --- a/mirage/config.ts +++ b/mirage/config.ts @@ -54,12 +54,13 @@ import * as wb from './views/wb'; const { OSF: { addonServiceUrl, apiUrl, shareBaseUrl, url: osfUrl } } = config; + export default function(this: Server) { this.passthrough(); // pass through all requests on currrent domain this.passthrough('https://api.crossref.org/*'); - // SHARE-powered registration discover endpoint - this.urlPrefix = 'https://share.osf.io'; + // SHARE search + this.urlPrefix = shareBaseUrl; this.namespace = '/api/v2/'; this.post('/search/creativeworks/_search', shareSearch); From c14fa8408d82d8db3afb5a802b0591c5455feea7 Mon Sep 17 00:00:00 2001 From: abram axel booth Date: Thu, 11 Jul 2024 11:06:15 -0400 Subject: [PATCH 2/3] default to local share/trove --- config/environment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/environment.js b/config/environment.js index 8e73b951ba..15a86a0164 100644 --- a/config/environment.js +++ b/config/environment.js @@ -96,9 +96,9 @@ const { RECAPTCHA_SITE_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', REDIRECT_URI: redirectUri, ROOT_URL: rootURL = '/', - SHARE_BASE_URL: shareBaseUrl = 'https://staging-share.osf.io/', - SHARE_API_URL: shareApiUrl = 'https://staging-share.osf.io/api/v2', - SHARE_SEARCH_URL: shareSearchUrl = 'https://staging-share.osf.io/api/v2/search/creativeworks/_search', + SHARE_BASE_URL: shareBaseUrl = 'http://localhost:8003/', + SHARE_API_URL: shareApiUrl = 'http:/localhost:8003/api/v2', + SHARE_SEARCH_URL: shareSearchUrl = 'http://localhost:8003/api/v2/search/creativeworks/_search', SOURCEMAPS_ENABLED: sourcemapsEnabled = true, SHOW_DEV_BANNER = false, } = { ...process.env, ...localConfig }; From 3e7cb5bffb3f364a814b6c76bacbae173efbfad4 Mon Sep 17 00:00:00 2001 From: abram axel booth Date: Thu, 11 Jul 2024 11:06:55 -0400 Subject: [PATCH 3/3] remove unused SHARE_API_URL config --- app/config/environment.d.ts | 1 - config/environment.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/app/config/environment.d.ts b/app/config/environment.d.ts index 20f0486233..c823759410 100644 --- a/app/config/environment.d.ts +++ b/app/config/environment.d.ts @@ -111,7 +111,6 @@ declare const config: { waterbutlerUrl: string; helpUrl: string; shareBaseUrl: string; - shareApiUrl: string; shareSearchUrl: string; devMode: boolean; cookieDomain: string; diff --git a/config/environment.js b/config/environment.js index 15a86a0164..17296e3009 100644 --- a/config/environment.js +++ b/config/environment.js @@ -97,7 +97,6 @@ const { REDIRECT_URI: redirectUri, ROOT_URL: rootURL = '/', SHARE_BASE_URL: shareBaseUrl = 'http://localhost:8003/', - SHARE_API_URL: shareApiUrl = 'http:/localhost:8003/api/v2', SHARE_SEARCH_URL: shareSearchUrl = 'http://localhost:8003/api/v2/search/creativeworks/_search', SOURCEMAPS_ENABLED: sourcemapsEnabled = true, SHOW_DEV_BANNER = false, @@ -193,7 +192,6 @@ module.exports = function(environment) { addonServiceUrl, helpUrl, shareBaseUrl, - shareApiUrl, shareSearchUrl, devMode, metricsStartDate,