diff --git a/src/containers/PDiskPage/PDiskPage.tsx b/src/containers/PDiskPage/PDiskPage.tsx index 2c4dbb43e..0ca6066bf 100644 --- a/src/containers/PDiskPage/PDiskPage.tsx +++ b/src/containers/PDiskPage/PDiskPage.tsx @@ -81,9 +81,12 @@ export function PDiskPage() { const handleRestart = async (isRetry?: boolean) => { if (pDiskParamsDefined) { - return window.api.restartPDisk({nodeId, pDiskId, force: isRetry}).then((res) => { - if (res?.result === false) { - const err = {statusText: res.error, retryPossible: res.forceRetryPossible}; + return window.api.restartPDisk({nodeId, pDiskId, force: isRetry}).then((response) => { + if (response?.result === false) { + const err = { + statusText: response.error, + retryPossible: response.forceRetryPossible, + }; throw err; } }); diff --git a/src/containers/VDiskPage/VDiskPage.tsx b/src/containers/VDiskPage/VDiskPage.tsx index 85b19a8fe..e2b208c24 100644 --- a/src/containers/VDiskPage/VDiskPage.tsx +++ b/src/containers/VDiskPage/VDiskPage.tsx @@ -56,24 +56,34 @@ export function VDiskPage() { const loading = isFetching && currentData === undefined; const {vDiskData = {}, groupData} = currentData || {}; const {NodeHost, NodeId, NodeType, NodeDC, PDiskId, PDiskType, Severity, VDiskId} = vDiskData; - - const handleEvictVDisk = async () => { - const {GroupID, GroupGeneration, Ring, Domain, VDisk} = VDiskId || {}; - - if ( - valueIsDefined(GroupID) && - valueIsDefined(GroupGeneration) && - valueIsDefined(Ring) && - valueIsDefined(Domain) && - valueIsDefined(VDisk) - ) { - return window.api.evictVDisk({ - groupId: GroupID, - groupGeneration: GroupGeneration, - failRealmIdx: Ring, - failDomainIdx: Domain, - vDiskIdx: VDisk, - }); + const {GroupID, GroupGeneration, Ring, Domain, VDisk} = VDiskId || {}; + const vDiskIdParamsDefined = + valueIsDefined(GroupID) && + valueIsDefined(GroupGeneration) && + valueIsDefined(Ring) && + valueIsDefined(Domain) && + valueIsDefined(VDisk); + + const handleEvictVDisk = async (isRetry?: boolean) => { + if (vDiskIdParamsDefined) { + return window.api + .evictVDisk({ + groupId: GroupID, + groupGeneration: GroupGeneration, + failRealmIdx: Ring, + failDomainIdx: Domain, + vDiskIdx: VDisk, + force: isRetry, + }) + .then((response) => { + if (response?.result === false) { + const err = { + statusText: response.error, + retryPossible: response.forceRetryPossible, + }; + throw err; + } + }); } return undefined; @@ -131,9 +141,10 @@ export function VDiskPage() { ( + path, + {}, {}, { - headers: { - // This handler requires exactly this string - // Automatic headers may not suit - Accept: 'application/json', - }, requestConfig: {'axios-retry': {retries: 0}}, }, ); @@ -543,7 +542,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper { pDiskId: number | string; force?: boolean; }) { - return this.post( + return this.post( this.getPath(`/pdisk/restart?node_id=${nodeId}&pdisk_id=${pDiskId}&force=${force}`), {}, {}, diff --git a/src/types/api/restartPDisk.ts b/src/types/api/modifyDisk.ts similarity index 60% rename from src/types/api/restartPDisk.ts rename to src/types/api/modifyDisk.ts index 98354f37e..e24e78f71 100644 --- a/src/types/api/restartPDisk.ts +++ b/src/types/api/modifyDisk.ts @@ -1,4 +1,7 @@ -export interface RestartPDiskResponse { +/** + * endpoints: pdisk/restart and vdiks/evict + */ +export interface ModifyDiskResponse { // true if successful, false if not result?: boolean; // Error message