Add remote and backend URLs and update global variable

This commit is contained in:
Aurelsicoko 2017-11-08 17:40:47 +01:00
parent 27016a95d6
commit 650e7dd6cb
29 changed files with 129 additions and 119 deletions

View File

@ -773,7 +773,7 @@ import reducer from './reducer';
export class FooPage extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.error !== nextProps.error && nextProps.error) {
window.Strapi.notification.error(nextProps.errorMessage);
strapi.notification.error(nextProps.errorMessage);
}
}

View File

@ -1,9 +1,9 @@
# Don't check auto-generated stuff into git
coverage
build
node_modules
stats.json
build
plugins.json
stats.json
package-lock.json
# Cruft

View File

@ -25,6 +25,16 @@ import { pluginLoaded, updatePlugin } from 'containers/App/actions';
import configureStore from './store';
import { translationMessages, languages } from './i18n';
// Retrieve remote and backend URLs.
const remoteURL = process.env.REMOTE_URL || 'http://localhost:1337/admin';
const backendURL = process.env.BACKEND_URL || 'http://localhost:1337';
window.strapi = {
remoteURL,
backendURL,
languages,
};
// Create redux store with history
const initialState = {};
const history = createHistory({
@ -70,11 +80,7 @@ window.onload = function onLoad() {
// Don't inject plugins in development mode.
if (window.location.port !== '4000') {
const uri = window.location.href.indexOf('/admin') !== -1 ?
`${window.location.origin}/admin` :
window.location.origin;
fetch(`${process.env.ADMIN_URL !== null ? process.env.ADMIN_URL : uri}/config/plugins.json`)
fetch(`${remoteURL}/config/plugins.json`)
.then(response => {
return response.json();
})
@ -140,10 +146,7 @@ const displayNotification = (message, status) => {
store.dispatch(showNotification(message, status));
};
const port = window.Strapi && window.Strapi.port ? window.Strapi.port : 1337;
const apiUrl = window.Strapi && window.Strapi.apiUrl ? window.Strapi.apiUrl : `http://localhost:${port}`;
window.Strapi = {
window.strapi = Object.assign(window.strapi, {
registerPlugin,
notification: {
success: (message) => {
@ -159,8 +162,6 @@ window.Strapi = {
displayNotification(message, 'info');
},
},
port,
apiUrl,
refresh: (pluginId) => ({
translationMessages: (translationMessagesUpdated) => {
render(merge({}, translationMessages, translationMessagesUpdated));
@ -170,8 +171,7 @@ window.Strapi = {
},
}),
router: history,
languages,
};
});
const dispatch = store.dispatch;
export {

View File

@ -21,7 +21,7 @@ export function* deletePlugin() {
} catch(error) {
yield put(deletePluginSucceeded());
window.Strapi.notification.error('app.components.listPluginsPage.deletePlugin.error');
strapi.notification.error('app.components.listPluginsPage.deletePlugin.error');
}
}
// Individual exports for testing

View File

@ -47,4 +47,4 @@
"npm": ">= 5.3.0"
},
"license": "MIT"
}
}

View File

@ -5,15 +5,34 @@
const _ = require('lodash');
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const pkg = require(path.resolve(process.cwd(), 'package.json'));
const pluginId = pkg.name.replace(/^strapi-/i, '');
let noPlugin = false;
let plugins = [];
let pluginFolders = {};
// Define remote and backend URLs.
const URLs = {
remote: '',
backend: ''
};
const serverConfig = path.resolve(process.env.PWD, '..', 'config', 'environments', _.lowerCase(process.env.NODE_ENV), 'server.json');
try {
const server = require(serverConfig);
URLs.remote = _.get(server, 'admin.remoteURL', null) ? _.get(server, 'admin.remoteURL', null) : `http://${_.get(server, 'host', 'localhost')}:${_.get(server, 'port', 1337)}/admin`;
URLs.backend = _.get(server, 'admin.backendURL', null) ? _.get(server, 'admin.backendURL', null) : `http://${_.get(server, 'host', 'localhost')}:${_.get(server, 'port', 1337)}`;
} catch (e) {
throw new Error('Impossible to open ' + serverConfig);
}
// Load plugins into the same build in development mode.
const plugins = {
exist: false,
src: [],
folders: {}
};
if (process.env.npm_lifecycle_event === 'start') {
try {
@ -23,33 +42,23 @@ if (process.env.npm_lifecycle_event === 'start') {
fs.accessSync(path.resolve(process.env.PWD, '..', 'api'), fs.constants.R_OK);
// Allow app without plugins.
noPlugin = true;
plugins.exist = true;
} catch (e) {
throw new Error(`You need to start the WebPack server from the /admin directory in a Strapi's project.`);
}
}
plugins = process.env.IS_ADMIN === 'true' && !noPlugin ? fs.readdirSync(path.resolve(process.env.PWD, '..', 'plugins'))
.filter(x => x[0] !== '.') : [];
// Read `plugins` directory.
plugins.src = process.env.IS_ADMIN === 'true' && !plugins.exist ? fs.readdirSync(path.resolve(process.env.PWD, '..', 'plugins')).filter(x => x[0] !== '.') : [];
pluginFolders = plugins.reduce((acc, current) => {
// Construct object of plugin' paths.
plugins.folders = plugins.src.reduce((acc, current) => {
acc[current] = path.resolve(process.env.PWD, '..', 'plugins', current, 'node_modules', 'strapi-helper-plugin', 'lib', 'src');
return acc;
}, {});
}
let adminURL = null;
try {
const server = require(path.resolve(process.env.PWD, '..', 'config', 'environments', _.lowerCase(process.env.NODE_ENV), 'server.json'));
adminURL = _.get(server, 'admin.url', null);
} catch (e) {
// Silent
}
module.exports = (options) => ({
entry: options.entry,
output: Object.assign({ // Compile into js/build.js
@ -83,8 +92,8 @@ module.exports = (options) => ({
},
},
include: [path.join(process.cwd(), 'admin', 'src')]
.concat(plugins.reduce((acc, current) => {
acc.push(path.resolve(process.env.PWD, '..', 'plugins', current, 'admin', 'src'), pluginFolders[current]);
.concat(plugins.src.reduce((acc, current) => {
acc.push(path.resolve(process.env.PWD, '..', 'plugins', current, 'admin', 'src'), plugins.folders[current]);
return acc;
}, []))
@ -174,7 +183,8 @@ module.exports = (options) => ({
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
ADMIN_URL: JSON.stringify(adminURL),
REMOTE_URL: JSON.stringify(URLs.remote),
BACKEND_URL: JSON.stringify(URLs.backend),
},
}),
new webpack.NamedModulesPlugin()

View File

@ -41,11 +41,11 @@ const pluginId = pluginPkg.name.replace(
);
const pluginName = pluginPkg.strapi.name;
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
const apiUrl = window.Strapi && `${window.Strapi.apiUrl}/${pluginId}`;
const router = window.Strapi.router;
const apiUrl = `${strapi.backendURL}/${pluginId}`;
const router = strapi.router;
// Create redux store with Strapi admin history
const store = configureStore({}, window.Strapi.router);
const store = configureStore({}, strapi.router);
// Define the plugin root component
function Comp(props) {
@ -61,10 +61,10 @@ if (module.hot) {
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept('./i18n', () => {
if (window.Strapi) {
if (strapi) {
System.import('./i18n').then(result => {
const translationMessagesUpdated = result.translationMessages;
window.Strapi
strapi
.refresh(pluginId)
.translationMessages(translationMessagesUpdated);
});
@ -73,7 +73,7 @@ if (module.hot) {
}
// Register the plugin.
window.Strapi.registerPlugin({
strapi.registerPlugin({
name: pluginPkg.strapi.name,
icon: pluginPkg.strapi.icon,
description: pluginDescription,

View File

@ -34,7 +34,7 @@ const formatMessages = messages => reduce(messages, (result, value, key) => {
*/
const requireTranslations = language => {
try {
return require(`translations/${language}.json`); // eslint-disable-line global-require
return require(`/translations/${language}.json`); // eslint-disable-line global-require
} catch (error) {
console.error(`Unable to load "${language}" translation for the plugin ${pluginId}. Please make sure "${language}.json" file exists in "pluginPath/admin/src/translations" folder.`);
return false;
@ -44,7 +44,10 @@ const requireTranslations = language => {
/**
* Dynamically generate `translationsMessages object`.
*/
const translationMessages = reduce(window.Strapi.languages, (result, language) => {
console.log(window.strapi);
const translationMessages = reduce(window.strapi.languages, (result, language) => {
const obj = result;
const messages = requireTranslations(language);
obj[language] = formatMessages(messages);

View File

@ -50,7 +50,7 @@ function formatQueryParams(params) {
*/
function serverRestartWatcher(response) {
return new Promise((resolve, reject) => {
fetch(`${Strapi.apiUrl}/_health`, {
fetch(`${strapi.backendURL}/_health`, {
method: 'HEAD',
mode: 'no-cors',
headers: {
@ -86,7 +86,7 @@ function serverRestartWatcher(response) {
// Add parameters to url
url = _.startsWith(url, '/')
? `${Strapi.apiUrl}${url}`
? `${strapi.backendURL}${url}`
: url;
if (options && options.params) {

View File

@ -58,7 +58,7 @@ class SelectMany extends React.Component { // eslint-disable-line react/prefer-s
return { options };
})
.catch(() => {
window.Strapi.notification.error('An error occurred during relationship fetch.');
strapi.notification.error('An error occurred during relationship fetch.');
});
}

View File

@ -58,7 +58,7 @@ class SelectOne extends React.Component { // eslint-disable-line react/prefer-st
return {options};
})
.catch(() => {
window.Strapi.notification.error('An error occurred during relationship fetch.');
strapi.notification.error('An error occurred during relationship fetch.');
});
}

View File

@ -10,17 +10,17 @@ import { makeSelectModels } from './selectors';
export function* modelEntriesGet(action) {
try {
const requestUrl = `${window.Strapi.apiUrl}/content-manager/explorer/${action.modelName}/count`;
const requestUrl = `${strapi.backendURL}/content-manager/explorer/${action.modelName}/count`;
const response = yield call(request, requestUrl, { method: 'GET' });
yield put(getModelEntriesSucceeded(response.count));
} catch(error) {
window.Strapi.notification.error('content-manager.error.model.fetch');
strapi.notification.error('content-manager.error.model.fetch');
}
}
export const generateMenu = function () {
return request(`${window.Strapi.apiUrl}/content-manager/models`, {
return request(`${strapi.backendURL}/content-manager/models`, {
method: 'GET',
})
.then(response => generateSchema(response))
@ -34,7 +34,7 @@ export const generateMenu = function () {
}];
})
.catch((error) => {
window.Strapi.notification.error('content-manager.error.model.fetch');
strapi.notification.error('content-manager.error.model.fetch');
throw Error(error);
});
};
@ -42,13 +42,13 @@ export const generateMenu = function () {
export function* getModels() {
try {
const response = yield call(request,
`${window.Strapi.apiUrl}/content-manager/models`, {
`${strapi.backendURL}/content-manager/models`, {
method: 'GET',
});
yield put(loadedModels(response));
} catch (err) {
window.Strapi.notification.error('content-manager.error.model.fetch');
strapi.notification.error('content-manager.error.model.fetch');
}
}
@ -59,7 +59,7 @@ export function* modelsLoaded() {
try {
schema = generateSchema(models);
} catch (err) {
window.Strapi.notification.error('content-manager.error.schema.generation');
strapi.notification.error('content-manager.error.schema.generation');
throw new Error(err);
}

View File

@ -114,7 +114,7 @@ export class Edit extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.editSuccess !== nextProps.editSuccess) {
if (!isEmpty(this.props.location.search)) {
window.Strapi.notification.success('content-manager.success.record.save');
strapi.notification.success('content-manager.success.record.save');
router.push(replace(this.props.location.search, '?redirectUrl=', ''));
} else {
router.push(replace(this.props.location.pathname, 'create', ''));

View File

@ -23,7 +23,7 @@ export function* getRecord(params) {
const currentModelName = yield select(makeSelectCurrentModelName());
try {
const requestUrl = `${window.Strapi.apiUrl}/content-manager/explorer/${currentModelName}/${params.id}`;
const requestUrl = `${strapi.backendURL}/content-manager/explorer/${currentModelName}/${params.id}`;
// Call our request helper (see 'utils/request')
const response = yield request(requestUrl, {
@ -32,7 +32,7 @@ export function* getRecord(params) {
yield put(recordLoaded(response));
} catch (err) {
window.Strapi.notification.error('content-manager.error.record.fetch');
strapi.notification.error('content-manager.error.record.fetch');
}
}
@ -51,7 +51,7 @@ export function* editRecord() {
const id = isCreating ? '' : recordCleaned.id;
try {
const requestUrl = `${window.Strapi.apiUrl}/content-manager/explorer/${currentModelName}/${id}`;
const requestUrl = `${strapi.backendURL}/content-manager/explorer/${currentModelName}/${id}`;
// Call our request helper (see 'utils/request')
yield call(request, requestUrl, {
@ -60,17 +60,17 @@ export function* editRecord() {
});
yield put(recordEdited());
window.Strapi.notification.success('content-manager.success.record.save');
strapi.notification.success('content-manager.success.record.save');
} catch (err) {
yield put(recordEditError());
window.Strapi.notification.error(isCreating ? 'content-manager.error.record.create' : 'content-manager.error.record.update');
strapi.notification.error(isCreating ? 'content-manager.error.record.create' : 'content-manager.error.record.update');
}
}
export function* deleteRecord({ id, modelName }) {
function* httpCall(id, modelName) {
try {
const requestUrl = `${window.Strapi.apiUrl}/content-manager/explorer/${modelName}/${id}`;
const requestUrl = `${strapi.backendURL}/content-manager/explorer/${modelName}/${id}`;
// Call our request helper (see 'utils/request')
yield call(request, requestUrl, {
@ -78,13 +78,13 @@ export function* deleteRecord({ id, modelName }) {
});
yield put(recordDeleted(id));
window.Strapi.notification.success('content-manager.success.record.delete');
strapi.notification.success('content-manager.success.record.delete');
// Redirect to the list page.
router.push(`/plugins/content-manager/${modelName}`);
} catch (err) {
yield put(recordDeleteError());
window.Strapi.notification.error('content-manager.error.record.delete');
strapi.notification.error('content-manager.error.record.delete');
}
}

View File

@ -41,7 +41,7 @@ export function* getRecords() {
};
try {
const requestUrl = `${window.Strapi.apiUrl}/content-manager/explorer/${currentModel}`;
const requestUrl = `${strapi.backendURL}/content-manager/explorer/${currentModel}`;
// Call our request helper (see 'utils/request')
const response = yield call(request, requestUrl, {
method: 'GET',
@ -50,7 +50,7 @@ export function* getRecords() {
yield put(loadedRecord(response));
} catch (err) {
window.Strapi.notification.error('content-manager.error.records.fetch');
strapi.notification.error('content-manager.error.records.fetch');
}
}
@ -60,12 +60,12 @@ export function* getCount() {
try {
const response = yield call(
request,
`${window.Strapi.apiUrl}/content-manager/explorer/${currentModel}/count`,
`${strapi.backendURL}/content-manager/explorer/${currentModel}/count`,
);
yield put(loadedCount(response.count));
} catch (err) {
window.Strapi.notification.error('content-manager.error.records.count');
strapi.notification.error('content-manager.error.records.count');
}
}

View File

@ -59,7 +59,7 @@ export default function request(url, options = {}) {
// Add parameters to url
url = _.startsWith(url, '/')
? `${Strapi.apiUrl}${url}`
? `${strapi.backendURL}${url}`
: url;
if (options && options.params) {

View File

@ -13,11 +13,11 @@ export function* deleteContentType(action) {
if (action.updateLeftMenu) {
action.updatePlugin('content-manager', 'leftMenuSections', action.leftMenuContentTypes);
}
window.Strapi.notification.success('content-type-builder.notification.success.contentTypeDeleted');
strapi.notification.success('content-type-builder.notification.success.contentTypeDeleted');
}
} catch(error) {
window.Strapi.notification.error('content-type-builder.notification.error.message');
strapi.notification.error('content-type-builder.notification.error.message');
}
}
@ -28,7 +28,7 @@ export function* fetchModels() {
yield put(modelsFetchSucceeded(data));
} catch(error) {
window.Strapi.notification.error('content-type-builder.notification.error.message');
strapi.notification.error('content-type-builder.notification.error.message');
}
}

View File

@ -54,10 +54,10 @@ export function* editContentType(action) {
leftMenuContentTypes[0].links = sortBy(leftMenuContentTypes[0].links, 'label');
action.context.updatePlugin('content-manager', 'leftMenuSections', leftMenuContentTypes);
}
window.Strapi.notification.success('content-type-builder.notification.success.message.contentType.edit');
strapi.notification.success('content-type-builder.notification.success.message.contentType.edit');
}
} catch(error) {
window.Strapi.notification.error(error);
strapi.notification.error(error);
}
}
@ -69,7 +69,7 @@ export function* fetchConnections() {
yield put(connectionsFetchSucceeded(data));
} catch(error) {
window.Strapi.notification.error('content-type-builder.notification.error.message');
strapi.notification.error('content-type-builder.notification.error.message');
}
}
@ -83,7 +83,7 @@ export function* fetchContentType(action) {
yield put(contentTypeFetchSucceeded(data));
} catch(error) {
window.Strapi.notification.error('content-type-builder.notification.error.message');
strapi.notification.error('content-type-builder.notification.error.message');
}
}

View File

@ -44,7 +44,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
handleButtonClick = () => {
if (storeData.getIsModelTemporary()) {
window.Strapi.notification.info('content-type-builder.notification.info.contentType.creating.notSaved');
strapi.notification.info('content-type-builder.notification.info.contentType.creating.notSaved');
} else {
this.toggleModal();
}

View File

@ -135,7 +135,7 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
handleAddLinkClick = () => {
if (storeData.getIsModelTemporary()) {
window.Strapi.notification.info('content-type-builder.notification.info.contentType.creating.notSaved');
strapi.notification.info('content-type-builder.notification.info.contentType.creating.notSaved');
} else {
this.toggleModal();
}

View File

@ -43,7 +43,7 @@ export function* getTableExistance() {
yield put(checkIfTableExistsSucceeded(tableExists));
} catch(error) {
window.Strapi.notification.error('An error occured');
strapi.notification.error('An error occured');
}
}
@ -58,7 +58,7 @@ export function* fetchModel(action) {
yield put(unsetButtonLoader());
} catch(error) {
window.Strapi.notification.error('An error occured');
strapi.notification.error('An error occured');
}
}
@ -116,10 +116,10 @@ export function* submitChanges(action) {
action.context.updatePlugin('content-manager', 'leftMenuSections', leftMenuContentTypes);
}
window.Strapi.notification.success('content-type-builder.notification.success.message.contentType.create');
strapi.notification.success('content-type-builder.notification.success.message.contentType.create');
} else {
window.Strapi.notification.success('content-type-builder.notification.success.message.contentType.edit');
strapi.notification.success('content-type-builder.notification.success.message.contentType.edit');
}
yield put(submitActionSucceeded());
@ -130,7 +130,7 @@ export function* submitChanges(action) {
}
} catch(error) {
window.Strapi.notification.error(error);
strapi.notification.error(error);
}
}

View File

@ -1,7 +1,7 @@
import request from 'utils/request';
const shouldRenderCompo = (plugin) => new Promise((resolve, reject) => {
request('/content-type-builder/autoReload')
request(`${strapi.backendURL}/content-type-builder/autoReload`)
.then(response => {
plugin.preventComponentRendering = !response.autoReload;
plugin.blockerComponentProps = {
@ -16,5 +16,4 @@ const shouldRenderCompo = (plugin) => new Promise((resolve, reject) => {
.catch(err => reject(err));
});
export default shouldRenderCompo;

View File

@ -47,7 +47,7 @@ export const storeData = {
return localStorage.setItem(contentType, stringify(data));
}
return window.Strapi.notification.info('This plugin is optimized with your localStorage');
return strapi.notification.info('This plugin is optimized with your localStorage');
},
setMenu(data, menu = MENU) {
@ -55,7 +55,7 @@ export const storeData = {
return localStorage.setItem(menu, stringify(data));
}
return window.Strapi.notification.info('This plugin is optimized with your localStorage');
return strapi.notification.info('This plugin is optimized with your localStorage');
},
setModel(data, model = MODEL) {
@ -63,7 +63,7 @@ export const storeData = {
return localStorage.setItem(model, stringify(data));
}
return window.Strapi.notification.info('This plugin is optimized with your localStorage');
return strapi.notification.info('This plugin is optimized with your localStorage');
},
setIsModelTemporary(isModelTemporay = IS_MODEL_TEMPORARY) {
@ -71,6 +71,6 @@ export const storeData = {
return localStorage.setItem(isModelTemporay, true);
}
return window.Strapi.notification.info('This plugin is optimized with your localStorage');
return strapi.notification.info('This plugin is optimized with your localStorage');
},
};

View File

@ -17,7 +17,7 @@ export function* fetchMenu() {
yield put(fetchMenuSucceeded(data));
} catch(err) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -33,7 +33,7 @@ export function* fetchEnvironments() {
yield put(environmentsFetchSucceeded(data));
} catch(error) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}

View File

@ -261,7 +261,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
const body = this.sendUpdatedParams(isCreatingNewFields);
const formErrors = checkFormValidity(body, this.props.home.formValidations);
if (isEmpty(body)) return window.Strapi.notification.info('settings-manager.strapi.notification.info.settingsEqual');
if (isEmpty(body)) return strapi.notification.info('settings-manager.strapi.notification.info.settingsEqual');
if (isEmpty(formErrors)) {
this.props.editSettings(body, apiUrl);
} else {
@ -276,7 +276,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
if (isEmpty(body)) {
this.props.closeModal();
return window.Strapi.notification.info('settings-manager.strapi.notification.info.settingsEqual');
return strapi.notification.info('settings-manager.strapi.notification.info.settingsEqual');
}
@ -291,7 +291,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
handleLanguageDelete = (languaToDelete) => this.props.languageDelete(languaToDelete);
handleDatabaseDelete = (dbName) => {
window.Strapi.notification.success('settings-manager.strapi.notification.success.databaseDelete');
strapi.notification.success('settings-manager.strapi.notification.success.databaseDelete');
this.props.databaseDelete(dbName, this.props.match.params.env);
}

View File

@ -53,14 +53,14 @@ export function* editDatabase(action) {
const resp = yield call(request, requestUrl, opts, true);
if (resp.ok) {
window.Strapi.notification.success('settings-manager.strapi.notification.success.databaseEdit');
strapi.notification.success('settings-manager.strapi.notification.success.databaseEdit');
yield put(databaseActionSucceeded());
}
} catch(error) {
const formErrors = map(error.response.payload.message, err => ({ target: err.target, errors: map(err.messages, mess => ({ id: `settings-manager.${mess.id}`})) }));
yield put(databaseActionError(formErrors));
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -72,11 +72,11 @@ export function* deleteDatabase(action) {
const resp = yield call(request, requestUrl, opts, true);
if (resp.ok) {
window.Strapi.notification.success('settings-manager.strapi.notification.success.databaseDeleted');
strapi.notification.success('settings-manager.strapi.notification.success.databaseDeleted');
}
} catch(error) {
yield put(databaseActionError([]));
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -90,11 +90,11 @@ export function* deleteLanguage(action) {
const resp = yield call(request, requestUrl, opts, true);
if (resp.ok) {
window.Strapi.notification.success('settings-manager.strapi.notification.success.languageDelete');
strapi.notification.success('settings-manager.strapi.notification.success.languageDelete');
}
} catch(error) {
yield put(languageActionError());
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -108,7 +108,7 @@ export function* fetchConfig(action) {
const data = yield call(request, requestUrl, opts);
yield put(configFetchSucceded(data));
} catch(error) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -127,7 +127,7 @@ export function* fetchDatabases(action) {
];
yield put(databasesFetchSucceeded(listDatabasesData, appDatabaseData));
} catch(error) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -145,7 +145,7 @@ export function* fetchLanguages() {
];
yield put(languagesFetchSucceeded(appLanguagesData, listLanguagesData));
} catch(error) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -174,12 +174,12 @@ export function* postLanguage() {
const resp = yield call(request, requestUrl, opts, true);
if (resp.ok) {
window.Strapi.notification.success('settings-manager.strapi.notification.success.languageAdd');
strapi.notification.success('settings-manager.strapi.notification.success.languageAdd');
yield put(languageActionSucceeded());
}
} catch(error) {
yield put(languageActionError());
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -201,7 +201,7 @@ export function* postDatabase(action) {
if (resp.ok) {
yield put(databaseActionSucceeded());
window.Strapi.notification.success('settings-manager.strapi.notification.success.databaseAdd');
strapi.notification.success('settings-manager.strapi.notification.success.databaseAdd');
}
} catch(error) {
const formErrors = map(error.response.payload.message, (err) => {
@ -213,7 +213,7 @@ export function* postDatabase(action) {
yield put(databaseActionError(formErrors));
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}
@ -230,12 +230,12 @@ export function* settingsEdit(action) {
const resp = yield call(request, requestUrl, opts, true);
if (resp.ok) {
window.Strapi.notification.success('settings-manager.strapi.notification.success.settingsEdit');
strapi.notification.success('settings-manager.strapi.notification.success.settingsEdit');
yield put(editSettingsSucceeded());
yield put(unsetLoader());
}
} catch(error) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
yield put(unsetLoader());
}
}
@ -251,7 +251,7 @@ export function* fetchSpecificDatabase(action) {
yield put(specificDatabaseFetchSucceeded(data));
} catch(error) {
window.Strapi.notification.error('settings-manager.strapi.notification.error');
strapi.notification.error('settings-manager.strapi.notification.error');
}
}

View File

@ -52,7 +52,7 @@ function formatQueryParams(params) {
*/
function serverRestartWatcher(response) {
return new Promise((resolve) => {
fetch(`${Strapi.apiUrl}/_health`, {
fetch(`${strapi.backendURL}/_health`, {
method: 'HEAD',
mode: 'no-cors',
headers: {
@ -90,7 +90,7 @@ export default function request(url, options, shouldWatchServerRestart = false)
// Add parameters to url
let urlFormatted = startsWith(url, '/')
? `${Strapi.apiUrl}${url}`
? `${strapi.backendURL}${url}`
: url;
if (optionsObj && optionsObj.params) {

View File

@ -66,8 +66,6 @@ module.exports = function() {
}, {})
}));
console.log(strapi.admin);
fs.writeFileSync(sourcePath, JSON.stringify(data, null, 2), 'utf8');
fs.writeFileSync(buildPath, JSON.stringify(data), 'utf8');

View File

@ -86,4 +86,4 @@
},
"preferGlobal": true,
"license": "MIT"
}
}