From 9962be6795b89e778ce061ed45dcb1af8a44d215 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Wed, 3 Apr 2024 16:05:02 +0800 Subject: [PATCH] feat: update code format update code format by yarn run lint Change-Id: Ic413e3f4dc181549d5a751933a22f590bd38d2ad --- src/client/masakari/index.js | 1 - src/core/i18n.js | 35 +++---- src/pages/basic/routes/index.js | 6 +- .../Instance/Detail/BaseDetail/index.jsx | 12 ++- .../containers/Instance/Detail/Log/index.jsx | 39 ++++---- .../containers/Containers/Detail/Console.jsx | 35 +++---- .../ha/containers/Hosts/Detail/BaseDetail.jsx | 16 ++- .../ha/containers/Hosts/Detail/index.jsx | 2 +- .../ha/containers/Hosts/actions/Delete.jsx | 5 +- .../ha/containers/Hosts/actions/Update.jsx | 26 ++--- .../ha/containers/Hosts/actions/index.jsx | 2 +- .../Notifications/Detail/BaseDetail.jsx | 20 ++-- .../containers/Notifications/Detail/index.jsx | 2 +- .../containers/Segments/Detail/BaseDetail.jsx | 2 +- .../containers/Segments/Detail/HostDetail.jsx | 32 +++--- .../containers/Segments/actions/AddHost.jsx | 39 ++++---- .../ha/containers/Segments/actions/Delete.jsx | 2 +- .../Segments/actions/StepCreate/StepHost.jsx | 92 +++++++++--------- .../actions/StepCreate/StepSegment.jsx | 9 +- .../Segments/actions/StepCreate/index.jsx | 97 +++++++++++++------ .../ha/containers/Segments/actions/Update.jsx | 18 ++-- .../ha/containers/Segments/actions/index.jsx | 2 +- .../DNS/Reverse/Detail/BaseDetail.jsx | 3 +- .../containers/DNS/Reverse/Detail/index.jsx | 3 +- .../actions/StepCreate/BaseStep/index.jsx | 5 +- .../StepCreateComponents/PoolStep/index.jsx | 2 +- .../storage/containers/Container/index.jsx | 7 +- src/stores/designate/reverse.js | 12 +-- src/stores/masakari/hosts.js | 26 ++--- src/stores/nova/instance.js | 8 +- 30 files changed, 313 insertions(+), 247 deletions(-) diff --git a/src/client/masakari/index.js b/src/client/masakari/index.js index 11153da3..36a2c10a 100644 --- a/src/client/masakari/index.js +++ b/src/client/masakari/index.js @@ -42,4 +42,3 @@ export class MasakariClient extends Base { const masakariClient = new MasakariClient(); export default masakariClient; - diff --git a/src/core/i18n.js b/src/core/i18n.js index 83b3d866..849f0b19 100644 --- a/src/core/i18n.js +++ b/src/core/i18n.js @@ -174,24 +174,24 @@ const init = () => { }); } else if (lang === 'tr-tr') { moment.locale('tr', { - months: 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split( - '_' - ), + months: + 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split( + '_' + ), monthsShort: 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'), weekdays: 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split( '_' ), weekdaysShort: 'Paz_Pzt_Sal_Çar_Per_Cum_Cmt'.split('_'), weekdaysMin: 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'), - meridiem: function (hours, minutes, isLower) { + meridiem(hours, minutes, isLower) { if (hours < 12) { return isLower ? 'öö' : 'ÖÖ'; - } else { - return isLower ? 'ös' : 'ÖS'; } + return isLower ? 'ös' : 'ÖS'; }, meridiemParse: /öö|ÖÖ|ös|ÖS/, - isPM: function (input) { + isPM(input) { return input === 'ös' || input === 'ÖS'; }, longDateFormat: { @@ -251,24 +251,25 @@ const init = () => { }); } else if (lang === 'ru') { moment.locale('ru', { - months: 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split( - '_' - ), + months: + 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split( + '_' + ), monthsShort: 'Янв_Фев_Мрт_Апр_Май_Июн_Июл_Авг_Сен_Окт_Нбр_Дек'.split('_'), - weekdays: 'Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота'.split( - '_' - ), + weekdays: + 'Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота'.split( + '_' + ), weekdaysShort: 'Пон_Втор_Сред_Четв_Пятн_Субб_Воскр'.split('_'), weekdaysMin: 'Пн_Вт_Ср_Чт_Пт_Сб_Вс'.split('_'), - meridiem: function (hours, minutes, isLower) { + meridiem(hours, minutes, isLower) { if (hours < 12) { return isLower ? 'ночи' : 'Ночи'; - } else { - return isLower ? 'дня' : 'Дня'; } + return isLower ? 'дня' : 'Дня'; }, meridiemParse: /ночи|Ночи|дня|Дня/, - isPM: function (input) { + isPM(input) { return input === 'дня' || input === 'Дня'; }, longDateFormat: { diff --git a/src/pages/basic/routes/index.js b/src/pages/basic/routes/index.js index 5efa288f..556d0c22 100644 --- a/src/pages/basic/routes/index.js +++ b/src/pages/basic/routes/index.js @@ -51,13 +51,13 @@ const Share = lazy(() => import(/* webpackChunkName: "share" */ 'pages/share/App') ); const ContainerInfra = lazy(() => -import(/* webpackChunkName: "container-infra" */ 'pages/container-infra/App') + import(/* webpackChunkName: "container-infra" */ 'pages/container-infra/App') ); const ContainerService = lazy(() => -import(/* webpackChunkName: "Container" */ 'pages/container-service/App') + import(/* webpackChunkName: "Container" */ 'pages/container-service/App') ); const E404 = lazy(() => -import(/* webpackChunkName: "E404" */ 'pages/base/containers/404') + import(/* webpackChunkName: "E404" */ 'pages/base/containers/404') ); const InstanceHA = lazy(() => import(/* webpackChunkName: "Inctance-HA" */ 'pages/ha/App') diff --git a/src/pages/compute/containers/Instance/Detail/BaseDetail/index.jsx b/src/pages/compute/containers/Instance/Detail/BaseDetail/index.jsx index 0888baaa..3fc1011a 100644 --- a/src/pages/compute/containers/Instance/Detail/BaseDetail/index.jsx +++ b/src/pages/compute/containers/Instance/Detail/BaseDetail/index.jsx @@ -176,11 +176,19 @@ export class BaseDetail extends Base { get keypairCard() { const keypair = this.detailData.key_name; const url = this.getRoutePath('keypairDetail', { id: keypair }); - const content = keypair ? (this.isAdminPage ?
{keypair}
: {keypair}) : '-'; + const content = keypair ? ( + this.isAdminPage ? ( +
{keypair}
+ ) : ( + {keypair} + ) + ) : ( + '-' + ); const options = [ { label: t('Name'), - content: content, + content, }, ]; return { diff --git a/src/pages/compute/containers/Instance/Detail/Log/index.jsx b/src/pages/compute/containers/Instance/Detail/Log/index.jsx index e88a2513..eca64c84 100644 --- a/src/pages/compute/containers/Instance/Detail/Log/index.jsx +++ b/src/pages/compute/containers/Instance/Detail/Log/index.jsx @@ -15,7 +15,10 @@ export default function Log(props) { const getLogs = async (tailSize) => { setLoading(true); - const data = await globalInstanceLogStore.fetchLogs(props.detail.id, tailSize); + const data = await globalInstanceLogStore.fetchLogs( + props.detail.id, + tailSize + ); setLogs(data.output); setLoading(false); }; @@ -45,10 +48,7 @@ export default function Log(props) { return (
-
- +

{t('Instance Console Log')}

@@ -58,27 +58,20 @@ export default function Log(props) { } /> -
- -
@@ -95,8 +88,14 @@ export default function Log(props) { fontSize: 12, }} > - {loading ? : logs ?
{logs}
: t('No Logs...')} + {loading ? ( + + ) : logs ? ( +
{logs}
+ ) : ( + t('No Logs...') + )}
); -} \ No newline at end of file +} diff --git a/src/pages/container-service/containers/Containers/Detail/Console.jsx b/src/pages/container-service/containers/Containers/Detail/Console.jsx index b04d5601..cf458111 100644 --- a/src/pages/container-service/containers/Containers/Detail/Console.jsx +++ b/src/pages/container-service/containers/Containers/Detail/Console.jsx @@ -10,37 +10,37 @@ // See the License for the specific language governing permissions and // limitations under the License. -import React, { useEffect } from "react"; +import React, { useEffect } from 'react'; import globalContainersStore from 'src/stores/zun/containers'; export default function Console(props) { - useEffect(() => { globalContainersStore.attach(props.detail.uuid).then((res) => { - const head = document.head; + const { head } = document; - const xtermCssLink = document.createElement("link"); - xtermCssLink.rel = "stylesheet"; - xtermCssLink.href = "https://cdn.jsdelivr.net/npm/xterm@4.19.0/css/xterm.css"; + const xtermCssLink = document.createElement('link'); + xtermCssLink.rel = 'stylesheet'; + xtermCssLink.href = + 'https://cdn.jsdelivr.net/npm/xterm@4.19.0/css/xterm.css'; head.appendChild(xtermCssLink); - - const xtermScript = document.createElement("script"); - xtermScript.src = "https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.5/xterm.min.js"; + const xtermScript = document.createElement('script'); + xtermScript.src = + 'https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.5/xterm.min.js'; xtermScript.onload = () => { const term = new window.Terminal({ cursorBlink: true, }); - term.write(" >$ "); + term.write(' >$ '); term.open(document.getElementById('terminal')); - let socket = new WebSocket(res, ['binary', 'base64']); + const socket = new WebSocket(res, ['binary', 'base64']); term.on('data', function (data) { socket.send(str2ab(data)); }); socket.onmessage = function (e) { if (e.data instanceof Blob) { - let f = new FileReader(); + const f = new FileReader(); f.onload = function () { term.write(f.result); }; @@ -50,8 +50,8 @@ export default function Console(props) { } }; function str2ab(str) { - let buf = new ArrayBuffer(str.length); // 2 bytes for each char - let bufView = new Uint8Array(buf); + const buf = new ArrayBuffer(str.length); // 2 bytes for each char + const bufView = new Uint8Array(buf); for (let i = 0, strLen = str.length; i < strLen; i++) { bufView[i] = str.charCodeAt(i); } @@ -65,14 +65,11 @@ export default function Console(props) { head.removeChild(xtermScript); }; }); - }, []); return (
-
-
-
+
+
); - } diff --git a/src/pages/ha/containers/Hosts/Detail/BaseDetail.jsx b/src/pages/ha/containers/Hosts/Detail/BaseDetail.jsx index 4e997a35..3ccfeee5 100644 --- a/src/pages/ha/containers/Hosts/Detail/BaseDetail.jsx +++ b/src/pages/ha/containers/Hosts/Detail/BaseDetail.jsx @@ -31,18 +31,26 @@ export class BaseDetail extends Base { label: t('Failover Segment'), dataIndex: 'failover_segment_id', render: (value, row) => { - return {row.failover_segment.name} - } + return ( + + {row.failover_segment.name} + + ); + }, }, { label: t('Reserved'), dataIndex: 'reserved', - valueRender: 'yesNo' + valueRender: 'yesNo', }, { label: t('On Maintenance'), dataIndex: 'on_maintenance', - valueRender: 'yesNo' + valueRender: 'yesNo', }, { label: t('Type'), diff --git a/src/pages/ha/containers/Hosts/Detail/index.jsx b/src/pages/ha/containers/Hosts/Detail/index.jsx index 2653b87a..0e2f8ae8 100644 --- a/src/pages/ha/containers/Hosts/Detail/index.jsx +++ b/src/pages/ha/containers/Hosts/Detail/index.jsx @@ -55,7 +55,7 @@ export class HostsDetail extends Base { const hostId = parse(this.routing.location.search.slice(1)); return { id: params.id, - uuid: hostId.uuid + uuid: hostId.uuid, }; }; diff --git a/src/pages/ha/containers/Hosts/actions/Delete.jsx b/src/pages/ha/containers/Hosts/actions/Delete.jsx index 835766f8..02842c6a 100644 --- a/src/pages/ha/containers/Hosts/actions/Delete.jsx +++ b/src/pages/ha/containers/Hosts/actions/Delete.jsx @@ -48,6 +48,9 @@ export default class Delete extends ConfirmAction { onSubmit = (item) => { const { uuid, failover_segment_id } = item || this.item; - return globalHostStore.delete({ segment_id: failover_segment_id, host_id: uuid }); + return globalHostStore.delete({ + segment_id: failover_segment_id, + host_id: uuid, + }); }; } diff --git a/src/pages/ha/containers/Hosts/actions/Update.jsx b/src/pages/ha/containers/Hosts/actions/Update.jsx index 44012849..58a5d0f3 100644 --- a/src/pages/ha/containers/Hosts/actions/Update.jsx +++ b/src/pages/ha/containers/Hosts/actions/Update.jsx @@ -11,7 +11,7 @@ // limitations under the License. import { inject, observer } from 'mobx-react'; -import { ModalAction } from "src/containers/Action"; +import { ModalAction } from 'src/containers/Action'; import globalHostStore from 'src/stores/masakari/hosts'; export class Update extends ModalAction { @@ -33,7 +33,7 @@ export class Update extends ModalAction { get defaultValue() { return { - ...this.item + ...this.item, }; } @@ -44,40 +44,42 @@ export class Update extends ModalAction { label: t('Host Name'), type: 'input', disabled: true, - required: true + required: true, }, { name: 'reserved', label: t('Reserved'), type: 'switch', checkedText: '', - uncheckedText: '' + uncheckedText: '', }, { name: 'type', label: t('Type'), type: 'input', - required: true + required: true, }, { name: 'control_attributes', label: t('Control Attribute'), type: 'input', - required: true + required: true, }, { name: 'on_maintenance', label: t('On Maintenance'), type: 'switch', checkedText: '', - uncheckedText: '' - } - ] + uncheckedText: '', + }, + ]; } onSubmit = (values) => { - return this.store.update(this.item.failover_segment_id, this.item.uuid, { 'host': values }); - } + return this.store.update(this.item.failover_segment_id, this.item.uuid, { + host: values, + }); + }; } -export default inject('rootStore')(observer(Update)); \ No newline at end of file +export default inject('rootStore')(observer(Update)); diff --git a/src/pages/ha/containers/Hosts/actions/index.jsx b/src/pages/ha/containers/Hosts/actions/index.jsx index b397b58d..56e01dbc 100644 --- a/src/pages/ha/containers/Hosts/actions/index.jsx +++ b/src/pages/ha/containers/Hosts/actions/index.jsx @@ -22,7 +22,7 @@ const actionConfigs = { }, ], }, - batchActions: [Delete] + batchActions: [Delete], }; export default actionConfigs; diff --git a/src/pages/ha/containers/Notifications/Detail/BaseDetail.jsx b/src/pages/ha/containers/Notifications/Detail/BaseDetail.jsx index 3f9c2c07..6f2da170 100644 --- a/src/pages/ha/containers/Notifications/Detail/BaseDetail.jsx +++ b/src/pages/ha/containers/Notifications/Detail/BaseDetail.jsx @@ -28,22 +28,22 @@ export class BaseDetail extends Base { { label: t('Host'), dataIndex: 'source_host_uuid', - copyable: true + copyable: true, }, { label: t('Generated Time'), dataIndex: 'generated_time', - valueRender: 'toLocalTime' + valueRender: 'toLocalTime', }, { label: t('Created At'), dataIndex: 'created_at', - valueRender: 'toLocalTime' + valueRender: 'toLocalTime', }, { label: t('Updated At'), dataIndex: 'updated_at', - valueRender: 'toLocalTime' + valueRender: 'toLocalTime', }, ]; @@ -57,23 +57,23 @@ export class BaseDetail extends Base { const options = [ { label: t('Event'), - dataIndex: 'event' + dataIndex: 'event', }, { label: t('Instance UUID'), - dataIndex: 'instance_uuid' + dataIndex: 'instance_uuid', }, { label: t('VIR Domain Event'), - dataIndex: 'vir_domain_event' - } + dataIndex: 'vir_domain_event', + }, ]; return { title: t('Payload'), sourceData: this.detailData.payload, - options - } + options, + }; } } diff --git a/src/pages/ha/containers/Notifications/Detail/index.jsx b/src/pages/ha/containers/Notifications/Detail/index.jsx index e2b1aa8f..2b34e3aa 100644 --- a/src/pages/ha/containers/Notifications/Detail/index.jsx +++ b/src/pages/ha/containers/Notifications/Detail/index.jsx @@ -12,8 +12,8 @@ import { inject, observer } from 'mobx-react'; import Base from 'containers/TabDetail'; -import BaseDetail from './BaseDetail'; import globalNotificationStore from 'stores/masakari/notifications'; +import BaseDetail from './BaseDetail'; export class NotificationsDetail extends Base { init() { diff --git a/src/pages/ha/containers/Segments/Detail/BaseDetail.jsx b/src/pages/ha/containers/Segments/Detail/BaseDetail.jsx index 6352eb8f..f5f3782f 100644 --- a/src/pages/ha/containers/Segments/Detail/BaseDetail.jsx +++ b/src/pages/ha/containers/Segments/Detail/BaseDetail.jsx @@ -32,7 +32,7 @@ export class BaseDetail extends Base { { label: t('Enabled'), dataIndex: 'enabled', - valueRender: 'yesNo' + valueRender: 'yesNo', }, { label: t('Created At'), diff --git a/src/pages/ha/containers/Segments/Detail/HostDetail.jsx b/src/pages/ha/containers/Segments/Detail/HostDetail.jsx index 46228aea..581333dd 100644 --- a/src/pages/ha/containers/Segments/Detail/HostDetail.jsx +++ b/src/pages/ha/containers/Segments/Detail/HostDetail.jsx @@ -36,9 +36,13 @@ export class HostDetail extends Base { title: t('Name'), dataIndex: 'name', render: (value, row) => { - const path = this.getRoutePath('masakariHostDetail', { id: row.failover_segment_id }, { uuid: row.uuid }); + const path = this.getRoutePath( + 'masakariHostDetail', + { id: row.failover_segment_id }, + { uuid: row.uuid } + ); return {value}; - } + }, }, { title: t('UUID'), @@ -49,7 +53,7 @@ export class HostDetail extends Base { title: t('Reserved'), dataIndex: 'reserved', isHideable: true, - valueRender: 'yesNo' + valueRender: 'yesNo', }, { title: t('Type'), @@ -59,27 +63,33 @@ export class HostDetail extends Base { { title: t('Control Attribute'), dataIndex: 'control_attributes', - isHideable: true + isHideable: true, }, { title: t('On Maintenance'), dataIndex: 'on_maintenance', isHideable: true, - valueRender: 'yesNo' - } - , + valueRender: 'yesNo', + }, { title: t('Failover Segment'), dataIndex: 'failover_segment', isHideable: true, render: (value, row) => { - return {row.failover_segment.name} - } - } + return ( + + {row.failover_segment.name} + + ); + }, + }, ]; return columns; }; - } export default inject('rootStore')(observer(HostDetail)); diff --git a/src/pages/ha/containers/Segments/actions/AddHost.jsx b/src/pages/ha/containers/Segments/actions/AddHost.jsx index 8d52ad02..d0969b67 100644 --- a/src/pages/ha/containers/Segments/actions/AddHost.jsx +++ b/src/pages/ha/containers/Segments/actions/AddHost.jsx @@ -11,7 +11,7 @@ // limitations under the License. import { inject, observer } from 'mobx-react'; -import { ModalAction } from "src/containers/Action"; +import { ModalAction } from 'src/containers/Action'; import globalHostStore from 'src/stores/masakari/hosts'; import globalComputeHostStore from 'src/stores/nova/compute-host'; @@ -19,7 +19,7 @@ export class AddHost extends ModalAction { init() { this.store = globalHostStore; this.state = { - host: [] + host: [], }; this.getHostList(); } @@ -37,17 +37,18 @@ export class AddHost extends ModalAction { static allowed = () => Promise.resolve(true); async getHostList() { - const response = await globalComputeHostStore.fetchList({ binary: 'nova-compute' }); + const response = await globalComputeHostStore.fetchList({ + binary: 'nova-compute', + }); const hostList = await globalHostStore.fetchList(); let flag = false; if (hostList.length < 1) { this.setState({ - host: response + host: response, }); - } - else { - response.forEach(newHost => { + } else { + response.forEach((newHost) => { for (let i = 0; i < hostList.length; i++) { if (hostList[i].name === newHost.host) { flag = true; @@ -55,7 +56,7 @@ export class AddHost extends ModalAction { } if (!flag) { this.setState({ - host: [...this.state.host, newHost] + host: [...this.state.host, newHost], }); } flag = false; @@ -74,7 +75,7 @@ export class AddHost extends ModalAction { return { segment_name: this.item.name, reserved: false, - on_maintenance: false + on_maintenance: false, }; } @@ -84,48 +85,48 @@ export class AddHost extends ModalAction { name: 'segment_name', label: t('Segment Name'), type: 'input', - disabled: true + disabled: true, }, { name: 'name', label: t('Host Name'), type: 'select', options: this.getHostName, - required: true + required: true, }, { name: 'reserved', label: t('Reserved'), type: 'switch', checkedText: '', - uncheckedText: '' + uncheckedText: '', }, { name: 'type', label: t('Type'), type: 'input', - required: true + required: true, }, { name: 'control_attributes', label: t('Control Attributes'), type: 'input', - required: true + required: true, }, { name: 'on_maintenance', label: t('On Maintenance'), type: 'switch', checkedText: '', - uncheckedText: '' + uncheckedText: '', }, - ] + ]; } onSubmit = (values) => { const { segment_name, ...submitData } = values; - return this.store.create(this.item.uuid, { 'host': { ...submitData } }); - } + return this.store.create(this.item.uuid, { host: { ...submitData } }); + }; } -export default inject('rootStore')(observer(AddHost)); \ No newline at end of file +export default inject('rootStore')(observer(AddHost)); diff --git a/src/pages/ha/containers/Segments/actions/Delete.jsx b/src/pages/ha/containers/Segments/actions/Delete.jsx index dfa8b1af..835673c4 100644 --- a/src/pages/ha/containers/Segments/actions/Delete.jsx +++ b/src/pages/ha/containers/Segments/actions/Delete.jsx @@ -48,7 +48,7 @@ export default class Delete extends ConfirmAction { onSubmit = (item) => { const { uuid } = item || this.item; - let id = uuid; + const id = uuid; return globalSegmentStore.delete({ id }); }; } diff --git a/src/pages/ha/containers/Segments/actions/StepCreate/StepHost.jsx b/src/pages/ha/containers/Segments/actions/StepCreate/StepHost.jsx index 6e89c275..4076adf4 100644 --- a/src/pages/ha/containers/Segments/actions/StepCreate/StepHost.jsx +++ b/src/pages/ha/containers/Segments/actions/StepCreate/StepHost.jsx @@ -23,7 +23,7 @@ export class StepHost extends Base { this.state = { host: [], hostLoading: true, - ...this.state + ...this.state, }; this.getHostList(); @@ -44,18 +44,18 @@ export class StepHost extends Base { allowed = () => Promise.resolve(); async getHostList() { - - const response = await globalComputeHostStore.fetchList({ binary: 'nova-compute' }); + const response = await globalComputeHostStore.fetchList({ + binary: 'nova-compute', + }); const hostList = await globalHostStore.fetchList(); let flag = false; if (hostList.length < 1) { this.setState({ - host: response + host: response, }); - } - else { - response.forEach(newHost => { + } else { + response.forEach((newHost) => { for (let i = 0; i < hostList.length; i++) { if (hostList[i].name === newHost.host) { flag = true; @@ -69,9 +69,9 @@ export class StepHost extends Base { } const hostMap = Object.fromEntries( - this.state.host.map(host => [host.id, host]) - ) - this.setState({ hostMap: hostMap, hostLoading: false }); + this.state.host.map((host) => [host.id, host]) + ); + this.setState({ hostMap, hostLoading: false }); } get getHostName() { @@ -88,7 +88,7 @@ export class StepHost extends Base { { title: t('Updated'), dataIndex: 'updated_at', - valueRender: 'toLocalTime' + valueRender: 'toLocalTime', }, { name: 'reserved', @@ -99,14 +99,14 @@ export class StepHost extends Base { { - this.setState(prevState => { - const host = prevState.hostMap - host[row.id].reserved = checked - return { hostMap: host } - }) + this.setState((prevState) => { + const host = prevState.hostMap; + host[row.id].reserved = checked; + return { hostMap: host }; + }); }} /> - ) + ), }, { name: 'type', @@ -115,18 +115,18 @@ export class StepHost extends Base { required: true, render: (type, row) => ( { - const { value } = e.target - this.setState(prevState => { - const host = prevState.hostMap - host[row.id].type = value - return { hostMap: host } - }) + const { value } = e.target; + this.setState((prevState) => { + const host = prevState.hostMap; + host[row.id].type = value; + return { hostMap: host }; + }); }} /> - ) + ), }, { name: 'control_attributes', @@ -135,17 +135,17 @@ export class StepHost extends Base { render: (control_attribute, row) => ( { - const { value } = e.target - this.setState(prevState => { - const host = prevState.hostMap - host[row.id].control_attributes = value - return { hostMap: host } - }) + const { value } = e.target; + this.setState((prevState) => { + const host = prevState.hostMap; + host[row.id].control_attributes = value; + return { hostMap: host }; + }); }} /> - ) + ), }, { name: 'on_maintenance', @@ -155,16 +155,16 @@ export class StepHost extends Base { { - this.setState(prevState => { - const host = prevState.hostMap - host[row.id].on_maintenance = checked - return { hostMap: host } - }) + this.setState((prevState) => { + const host = prevState.hostMap; + host[row.id].on_maintenance = checked; + return { hostMap: host }; + }); }} /> - ) - } - ] + ), + }, + ]; return [ { @@ -174,15 +174,15 @@ export class StepHost extends Base { required: true, data: this.state.host, isMulti: true, - onRow: () => { }, - columns: columns, + onRow: () => {}, + columns, isLoading: this.state.hostLoading, filterParams: [ { label: t('Name'), name: 'host' }, { label: t('Zone'), name: 'zone' }, - ] - } - ] + ], + }, + ]; } } diff --git a/src/pages/ha/containers/Segments/actions/StepCreate/StepSegment.jsx b/src/pages/ha/containers/Segments/actions/StepCreate/StepSegment.jsx index 758bd2d8..f7741921 100644 --- a/src/pages/ha/containers/Segments/actions/StepCreate/StepSegment.jsx +++ b/src/pages/ha/containers/Segments/actions/StepCreate/StepSegment.jsx @@ -14,7 +14,6 @@ import { inject, observer } from 'mobx-react'; import Base from 'components/Form'; export class StepSegment extends Base { - get title() { return 'StepSegment'; } @@ -42,7 +41,7 @@ export class StepSegment extends Base { name: 'segment_name', label: t('Segment Name'), type: 'input', - required: true + required: true, }, { name: 'recovery_method', @@ -54,20 +53,20 @@ export class StepSegment extends Base { { label: t('reserved_host'), value: 'reserved_host' }, { label: t('rh_priority'), value: 'rh_priority' }, ], - required: true + required: true, }, { name: 'service_type', label: t('Service Type'), type: 'input', required: true, - disabled: true + disabled: true, }, { name: 'description', label: t('Description'), type: 'textarea', - rows: 4 + rows: 4, }, ]; } diff --git a/src/pages/ha/containers/Segments/actions/StepCreate/index.jsx b/src/pages/ha/containers/Segments/actions/StepCreate/index.jsx index 652a24dd..64379dc4 100644 --- a/src/pages/ha/containers/Segments/actions/StepCreate/index.jsx +++ b/src/pages/ha/containers/Segments/actions/StepCreate/index.jsx @@ -12,9 +12,7 @@ import { inject, observer } from 'mobx-react'; import { StepAction } from 'containers/Action'; -import StepSegment from './StepSegment'; import globalSegmentStore from 'src/stores/masakari/segments'; -import StepHost from './StepHost'; import React from 'react'; import { Button, Modal } from 'antd'; import { toJS } from 'mobx'; @@ -22,6 +20,8 @@ import { QuestionCircleFilled } from '@ant-design/icons'; import stylesConfirm from 'src/components/Confirm/index.less'; import globalHostStore from 'src/stores/masakari/hosts'; import Notify from 'src/components/Notify'; +import StepHost from './StepHost'; +import StepSegment from './StepSegment'; export class StepCreate extends StepAction { static id = 'instance-ha-create'; @@ -54,28 +54,46 @@ export class StepCreate extends StepAction { } next() { - this.currentRef.current.wrappedInstance.checkFormInput((values) => { - this.updateData(values); + this.currentRef.current.wrappedInstance.checkFormInput( + (values) => { + this.updateData(values); - if (this.state.current === 0) { - this.setState({ btnIsLoading: true }) - const { segment_name, recovery_method, service_type, description } = this.state.data; + if (this.state.current === 0) { + this.setState({ btnIsLoading: true }); + const { segment_name, recovery_method, service_type, description } = + this.state.data; - globalSegmentStore.create({ segment: { name: segment_name, recovery_method, service_type, description } }).then(item => { - this.setState({ extra: toJS({ createdSegmentId: item.segment.uuid }) }, () => { - this.setState((prev) => ({ current: prev.current + 1 })); - }) - }, (err) => { - this.responseError = err; - const { response: { data: responseData } = {} } = err; - Notify.errorWithDetail(responseData, this.errorText); + globalSegmentStore + .create({ + segment: { + name: segment_name, + recovery_method, + service_type, + description, + }, + }) + .then( + (item) => { + this.setState( + { extra: toJS({ createdSegmentId: item.segment.uuid }) }, + () => { + this.setState((prev) => ({ current: prev.current + 1 })); + } + ); + }, + (err) => { + this.responseError = err; + const { response: { data: responseData } = {} } = err; + Notify.errorWithDetail(responseData, this.errorText); + } + ) + .finally(() => { + this.setState({ btnIsLoading: false }); + }); } - ).finally(() => { - this.setState({ btnIsLoading: false }) - }); - } - - }, () => this.setState({ btnIsLoading: false })); + }, + () => this.setState({ btnIsLoading: false }) + ); } getNextBtn() { @@ -85,7 +103,11 @@ export class StepCreate extends StepAction { } const { title } = this.steps[current + 1]; return ( - ); @@ -117,32 +139,47 @@ export class StepCreate extends StepAction { Modal.confirm({ title: 'Confirm', icon: , - content: 'Segment will be deleted. Are you sure want to cancel this created segment?', + content: + 'Segment will be deleted. Are you sure want to cancel this created segment?', okText: 'Confirm', cancelText: 'Cancel', loading: true, onOk: () => { - return globalSegmentStore.delete({ id: this.state.extra.createdSegmentId }).finally(() => this.routing.push(this.listUrl)); - } + return globalSegmentStore + .delete({ id: this.state.extra.createdSegmentId }) + .finally(() => this.routing.push(this.listUrl)); + }, }); } else { this.routing.push(this.listUrl); } - } + }; get steps() { return [ { title: t('Create Segment'), component: StepSegment }, - { title: t('Add Host'), component: StepHost } + { title: t('Add Host'), component: StepHost }, ]; } onSubmit = (values) => { const { name } = values; return Promise.resolve( - name.selectedRows.forEach(item => { - const { binary, forced_down, host, id, state, status, updated_at, zone, ...hostData } = item; - this.store.create(this.state.extra.createdSegmentId, { 'host': { name: host, ...hostData } }) + name.selectedRows.forEach((item) => { + const { + binary, + forced_down, + host, + id, + state, + status, + updated_at, + zone, + ...hostData + } = item; + this.store.create(this.state.extra.createdSegmentId, { + host: { name: host, ...hostData }, + }); }) ); }; diff --git a/src/pages/ha/containers/Segments/actions/Update.jsx b/src/pages/ha/containers/Segments/actions/Update.jsx index c83eeb96..38d62fb6 100644 --- a/src/pages/ha/containers/Segments/actions/Update.jsx +++ b/src/pages/ha/containers/Segments/actions/Update.jsx @@ -11,7 +11,7 @@ // limitations under the License. import { inject, observer } from 'mobx-react'; -import { ModalAction } from "src/containers/Action"; +import { ModalAction } from 'src/containers/Action'; import globalSegmentStore from 'src/stores/masakari/segments'; export class Update extends ModalAction { @@ -33,7 +33,7 @@ export class Update extends ModalAction { get defaultValue() { return { - ...this.item + ...this.item, }; } @@ -43,7 +43,7 @@ export class Update extends ModalAction { name: 'name', label: t('Segment Name'), type: 'input', - required: true + required: true, }, { name: 'recovery_method', @@ -55,20 +55,20 @@ export class Update extends ModalAction { { label: t('reserved_host'), value: 'reserved_host' }, { label: t('rh_priority'), value: 'rh_priority' }, ], - required: true + required: true, }, { name: 'description', label: t('Description'), type: 'textarea', - rows: 4 + rows: 4, }, - ] + ]; } onSubmit = (values) => { - return this.store.update(this.item.uuid, { 'segment': values }); - } + return this.store.update(this.item.uuid, { segment: values }); + }; } -export default inject('rootStore')(observer(Update)); \ No newline at end of file +export default inject('rootStore')(observer(Update)); diff --git a/src/pages/ha/containers/Segments/actions/index.jsx b/src/pages/ha/containers/Segments/actions/index.jsx index 0a3c6fc7..36d01aad 100644 --- a/src/pages/ha/containers/Segments/actions/index.jsx +++ b/src/pages/ha/containers/Segments/actions/index.jsx @@ -28,7 +28,7 @@ const actionConfigs = { ], }, batchActions: [Delete], - primaryActions: [StepCreate] + primaryActions: [StepCreate], }; export default actionConfigs; diff --git a/src/pages/network/containers/DNS/Reverse/Detail/BaseDetail.jsx b/src/pages/network/containers/DNS/Reverse/Detail/BaseDetail.jsx index b0384a24..f59d6e99 100644 --- a/src/pages/network/containers/DNS/Reverse/Detail/BaseDetail.jsx +++ b/src/pages/network/containers/DNS/Reverse/Detail/BaseDetail.jsx @@ -55,7 +55,6 @@ export class BaseDetail extends Base { options, }; } - } -export default inject('rootStore')(observer(BaseDetail)); \ No newline at end of file +export default inject('rootStore')(observer(BaseDetail)); diff --git a/src/pages/network/containers/DNS/Reverse/Detail/index.jsx b/src/pages/network/containers/DNS/Reverse/Detail/index.jsx index 9a17d469..94c84460 100644 --- a/src/pages/network/containers/DNS/Reverse/Detail/index.jsx +++ b/src/pages/network/containers/DNS/Reverse/Detail/index.jsx @@ -12,12 +12,11 @@ import { inject, observer } from 'mobx-react'; import Base from 'containers/TabDetail'; +import globalReverseStore from 'stores/designate/reverse'; import BaseDetail from './BaseDetail'; import actionConfigs from '../actions'; -import globalReverseStore from 'src/stores/designate/reverse'; export class ReverseDetail extends Base { - init() { this.store = globalReverseStore; } diff --git a/src/pages/network/containers/LoadBalancers/LoadBalancerInstance/actions/StepCreate/BaseStep/index.jsx b/src/pages/network/containers/LoadBalancers/LoadBalancerInstance/actions/StepCreate/BaseStep/index.jsx index 7e977f4b..8df5d617 100644 --- a/src/pages/network/containers/LoadBalancers/LoadBalancerInstance/actions/StepCreate/BaseStep/index.jsx +++ b/src/pages/network/containers/LoadBalancers/LoadBalancerInstance/actions/StepCreate/BaseStep/index.jsx @@ -80,10 +80,7 @@ export class BaseStep extends Base { }; get formItems() { - const { - network_id, - subnetDetails = [], - } = this.state; + const { network_id, subnetDetails = [] } = this.state; return [ { name: 'name', diff --git a/src/pages/network/containers/LoadBalancers/StepCreateComponents/PoolStep/index.jsx b/src/pages/network/containers/LoadBalancers/StepCreateComponents/PoolStep/index.jsx index 893d06b2..72b82b8d 100644 --- a/src/pages/network/containers/LoadBalancers/StepCreateComponents/PoolStep/index.jsx +++ b/src/pages/network/containers/LoadBalancers/StepCreateComponents/PoolStep/index.jsx @@ -56,7 +56,7 @@ export class PoolStep extends Base { } get formItems() { - const {pool_lb_algorithm} = this.state; + const { pool_lb_algorithm } = this.state; return [ { name: 'pool_name', diff --git a/src/pages/storage/containers/Container/index.jsx b/src/pages/storage/containers/Container/index.jsx index 224910c7..204b2611 100644 --- a/src/pages/storage/containers/Container/index.jsx +++ b/src/pages/storage/containers/Container/index.jsx @@ -65,7 +65,12 @@ function PopUpContent({ name }) { {t('Public Access')} {data.link ? ( - + {t('Click To View')} ) : ( diff --git a/src/stores/designate/reverse.js b/src/stores/designate/reverse.js index d36a723c..c0e83b9c 100644 --- a/src/stores/designate/reverse.js +++ b/src/stores/designate/reverse.js @@ -15,7 +15,6 @@ import client from 'client'; import Base from 'stores/base'; export class ReverseStore extends Base { - get client() { return client.designate.reverse.floatingips; } @@ -34,16 +33,17 @@ export class ReverseStore extends Base { } get paramsFunc() { - return () => { }; + return () => {}; } @action - set = ({ id }, body) => this.submitting(this.reverseClient.setReverse(id, body)); + set = ({ id }, body) => + this.submitting(this.reverseClient.setReverse(id, body)); @action - unset = ({ id }, body) => this.submitting(this.reverseClient.unsetReverse(id, body)); - + unset = ({ id }, body) => + this.submitting(this.reverseClient.unsetReverse(id, body)); } const globalReverseStore = new ReverseStore(); -export default globalReverseStore; \ No newline at end of file +export default globalReverseStore; diff --git a/src/stores/masakari/hosts.js b/src/stores/masakari/hosts.js index 0c64d55b..4506c213 100644 --- a/src/stores/masakari/hosts.js +++ b/src/stores/masakari/hosts.js @@ -3,7 +3,6 @@ import client from 'client'; import { action } from 'mobx'; export class HostStore extends Base { - get client() { return client.masakari.segments.hosts; } @@ -32,22 +31,24 @@ export class HostStore extends Base { const result = []; if (params.segment_id) { - await this.client.list(params.segment_id).then(response => { - response.hosts.map(item => result.push(item)) + await this.client.list(params.segment_id).then((response) => { + response.hosts.map((item) => result.push(item)); }); } else { - await this.segmentClient.list().then(async segmentList => { - const segmentHosts = segmentList.segments.map((it) => this.client.list(it.uuid).then(getHost => getHost.hosts)) - await Promise.all(segmentHosts).then(hostList => { - hostList.forEach(host => { - host.forEach(item => { + await this.segmentClient.list().then(async (segmentList) => { + const segmentHosts = segmentList.segments.map((it) => + this.client.list(it.uuid).then((getHost) => getHost.hosts) + ); + await Promise.all(segmentHosts).then((hostList) => { + hostList.forEach((host) => { + host.forEach((item) => { result.push(item); - }) - }) + }); + }); }); }); } - return { hosts: result } + return { hosts: result }; } @action @@ -56,7 +57,8 @@ export class HostStore extends Base { } @action - delete = ({ segment_id, host_id }) => this.submitting(this.client.delete(segment_id, host_id)); + delete = ({ segment_id, host_id }) => + this.submitting(this.client.delete(segment_id, host_id)); @action update(segmentId, id, body) { diff --git a/src/stores/nova/instance.js b/src/stores/nova/instance.js index 595f45ee..beb4c5c7 100644 --- a/src/stores/nova/instance.js +++ b/src/stores/nova/instance.js @@ -181,9 +181,9 @@ export class ServerStore extends Base { async fetchLogs(id, tailSize) { const logs = await this.client.action(id, { - "os-getConsoleOutput": { - "length": tailSize - } + 'os-getConsoleOutput': { + length: tailSize, + }, }); return logs; } @@ -235,7 +235,7 @@ export class ServerStore extends Base { sgItems = result.map((it) => this.mapperSecurityGroupRule(it.security_group) ); - } catch (e) { } + } catch (e) {} this.securityGroups = { data: sgItems || [], interfaces: ports,