Set the PHP server config per site (#232)
* Set up the php server per site. * Backwards compatibility logic for old config URLs. * Remove php global config tab. * Fix util import in website.conf.js * Fix eslint fails. * Move global php i18n keys to domain * Remove unnecessary domains verification and set fastcgi_pass in unified mode. * Convert return statement to logic operator in php_ustream.js * Move php upstream to outside the server blocks * Remove unnecessary watcher from php domain section * Fix upstream config context and conditional append * Separate backwards compatibility logic. * Remove unused i18n key from php domain and update copyright of these files * Replace all dots for underscore in php_upstream helper * Fix missing space and remove upstream comment from php config. * Fix selects $refs and watch the enable status for phpServer and phpBackupServer. * Change copyright year for all modified files. * Backwards compatibility logic for old config URLs after angularBackwardsCompatibility * Deep merge old php global config from data url, and add safe disable for phpConfigs * Move deep merge function to new helper * Fix missing disable wordpressRules and convert function declaration to arrows in deep merge helper * Fix missing css class in php domain-sectionpull/236/head
parent
4cfdcdb8d1
commit
1fb756ca77
@ -1,45 +0,0 @@
|
||||
/*
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
|
||||
export default {
|
||||
phpServer: `${common.php} server`,
|
||||
phpMustBeEnabledOnOneSite: `${common.php} must be enabled on at least one site to configure global ${common.php} settings.`,
|
||||
phpBackupServer: `${common.php} backup server`,
|
||||
tcp: 'TCP',
|
||||
hhvmSocket: 'HHVM socket',
|
||||
php5Socket: '5.x socket',
|
||||
php70Socket: '7.0 socket',
|
||||
php71Socket: '7.1 socket',
|
||||
php72Socket: '7.2 socket',
|
||||
php73Socket: '7.3 socket',
|
||||
php74Socket: '7.4 socket',
|
||||
php80Socket: '8.0 socket',
|
||||
phpSocket: 'PHP socket',
|
||||
custom: 'Custom',
|
||||
disabled: 'Disabled',
|
||||
};
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
|
||||
export default {
|
||||
phpServer: `Serveur ${common.php}`,
|
||||
phpMustBeEnabledOnOneSite: `${common.php} doit être activé sur au moins un site pour configurer les paramètres globaux de ${common.php}.`,
|
||||
phpBackupServer: `Serveur de sauvegarde ${common.php}`,
|
||||
tcp: 'TCP',
|
||||
hhvmSocket: 'Socket HHVM',
|
||||
php5Socket: 'Socket 5.x',
|
||||
php70Socket: 'Socket 7.0',
|
||||
php71Socket: 'Socket 7.1',
|
||||
php72Socket: 'Socket 7.2',
|
||||
php73Socket: 'Socket 7.3',
|
||||
php74Socket: 'Socket 7.4',
|
||||
php80Socket: 'Socket 8.0',
|
||||
phpSocket: 'Socket PHP',
|
||||
custom: 'Custom', // TODO: translate
|
||||
disabled: 'Désactivé',
|
||||
};
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
|
||||
export default {
|
||||
phpServer: `Servidor ${common.php}`,
|
||||
phpMustBeEnabledOnOneSite: `O ${common.php} deve estar habilitado em pelo menos um site para definir as configurações globais do ${common.php}.`,
|
||||
phpBackupServer: `Servidor de backup ${common.php}`,
|
||||
tcp: 'TCP',
|
||||
hhvmSocket: 'Socket HHVM',
|
||||
php5Socket: 'Socket 5.x',
|
||||
php70Socket: 'Socket 7.0',
|
||||
php71Socket: 'Socket 7.1',
|
||||
php72Socket: 'Socket 7.2',
|
||||
php73Socket: 'Socket 7.3',
|
||||
php74Socket: 'Socket 7.4',
|
||||
php80Socket: 'Socket 8.0',
|
||||
phpSocket: 'Socket PHP',
|
||||
custom: 'Custom', // TODO: translate
|
||||
disabled: 'Desabilitado',
|
||||
};
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import common from '../../common';
|
||||
|
||||
export default {
|
||||
phpServer: `${common.php} сервер`,
|
||||
phpMustBeEnabledOnOneSite: `${common.php} должен быть включен как минимум на одном сайте, чтобы сконфигурировать глобальные настройки ${common.php}.`,
|
||||
phpBackupServer: `${common.php} бекап сервер`,
|
||||
tcp: 'TCP',
|
||||
hhvmSocket: 'HHVM сокет',
|
||||
php5Socket: '5.x сокет',
|
||||
php70Socket: '7.0 сокет',
|
||||
php71Socket: '7.1 сокет',
|
||||
php72Socket: '7.2 сокет',
|
||||
php73Socket: '7.3 сокет',
|
||||
php74Socket: '7.4 сокет',
|
||||
php80Socket: '8.0 сокет',
|
||||
phpSocket: 'PHP сокет',
|
||||
custom: 'Другой',
|
||||
disabled: 'Выключено',
|
||||
};
|
@ -1,238 +0,0 @@
|
||||
<!--
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!phpServerEnabled" class="field is-horizontal is-aligned-top">
|
||||
<div class="field-label">
|
||||
<label class="label">{{ $t('templates.globalSections.php.phpServer') }}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="text">
|
||||
{{ $t('templates.globalSections.php.phpMustBeEnabledOnOneSite') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="field is-horizontal is-aligned-top">
|
||||
<div class="field-label has-margin-top">
|
||||
<label class="label">{{ $t('templates.globalSections.php.phpServer') }}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div :class="`control${phpServerChanged ? ' is-changed' : ''}`">
|
||||
<VueSelect v-model="phpServer"
|
||||
:options="phpServerOptions"
|
||||
:clearable="false"
|
||||
:reduce="s => s.value"
|
||||
></VueSelect>
|
||||
</div>
|
||||
|
||||
<div v-if="phpServerCustomEnabled"
|
||||
:class="`control${phpServerCustomChanged ? ' is-changed' : ''}`"
|
||||
>
|
||||
<input v-model="phpServerCustom" class="input" type="text" :placeholder="$props.data.phpServerCustom.default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-horizontal is-aligned-top">
|
||||
<div class="field-label has-margin-top">
|
||||
<label class="label">{{ $t('templates.globalSections.php.phpBackupServer') }}</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div :class="`control${phpBackupServerChanged ? ' is-changed' : ''}`">
|
||||
<VueSelect ref="phpBackupServerSelect"
|
||||
v-model="phpBackupServer"
|
||||
:options="phpBackupServerOptions"
|
||||
:clearable="false"
|
||||
:reduce="s => s.value"
|
||||
></VueSelect>
|
||||
</div>
|
||||
|
||||
<div v-if="phpBackupServerCustomEnabled"
|
||||
:class="`control${phpBackupServerCustomChanged ? ' is-changed' : ''}`"
|
||||
>
|
||||
<input v-model="phpBackupServerCustom" class="input" type="text" :placeholder="$props.data.phpBackupServerCustom.default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VueSelect from 'vue-select';
|
||||
import delegatedFromDefaults from '../../util/delegated_from_defaults';
|
||||
import computedFromDefaults from '../../util/computed_from_defaults';
|
||||
|
||||
// Value -> i18n key
|
||||
const serverOptions = {
|
||||
'127.0.0.1:9000': 'templates.globalSections.php.tcp',
|
||||
'/var/run/hhvm/sock': 'templates.globalSections.php.hhvmSocket',
|
||||
'/var/run/hhvm/hhvm.sock': 'templates.globalSections.php.hhvmSocket',
|
||||
'/var/run/php5-fpm.sock': 'templates.globalSections.php.php5Socket',
|
||||
'/var/run/php/php7.1-fpm.sock': 'templates.globalSections.php.php71Socket',
|
||||
'/var/run/php/php7.2-fpm.sock': 'templates.globalSections.php.php72Socket',
|
||||
'/var/run/php/php7.0-fpm.sock': 'templates.globalSections.php.php70Socket',
|
||||
'/var/run/php/php7.3-fpm.sock': 'templates.globalSections.php.php73Socket',
|
||||
'/var/run/php/php7.4-fpm.sock': 'templates.globalSections.php.php74Socket',
|
||||
'/var/run/php/php8.0-fpm.sock': 'templates.globalSections.php.php80Socket',
|
||||
'/var/run/php/php-fpm.sock': 'templates.globalSections.php.phpSocket',
|
||||
'custom': 'templates.globalSections.php.custom',
|
||||
};
|
||||
const hiddenValues = ['', 'custom'];
|
||||
|
||||
const defaults = {
|
||||
phpServer: {
|
||||
default: '/var/run/php/php-fpm.sock',
|
||||
options: serverOptions,
|
||||
enabled: true,
|
||||
},
|
||||
phpServerCustom: {
|
||||
default: 'unix:/var/run/php/php-fpm.sock',
|
||||
enabled: false,
|
||||
},
|
||||
phpBackupServer: {
|
||||
default: '',
|
||||
options: { '': 'templates.globalSections.php.disabled', ...serverOptions },
|
||||
enabled: true,
|
||||
},
|
||||
phpBackupServerCustom: {
|
||||
default: 'unix:/var/run/php/php-fpm.sock',
|
||||
enabled: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'GlobalPHP', // Component name
|
||||
display: 'common.php', // Display name for tab (i18n key)
|
||||
key: 'php', // Key for data in parent
|
||||
delegated: delegatedFromDefaults(defaults), // Data the parent will present here
|
||||
components: {
|
||||
VueSelect,
|
||||
},
|
||||
props: {
|
||||
data: Object, // Data delegated back to us from parent
|
||||
},
|
||||
computed: {
|
||||
...computedFromDefaults(defaults, 'php'), // Getters & setters for the delegated data
|
||||
phpServerOptions() {
|
||||
return Object.entries(this.$props.data.phpServer.options)
|
||||
.map(([key, value]) => this.formattedOption(key, value));
|
||||
},
|
||||
phpBackupServerOptions() {
|
||||
return Object.entries(this.$props.data.phpBackupServer.options)
|
||||
.map(([key, value]) => this.formattedOption(key, value));
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// Check server selection is valid
|
||||
'$props.data.phpServer': {
|
||||
handler(data) {
|
||||
if (data.enabled) {
|
||||
// This might cause recursion, but seems not to
|
||||
if (!Object.keys(data.options).includes(data.computed))
|
||||
data.computed = data.default;
|
||||
|
||||
// Show the custom box
|
||||
this.$props.data.phpServerCustom.enabled = data.computed === 'custom';
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide custom if disabled
|
||||
this.$props.data.phpServerCustom.enabled = false;
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
// Check backup server selection is valid
|
||||
'$props.data.phpBackupServer': {
|
||||
handler(data) {
|
||||
if (data.enabled) {
|
||||
// This might cause recursion, but seems not to
|
||||
if (!Object.keys(data.options).includes(data.computed))
|
||||
data.computed = data.default;
|
||||
|
||||
// Show the custom box
|
||||
this.$props.data.phpBackupServerCustom.enabled = data.computed === 'custom';
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide custom if disabled
|
||||
this.$props.data.phpBackupServerCustom.enabled = false;
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
// Enable PHP server settings if any site uses PHP
|
||||
'$parent.$parent.$data.domains': {
|
||||
handler(data) {
|
||||
for (const domain of data) {
|
||||
if (domain && domain.php && domain.php.php && domain.php.php.computed) {
|
||||
this.$props.data.phpServer.enabled = true;
|
||||
this.$props.data.phpServer.computed = this.$props.data.phpServer.value;
|
||||
this.$props.data.phpBackupServer.enabled = true;
|
||||
this.$props.data.phpBackupServer.computed = this.$props.data.phpBackupServer.value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.$props.data.phpServer.enabled = false;
|
||||
this.$props.data.phpServer.computed = '';
|
||||
this.$props.data.phpBackupServer.enabled = false;
|
||||
this.$props.data.phpBackupServer.computed = '';
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
// Ensure 'Custom'/'Disabled' get translated in VueSelect on language switch
|
||||
'$i18n.locale'() {
|
||||
if (!this.$refs.phpServerOptions)
|
||||
return false;
|
||||
const updated = this.phpServerOptions
|
||||
.find(x => x.value === this.$refs.phpServerOptions.$data._value.value);
|
||||
if (updated) this.$refs.phpServerOptions.$data._value = updated;
|
||||
|
||||
const updatedBackup = this.phpBackupServerOptions
|
||||
.find(x => x.value === this.$refs.phpBackupServerSelect.$data._value.value);
|
||||
if (updatedBackup) this.$refs.phpBackupServerSelect.$data._value = updatedBackup;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formattedOption(key, value) {
|
||||
return {
|
||||
label: `${this.$t(value)}${hiddenValues.includes(key) ? '' : `: ${key}`}`,
|
||||
value: key,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2021 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import isObject from './is_object';
|
||||
import deepMerge from './deep_merge';
|
||||
|
||||
// Handle converting the old query format to our new query params
|
||||
export default data => {
|
||||
// Handle converting old domain settings to new ones
|
||||
if ('global' in data && isObject(data.global)) {
|
||||
// Handle specifics global data
|
||||
const mappedData = {
|
||||
php: {},
|
||||
};
|
||||
|
||||
// Keys to map
|
||||
const keysToMap = {
|
||||
php: [
|
||||
'phpServer',
|
||||
'phpServerCustom',
|
||||
'phpBackupServer',
|
||||
'phpBackupServerCustom',
|
||||
],
|
||||
};
|
||||
|
||||
for (const key in data.global) {
|
||||
if (!Object.prototype.hasOwnProperty.call(data.global, key)) continue;
|
||||
|
||||
// Skip if key doesn't need to be mapped
|
||||
if (!Object.prototype.hasOwnProperty.call(keysToMap, key)) continue;
|
||||
|
||||
for (const key2 in data.global[key]) {
|
||||
if (!Object.prototype.hasOwnProperty.call(data.global[key], key2)) continue;
|
||||
|
||||
if (keysToMap[key].includes(key2)) {
|
||||
mappedData[key][key2] = data.global[key][key2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const key in data.domains) {
|
||||
if (!Object.prototype.hasOwnProperty.call(data.domains, key)) continue;
|
||||
|
||||
// Deep merge the mapped data
|
||||
deepMerge(data.domains[key], mappedData);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in new issue