diff --git a/config/default.js b/config/default.js index cd7155df27c..62619336be6 100644 --- a/config/default.js +++ b/config/default.js @@ -17,8 +17,6 @@ if (appName && validAppNames.indexOf(appName) === -1) { const amoCDN = 'https://addons.cdn.mozilla.net'; const apiHost = 'https://addons.mozilla.org'; -const apiBase = `${apiHost}/api/v3`; -const startLoginUrl = `${apiBase}/internal/accounts/login/start/`; module.exports = { @@ -42,19 +40,18 @@ module.exports = { // The CDN host for AMO. amoCDN, apiHost, - apiBase, - startLoginUrl, + apiPath: '/api/v3', // The keys listed here will be exposed on the client. // Since by definition client-side code is public these config keys // must not contain sensitive data. clientConfigKeys: [ - 'apiBase', + 'apiHost', + 'apiPath', 'cookieName', 'cookieMaxAge', 'isDeployed', 'isDevelopment', - 'startLoginUrl', ], // Content security policy. diff --git a/config/dev.js b/config/dev.js index 15e41224a71..0b6959932c6 100644 --- a/config/dev.js +++ b/config/dev.js @@ -2,15 +2,11 @@ const amoCDN = 'https://addons-dev-cdn.allizom.org'; const apiHost = 'https://addons-dev.allizom.org'; -const apiBase = `${apiHost}/api/v3`; -const startLoginUrl = `${apiBase}/internal/accounts/login/start/`; module.exports = { apiHost, - apiBase, amoCDN, - startLoginUrl, // Content security policy. CSP: { diff --git a/config/development.js b/config/development.js index b36af002a47..f69bb2c5ae9 100644 --- a/config/development.js +++ b/config/development.js @@ -5,12 +5,9 @@ const webpackServerPort = 3001; const webpackHost = `${webpackServerHost}:${webpackServerPort}`; const apiHost = 'https://addons-dev.allizom.org'; const amoCDN = 'https://addons-dev-cdn.allizom.org'; -const apiBase = `${apiHost}/api/v3`; -const startLoginUrl = `${apiBase}/internal/accounts/login/start/`; module.exports = { - apiHost, amoCDN, @@ -18,7 +15,6 @@ module.exports = { isDevelopment: true, serverPort: 3000, - startLoginUrl, webpackServerHost, webpackServerPort, webpackHost, diff --git a/config/stage.js b/config/stage.js index 1dd5eecfc41..4021a320283 100644 --- a/config/stage.js +++ b/config/stage.js @@ -2,15 +2,11 @@ const amoCDN = 'https://addons-stage-cdn.allizom.org'; const apiHost = 'https://addons.allizom.org'; -const apiBase = `${apiHost}/api/v3`; -const startLoginUrl = `${apiBase}/internal/accounts/login/start/`; module.exports = { apiHost, - apiBase, amoCDN, - startLoginUrl, // Content security policy. CSP: { diff --git a/src/core/api/index.js b/src/core/api/index.js index c2355296078..6f1a514adcc 100644 --- a/src/core/api/index.js +++ b/src/core/api/index.js @@ -5,7 +5,7 @@ import config from 'config'; import 'isomorphic-fetch'; -const API_BASE = config.get('apiBase'); +const API_BASE = `${config.get('apiHost')}${config.get('apiPath')}`; const addon = new Schema('addons', {idAttribute: 'slug'}); @@ -45,10 +45,11 @@ function callApi({endpoint, schema, params, auth = false, state = {}, method = ' export function search({ api, page, query }) { // TODO: Get the language from the server. return callApi({ - endpoint: 'addons/search', + endpoint: 'internal/addons/search', schema: {results: arrayOf(addon)}, params: {q: query, lang: 'en-US', page}, state: api, + auth: true, }); } @@ -72,3 +73,7 @@ export function login({ api, code, state }) { credentials: true, }); } + +export function startLoginUrl() { + return `${API_BASE}/internal/accounts/login/start/`; +} diff --git a/src/core/components/LoginPage/index.js b/src/core/components/LoginPage/index.js index 7e3bec34450..a36b4d4fd43 100644 --- a/src/core/components/LoginPage/index.js +++ b/src/core/components/LoginPage/index.js @@ -1,6 +1,6 @@ import React, { PropTypes } from 'react'; -import config from 'config'; +import { startLoginUrl } from 'core/api'; import { gettext as _ } from 'core/utils'; export default class LoginPage extends React.Component { @@ -17,7 +17,7 @@ export default class LoginPage extends React.Component { {message || _('You must be logged in to access this page.')}
diff --git a/src/core/server/base.js b/src/core/server/base.js index 5181c6bc12b..bbe848fc577 100644 --- a/src/core/server/base.js +++ b/src/core/server/base.js @@ -165,7 +165,8 @@ export function runServer({listen = true, app = appName} = {}) { reject(err); } log.info(`🔥 Addons-frontend server is running [ENV:${env}] [APP:${app}] ` + - `[isDevelopment:${isDevelopment}] [isDeployed:${isDeployed}]`); + `[isDevelopment:${isDevelopment}] [isDeployed:${isDeployed}] ` + + `[apiHost:${config.get('apiHost')}] [apiPath:${config.get('apiPath')}]`); log.info(`👁 Open your browser at http://${host}:${port} to view it.`); resolve(server); }); diff --git a/src/search/containers/AddonPage/index.js b/src/search/containers/AddonPage/index.js index 533a17ee0bf..33deb146f31 100644 --- a/src/search/containers/AddonPage/index.js +++ b/src/search/containers/AddonPage/index.js @@ -8,10 +8,8 @@ import NotFound from 'core/components/NotFound'; import './style.scss'; -const editRegExpHelper = new RegExp('/firefox/addon/'); -const editRegExpPath = '/developers/addon/'; -function editUrl(viewUrl) { - return `${viewUrl.replace(editRegExpHelper, editRegExpPath)}edit`; +function siteLink(url, text) { + return {text}; } class AddonPage extends React.Component { @@ -28,8 +26,9 @@ class AddonPage extends React.Component { const items = [ [addon.type, 'type'], [addon.status, 'status'], - [{_('View on site')}, 'url'], - [{_('Edit on site')}, 'edit'], + [siteLink(addon.url, _('View on site')), 'url'], + [siteLink(addon.edit_url, _('Edit on site')), 'edit'], + [siteLink(addon.review_url, _('View on editors')), 'editors'], ]; if (addon.homepage) { items.push([ @@ -69,7 +68,11 @@ class AddonPage extends React.Component { return (