Skip to content

Commit

Permalink
Rename flag to mlUpgradeModeEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed Sep 20, 2021
1 parent 824e900 commit 92e5d6a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Machine learning deprecation flyout', () => {

beforeEach(async () => {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(esDeprecationsMockResponse);
httpRequestsMockHelpers.setLoadMlUpgradeModeResponse({ mlUpgradeMode: false });
httpRequestsMockHelpers.setLoadMlUpgradeModeResponse({ mlUpgradeModeEnabled: false });
httpRequestsMockHelpers.setUpgradeMlSnapshotStatusResponse({
nodeId: 'my_node',
snapshotId: MOCK_SNAPSHOT_ID,
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Machine learning deprecation flyout', () => {
});

it('Doesnt allow to take actions if ml_upgrade_mode is enabled', async () => {
httpRequestsMockHelpers.setLoadMlUpgradeModeResponse({ mlUpgradeMode: true });
httpRequestsMockHelpers.setLoadMlUpgradeModeResponse({ mlUpgradeModeEnabled: true });

await act(async () => {
testBed = await setupElasticsearchPage({ isReadOnlyMode: false });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useSnapshotState, SnapshotState } from './use_snapshot_state';

export interface MlSnapshotContext {
snapshotState: SnapshotState;
mlUpgradeMode: boolean;
mlUpgradeModeEnabled: boolean;
upgradeSnapshot: () => Promise<void>;
deleteSnapshot: () => Promise<void>;
}
Expand All @@ -32,14 +32,14 @@ interface Props {
children: React.ReactNode;
snapshotId: string;
jobId: string;
mlUpgradeMode: boolean;
mlUpgradeModeEnabled: boolean;
}

export const MlSnapshotsStatusProvider: React.FunctionComponent<Props> = ({
api,
snapshotId,
jobId,
mlUpgradeMode,
mlUpgradeModeEnabled,
children,
}) => {
const { updateSnapshotStatus, snapshotState, upgradeSnapshot, deleteSnapshot } = useSnapshotState(
Expand All @@ -60,7 +60,7 @@ export const MlSnapshotsStatusProvider: React.FunctionComponent<Props> = ({
snapshotState,
upgradeSnapshot,
deleteSnapshot,
mlUpgradeMode,
mlUpgradeModeEnabled,
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const FixSnapshotsFlyout = ({
snapshotState,
upgradeSnapshot,
deleteSnapshot,
mlUpgradeMode,
mlUpgradeModeEnabled,
}: FixSnapshotsFlyoutProps) => {
const {
services: {
Expand Down Expand Up @@ -207,7 +207,7 @@ export const FixSnapshotsFlyout = ({
</>
)}

{mlUpgradeMode && (
{mlUpgradeModeEnabled && (
<>
<EuiCallOut
title={i18nTexts.upgradeModeEnabledErrorTitle}
Expand Down Expand Up @@ -240,7 +240,7 @@ export const FixSnapshotsFlyout = ({
</EuiButtonEmpty>
</EuiFlexItem>

{!isResolved && !mlUpgradeMode && (
{!isResolved && !mlUpgradeModeEnabled && (
<EuiFlexItem grow={false}>
<EuiFlexGroup>
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { useGlobalFlyout } = GlobalFlyout;
interface TableRowProps {
deprecation: EnrichedDeprecationInfo;
rowFieldNames: DeprecationTableColumns[];
mlUpgradeMode: boolean;
mlUpgradeModeEnabled: boolean;
}

export const MlSnapshotsTableRowCells: React.FunctionComponent<TableRowProps> = ({
Expand Down Expand Up @@ -86,7 +86,7 @@ export const MlSnapshotsTableRow: React.FunctionComponent<TableRowProps> = (prop
<MlSnapshotsStatusProvider
snapshotId={(props.deprecation.correctiveAction as MlAction).snapshotId}
jobId={(props.deprecation.correctiveAction as MlAction).jobId}
mlUpgradeMode={props.mlUpgradeMode}
mlUpgradeModeEnabled={props.mlUpgradeModeEnabled}
api={api}
>
<MlSnapshotsTableRowCells {...props} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,17 @@ const cellToLabelMap = {
const cellTypes = Object.keys(cellToLabelMap) as DeprecationTableColumns[];
const pageSizeOptions = PAGINATION_CONFIG.pageSizeOptions;

const renderTableRowCells = (deprecation: EnrichedDeprecationInfo, mlUpgradeMode: boolean) => {
const renderTableRowCells = (
deprecation: EnrichedDeprecationInfo,
mlUpgradeModeEnabled: boolean
) => {
switch (deprecation.correctiveAction?.type) {
case 'mlSnapshot':
return (
<MlSnapshotsTableRow
deprecation={deprecation}
rowFieldNames={cellTypes}
mlUpgradeMode={mlUpgradeMode}
mlUpgradeModeEnabled={mlUpgradeModeEnabled}
/>
);

Expand Down Expand Up @@ -158,7 +161,7 @@ export const EsDeprecationsTable: React.FunctionComponent<Props> = ({
} = useAppContext();

const { data } = api.useLoadMLUpgradeMode();
const mlUpgradeMode = !!data?.mlUpgradeMode;
const mlUpgradeModeEnabled = !!data?.mlUpgradeModeEnabled;

const [sortConfig, setSortConfig] = useState<SortConfig>({
isSortAscending: true,
Expand Down Expand Up @@ -305,7 +308,7 @@ export const EsDeprecationsTable: React.FunctionComponent<Props> = ({
{visibleDeprecations.map((deprecation, index) => {
return (
<EuiTableRow data-test-subj="deprecationTableRow" key={`deprecation-row-${index}`}>
{renderTableRowCells(deprecation, mlUpgradeMode)}
{renderTableRowCells(deprecation, mlUpgradeModeEnabled)}
</EuiTableRow>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class ApiService {

public useLoadMLUpgradeMode() {
return this.useRequest<{
mlUpgradeMode: boolean;
mlUpgradeModeEnabled: boolean;
}>({
path: `${API_BASE_PATH}/ml_upgrade_mode`,
method: 'get',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('ML snapshots APIs', () => {

expect(resp.status).toEqual(200);
expect(resp.payload).toEqual({
mlUpgradeMode: true,
mlUpgradeModeEnabled: true,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export function registerMlSnapshotRoutes({ router, lib: { handleEsError } }: Rou

return response.ok({
body: {
mlUpgradeMode: mlInfo.upgrade_mode,
mlUpgradeModeEnabled: mlInfo.upgrade_mode,
},
});
} catch (e) {
Expand Down

0 comments on commit 92e5d6a

Please sign in to comment.