Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VDiskPage): fix evict action #1817

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/containers/VDiskPage/VDiskPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authenticat
import {useDiskPagesAvailable} from '../../store/reducers/capabilities/hooks';
import {setHeaderBreadcrumbs} from '../../store/reducers/header/header';
import {vDiskApi} from '../../store/reducers/vdisk/vdisk';
import type {ModifyDiskResponse} from '../../types/api/modifyDisk';
import {valueIsDefined} from '../../utils';
import {cn} from '../../utils/cn';
import {getSeverityColor, getVDiskSlotBasedId} from '../../utils/disks/helpers';
Expand Down Expand Up @@ -70,27 +71,31 @@ export function VDiskPage() {

const handleEvictVDisk = async (isRetry?: boolean) => {
if (vDiskIdParamsDefined) {
return (
newDiskApiAvailable ? window.api.vdisk.evictVDisk : window.api.tablets.evictVDiskOld
)({
Comment on lines -73 to -75
Copy link
Member Author

@artemmufazalov artemmufazalov Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In such construction this is lost, so this.post inside functions doesn't work.

How it should be done in such case (adding bind):

newDiskApiAvailable ? 
    window.api.vdisk.evictVDisk.bind(window.api.vdisk) :
    window.api.tablets.evictVDiskOld.bind(window.api.tablets)

I rewritten this part so it should work and be readable

const requestParams = {
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;
}
});
};

let response: ModifyDiskResponse;

if (newDiskApiAvailable) {
response = await window.api.vdisk.evictVDisk(requestParams);
} else {
response = await window.api.tablets.evictVDiskOld(requestParams);
}

if (response?.result === false) {
const err = {
statusText: response.error,
retryPossible: response.forceRetryPossible,
};
throw err;
}
}

return undefined;
};

const handleAfterEvictVDisk = () => {
Expand Down
Loading