Skip to content

Commit

Permalink
change: [UIE-7292] - rename DatabaseScaleUp and all variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolotsk-akamai committed Feb 21, 2024
1 parent f0758d4 commit cb53bad
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 51 deletions.
2 changes: 1 addition & 1 deletion packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Flags {
aclbFullCreateFlow: boolean;
apiMaintenance: APIMaintenance;
databaseBeta: boolean;
databaseScaleUp: boolean;
databaseResize: boolean;
databases: boolean;
firewallNodebalancer: boolean;
ipv6Sharing: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const StyledGrid = styled(Grid, { label: 'StyledGrid' })(
})
);

export const StyledScaleUpButton = styled(Button, {
label: 'StyledScaleUpButton',
export const StyledResizeButton = styled(Button, {
label: 'StyledResizeButton',
})(({ theme }) => ({
[theme.breakpoints.down('md')]: {
marginRight: theme.spacing(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { makeResourcePage } from 'src/mocks/serverHandlers';
import { rest, server } from 'src/mocks/testServer';
import { mockMatchMedia, renderWithTheme } from 'src/utilities/testHelpers';

import { DatabaseScaleUp } from './DatabaseScaleUp';
import { DatabaseResize } from './DatabaseResize';

const queryClient = new QueryClient();
const loadingTestId = 'circle-progress';
Expand All @@ -31,7 +31,7 @@ describe('database resize', () => {

it('should render a loading state', async () => {
const { getByTestId } = renderWithTheme(
<DatabaseScaleUp database={database} />,
<DatabaseResize database={database} />,
{
queryClient,
}
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('database resize', () => {
);

const { getByTestId, getByText } = renderWithTheme(
<DatabaseScaleUp database={database} />,
<DatabaseResize database={database} />,
{
queryClient,
}
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('database resize', () => {

it('resize button should be disabled when no input is provided in the form', async () => {
const { getByTestId, getByText } = renderWithTheme(
<DatabaseScaleUp database={database} />,
<DatabaseResize database={database} />,
{
queryClient,
}
Expand All @@ -120,7 +120,7 @@ describe('database resize', () => {
history.push(`databases/${database.engine}/${database.id}/resize`);
const { container, getByTestId, getByText } = renderWithTheme(
<Router history={history}>
<DatabaseScaleUp database={database} />
<DatabaseResize database={database} />
</Router>,
{
queryClient,
Expand All @@ -129,12 +129,12 @@ describe('database resize', () => {
await waitForElementToBeRemoved(getByTestId(loadingTestId));
const getById = queryByAttribute.bind(null, 'id');
fireEvent.click(getById(container, examplePlanType));
const scaleUpButton = getByText(/Resize Database Cluster/i);
expect(scaleUpButton.closest('button')).toHaveAttribute(
const resizeButton = getByText(/Resize Database Cluster/i);
expect(resizeButton.closest('button')).toHaveAttribute(
'aria-disabled',
'false'
);
fireEvent.click(scaleUpButton);
fireEvent.click(resizeButton);
getByText(`Resize ${database.label}?`);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import {
StyledGrid,
StyledPlanSummarySpan,
StyledPlansPanel,
StyledScaleUpButton,
} from './DatabaseScaleUp.style';
import { DatabaseScaleUpCurrentConfiguration } from './DatabaseScaleUpCurrentConfiguration';
StyledResizeButton,
} from './DatabaseResize.style';
import { DatabaseResizeCurrentConfiguration } from './DatabaseResizeCurrentConfiguration';

interface Props {
database: Database;
}

export const DatabaseScaleUp = ({ database }: Props) => {
export const DatabaseResize = ({ database }: Props) => {
const history = useHistory();

const [planSelected, setPlanSelected] = React.useState<string>();
Expand All @@ -53,12 +53,12 @@ export const DatabaseScaleUp = ({ database }: Props) => {
] = React.useState<boolean>(true);

const [
isScaleUpConfirmationDialogOpen,
setIsScaleUpConfirmationDialogOpen,
isResizeConfirmationDialogOpen,
setIsResizeConfirmationDialogOpen,
] = React.useState(false);

const {
error: scaleUpError,
error: resizeError,
isLoading: submitInProgress,
mutateAsync: updateDatabase,
} = useDatabaseMutation(database.engine, database.id);
Expand All @@ -71,7 +71,7 @@ export const DatabaseScaleUp = ({ database }: Props) => {

const { enqueueSnackbar } = useSnackbar();

const onScaleUp = () => {
const onResize = () => {
updateDatabase({
type: planSelected,
}).then(() => {
Expand All @@ -85,12 +85,12 @@ export const DatabaseScaleUp = ({ database }: Props) => {
});
};

const scaleUpDescription = (
const resizeDescription = (
<>
<Typography variant="h2">Resize a Database Cluster</Typography>
<Typography sx={{ marginTop: '4px' }}>
Adapt the cluster to your needs by scaling it up. Clusters cannot be
scaled down.
Adapt the cluster to your needs by resizing to a larger plan. Clusters
cannot be resized to smaller plans.
</Typography>
</>
);
Expand Down Expand Up @@ -123,12 +123,12 @@ export const DatabaseScaleUp = ({ database }: Props) => {
'data-testid': 'button-confirm',
label: 'Resize',
loading: submitInProgress,
onClick: onScaleUp,
onClick: onResize,
}}
secondaryButtonProps={{
'data-testid': 'button-cancel',
label: 'Cancel',
onClick: () => setIsScaleUpConfirmationDialogOpen(false),
onClick: () => setIsResizeConfirmationDialogOpen(false),
}}
/>
);
Expand Down Expand Up @@ -228,7 +228,7 @@ export const DatabaseScaleUp = ({ database }: Props) => {
// We don't have a "Nanodes" tab anymore, so use `shared`
const selectedTypeClass =
currentPlanClass === 'nanode' ? 'standard' : currentPlanClass;
// User cannot switch to different plan type apart from current plan while scaling up a DB cluster. So disable rest of the tabs.
// User cannot switch to different plan type apart from current plan while resizing a DB cluster. So disable rest of the tabs.
const tabsToBeDisabled = typeClasses
.filter((typeClass) => typeClass !== selectedTypeClass)
.map((plan) => (plan === 'standard' ? 'shared' : plan));
Expand All @@ -242,9 +242,9 @@ export const DatabaseScaleUp = ({ database }: Props) => {
return (
<>
<Paper sx={{ marginTop: 2 }}>
{scaleUpDescription}
{resizeDescription}
<Box sx={{ marginTop: 2 }}>
<DatabaseScaleUpCurrentConfiguration database={database} />
<DatabaseResizeCurrentConfiguration database={database} />
</Box>
</Paper>
<Paper sx={{ marginTop: 2 }}>
Expand All @@ -264,22 +264,22 @@ export const DatabaseScaleUp = ({ database }: Props) => {
</Paper>
<Paper sx={{ marginTop: 2 }}>{summaryPanel}</Paper>
<StyledGrid>
<StyledScaleUpButton
<StyledResizeButton
onClick={() => {
setIsScaleUpConfirmationDialogOpen(true);
setIsResizeConfirmationDialogOpen(true);
}}
buttonType="primary"
disabled={shouldSubmitBeDisabled}
type="submit"
>
Resize Database Cluster
</StyledScaleUpButton>
</StyledResizeButton>
</StyledGrid>
<ConfirmationDialog
actions={confirmationDialogActions}
error={scaleUpError?.[0].reason}
onClose={() => setIsScaleUpConfirmationDialogOpen(false)}
open={isScaleUpConfirmationDialogOpen}
error={resizeError?.[0].reason}
onClose={() => setIsResizeConfirmationDialogOpen(false)}
open={isResizeConfirmationDialogOpen}
title={`Resize ${database.label}?`}
>
{confirmationPopUpMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { makeResourcePage } from 'src/mocks/serverHandlers';
import { rest, server } from 'src/mocks/testServer';
import { mockMatchMedia, renderWithTheme } from 'src/utilities/testHelpers';

import { DatabaseScaleUpCurrentConfiguration } from './DatabaseScaleUpCurrentConfiguration';
import { DatabaseResizeCurrentConfiguration } from './DatabaseResizeCurrentConfiguration';

const queryClient = new QueryClient();
const loadingTestId = 'circle-progress';
Expand All @@ -21,7 +21,7 @@ describe('database current configuration section', () => {
const database = databaseFactory.build();
it('should render a loading state', async () => {
const { getByTestId } = renderWithTheme(
<DatabaseScaleUpCurrentConfiguration database={database} />,
<DatabaseResizeCurrentConfiguration database={database} />,
{
queryClient,
}
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('database current configuration section', () => {
);

const { getByTestId, getByText } = renderWithTheme(
<DatabaseScaleUpCurrentConfiguration database={database} />,
<DatabaseResizeCurrentConfiguration database={database} />,
{
queryClient,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
StyledSummaryTextBox,
StyledSummaryTextTypography,
StyledTitleTypography,
} from './DatabaseScaleUpCurrentConfiguration.style';
} from './DatabaseResizeCurrentConfiguration.style';

interface Props {
database: Database;
Expand All @@ -32,7 +32,7 @@ export const getDatabaseVersionNumber = (
version: DatabaseInstance['version']
) => version.split('/')[1];

export const DatabaseScaleUpCurrentConfiguration = ({ database }: Props) => {
export const DatabaseResizeCurrentConfiguration = ({ database }: Props) => {
const {
data: types,
error: typesError,
Expand Down
12 changes: 6 additions & 6 deletions packages/manager/src/features/Databases/DatabaseDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
const DatabaseSummary = React.lazy(() => import('./DatabaseSummary'));
const DatabaseBackups = React.lazy(() => import('./DatabaseBackups'));
const DatabaseSettings = React.lazy(() => import('./DatabaseSettings'));
const DatabaseScaleUp = React.lazy(() =>
import('./DatabaseScaleUp/DatabaseScaleUp').then(({ DatabaseScaleUp }) => ({
default: DatabaseScaleUp,
const DatabaseResize = React.lazy(() =>
import('./DatabaseResize/DatabaseResize').then(({ DatabaseResize }) => ({
default: DatabaseResize,
}))
);

Expand Down Expand Up @@ -84,7 +84,7 @@ export const DatabaseDetail = () => {
},
];

if (flags.databaseScaleUp) {
if (flags.databaseResize) {
tabs.push({
routeName: `/databases/${engine}/${id}/resize`,
title: 'Resize',
Expand Down Expand Up @@ -164,9 +164,9 @@ export const DatabaseDetail = () => {
<SafeTabPanel index={2}>
<DatabaseSettings database={database} />
</SafeTabPanel>
{flags.databaseScaleUp ? (
{flags.databaseResize ? (
<SafeTabPanel index={3}>
<DatabaseScaleUp database={database} />
<DatabaseResize database={database} />
</SafeTabPanel>
) : null}
</TabPanels>
Expand Down
9 changes: 4 additions & 5 deletions packages/manager/src/features/Events/eventMessageGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@ export const eventMessageCreators: { [index: string]: CreatorsForStatus } = {
notification: (e) => `Database ${e.entity!.label} has low disk space.`,
},
database_resize: {
failed: (e) => `Database ${e.entity!.label} could not be scaled up.`,
finished: (e) => `Database ${e.entity!.label} has been scaled up.`,
scheduled: (e) =>
`Database ${e.entity!.label} is scheduled for scaling up.`,
started: (e) => `Database ${e.entity!.label} is scaling up.`,
failed: (e) => `Database ${e.entity!.label} could not be resized.`,
finished: (e) => `Database ${e.entity!.label} has been resized.`,
scheduled: (e) => `Database ${e.entity!.label} is scheduled for resizing.`,
started: (e) => `Database ${e.entity!.label} is resizing.`,
},
database_update: {
finished: (e) => `Database ${e.entity!.label} has been updated.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export const PlanContainer = (props: Props) => {

// DC Dynamic price logic - DB creation and DB resize flows are currently out of scope
const isDatabaseCreateFlow = location.pathname.includes('/databases/create');
const isDatabaseScaleUpFlow =
const isDatabaseResizeFlow =
location.pathname.match(/\/databases\/.*\/(\d+\/resize)/)?.[0] ===
location.pathname;
const shouldDisplayNoRegionSelectedMessage =
!selectedRegionId && !isDatabaseCreateFlow && !isDatabaseScaleUpFlow;
!selectedRegionId && !isDatabaseCreateFlow && !isDatabaseResizeFlow;

const renderPlanSelection = React.useCallback(() => {
return plans.map((plan, id) => {
Expand Down

0 comments on commit cb53bad

Please sign in to comment.