Skip to content

feat: unify organization and deployment management settings #13602

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

Merged
merged 17 commits into from
Jul 1, 2024
Prev Previous commit
Next Next commit
🧹
  • Loading branch information
aslilac committed Jun 20, 2024
commit 73773bf266f1b4ea5112ae8f3bbb603d94eceb5a
4 changes: 2 additions & 2 deletions site/src/pages/ManagementSettingsPage/Horizontal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Interpolation, type Theme } from "@emotion/react";
import { type FC, type HTMLAttributes, type ReactNode } from "react";
import type { Interpolation, Theme } from "@emotion/react";
import type { FC, HTMLAttributes, ReactNode } from "react";

export const HorizontalContainer: FC<HTMLAttributes<HTMLDivElement>> = ({
...attrs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const OrganizationSettingsPage: FC = () => {
{Boolean(error) && <ErrorAlert error={error} />}

<OrganizationSettingsPageView
org={org}
organization={org}
error={error}
onSubmit={async (values) => {
await updateOrganizationMutation.mutateAsync({
Expand All @@ -51,7 +51,7 @@ const OrganizationSettingsPage: FC = () => {
});
displaySuccess("Organization settings updated.");
}}
onDeleteOrg={() => {
onDeleteOrganization={() => {
deleteOrganizationMutation.mutate(org.id);
navigate("/organizations");
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import type { Meta, StoryObj } from "@storybook/react";
import {
MockDefaultOrganization,
MockOrganization,
} from "testHelpers/entities";
import { OrganizationSettingsPageView } from "./OrganizationSettingsPageView";
import { MockOrganization } from "testHelpers/entities";

const meta: Meta<typeof OrganizationSettingsPageView> = {
title: "pages/OrganizationSettingsPageView",
component: OrganizationSettingsPageView,
args: {
org: MockOrganization,
organization: MockOrganization,
},
};

export default meta;
type Story = StoryObj<typeof OrganizationSettingsPageView>;

export const Example: Story = {};

export const DefaultOrg: Story = {
args: {
organization: MockDefaultOrganization,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
Organization,
UpdateOrganizationRequest,
} from "api/typesGenerated";
import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog";
import {
FormFields,
FormSection,
Expand All @@ -23,7 +24,6 @@ import {
onChangeTrimmed,
} from "utils/formUtils";
import { HorizontalContainer, HorizontalSection } from "./Horizontal";
import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog";

const MAX_DESCRIPTION_CHAR_LIMIT = 128;
const MAX_DESCRIPTION_MESSAGE = `Please enter a description that is no longer than ${MAX_DESCRIPTION_CHAR_LIMIT} characters.`;
Expand All @@ -38,22 +38,21 @@ const validationSchema = Yup.object({
});

interface OrganizationSettingsPageViewProps {
org: Organization;
organization: Organization;
error: unknown;
onSubmit: (values: UpdateOrganizationRequest) => Promise<void>;

onDeleteOrg: () => void;
onDeleteOrganization: () => void;
}

export const OrganizationSettingsPageView: FC<
OrganizationSettingsPageViewProps
> = ({ org, error, onSubmit, onDeleteOrg }) => {
> = ({ organization, error, onSubmit, onDeleteOrganization }) => {
const form = useFormik<UpdateOrganizationRequest>({
initialValues: {
name: org.name,
display_name: org.display_name,
description: org.description,
icon: org.icon,
name: organization.name,
display_name: organization.display_name,
description: organization.description,
icon: organization.icon,
},
validationSchema,
onSubmit,
Expand Down Expand Up @@ -113,7 +112,7 @@ export const OrganizationSettingsPageView: FC<
<FormFooter isLoading={form.isSubmitting} />
</HorizontalForm>

{!org.is_default && (
{!organization.is_default && (
<HorizontalContainer css={{ marginTop: 48 }}>
<HorizontalSection
title="Settings"
Expand Down Expand Up @@ -150,7 +149,10 @@ export const OrganizationSettingsPageView: FC<
<span>Deleting an organization is irreversible.</span>
<Button
css={styles.dangerButton}
variant="contained"
// variant="contained"
// varia
color="warning"
// variant="contained"
onClick={() => setIsDeleting(true)}
>
Delete this organization
Expand All @@ -162,38 +164,28 @@ export const OrganizationSettingsPageView: FC<

<DeleteDialog
isOpen={isDeleting}
onConfirm={onDeleteOrg}
onConfirm={onDeleteOrganization}
onCancel={() => setIsDeleting(false)}
entity="organization"
name={org.name}
name={organization.name}
/>
</div>
);
};

const styles = {
dangerButton: (theme) => ({
"&.MuiButton-contained": {
backgroundColor: theme.roles.danger.fill.solid,
borderColor: theme.roles.danger.fill.outline,
// backgroundColor: theme.roles.danger.fill.solid,
borderColor: theme.roles.danger.outline,
color: theme.roles.danger.text,

"&:not(.MuiLoadingButton-loading)": {
color: theme.roles.danger.fill.text,
},

"&:hover:not(:disabled)": {
backgroundColor: theme.roles.danger.hover.fill.solid,
borderColor: theme.roles.danger.hover.fill.outline,
},

"&.Mui-disabled": {
backgroundColor: theme.roles.danger.disabled.background,
borderColor: theme.roles.danger.disabled.outline,
"&:not(.MuiLoadingButton-loading)": {
color: theme.roles.danger.fill.text,
},

"&:not(.MuiLoadingButton-loading)": {
color: theme.roles.danger.disabled.fill.text,
},
},
"&:hover:not(:disabled)": {
backgroundColor: theme.roles.danger.hover.background,
borderColor: theme.roles.danger.hover.fill.outline,
},
}),
} satisfies Record<string, Interpolation<Theme>>;
Loading