Skip to content

feat: create and modify organization groups #13887

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 14 commits into from
Jul 22, 2024
Prev Previous commit
Next Next commit
🧹
  • Loading branch information
aslilac committed Jul 17, 2024
commit 571bb5eb150c2e360a545e4608ba0db34af87198
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { useFormik } from "formik";
import type { FC } from "react";
import * as Yup from "yup";
import type { Group } from "api/typesGenerated";
import { FormFooter } from "components/FormFooter/FormFooter";
import { FullPageForm } from "components/FullPageForm/FullPageForm";
import {
FormFields,
FormFooter,
FormSection,
HorizontalForm,
} from "components/Form/Form";
import { IconField } from "components/IconField/IconField";
import { Loader } from "components/Loader/Loader";
import { Margins } from "components/Margins/Margins";
import { Stack } from "components/Stack/Stack";
import {
getFormHelpers,
nameValidator,
Expand Down Expand Up @@ -56,9 +58,12 @@ const UpdateGroupForm: FC<UpdateGroupFormProps> = ({
const getFieldHelpers = getFormHelpers<FormData>(form, errors);

return (
<FullPageForm title="Group settings">
<form onSubmit={form.handleSubmit}>
<Stack spacing={2.5}>
<HorizontalForm onSubmit={form.handleSubmit}>
<FormSection
title="Group settings"
description="Set a name and avatar for this group."
>
<FormFields>
<TextField
{...getFieldHelpers("name")}
onChange={onChangeTrimmed(form)}
Expand Down Expand Up @@ -89,6 +94,13 @@ const UpdateGroupForm: FC<UpdateGroupFormProps> = ({
/>
</>
)}
</FormFields>
</FormSection>
<FormSection
title="Quota"
description="You can use quotas to restrict how many resources a user can create."
>
<FormFields>
<TextField
{...getFieldHelpers("quota_allowance", {
helperText: `This group gives ${form.values.quota_allowance} quota credits to each
Expand All @@ -100,11 +112,11 @@ const UpdateGroupForm: FC<UpdateGroupFormProps> = ({
type="number"
label="Quota Allowance"
/>
</Stack>
</FormFields>
</FormSection>

<FormFooter onCancel={onCancel} isLoading={isLoading} />
</form>
</FullPageForm>
<FormFooter onCancel={onCancel} isLoading={isLoading} />
</HorizontalForm>
);
};

Expand All @@ -130,15 +142,13 @@ const GroupSettingsPageView: FC<SettingsGroupPageViewProps> = ({
}

return (
<Margins>
<UpdateGroupForm
group={group!}
onCancel={onCancel}
errors={formErrors}
isLoading={isUpdating}
onSubmit={onSubmit}
/>
</Margins>
<UpdateGroupForm
group={group!}
onCancel={onCancel}
errors={formErrors}
isLoading={isUpdating}
onSubmit={onSubmit}
/>
);
};

Expand Down
1 change: 0 additions & 1 deletion site/src/pages/ManagementSettingsPage/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const DeploymentSettingsNavigation: FC = () => {
Observability
</SidebarNavSubItem>
<SidebarNavSubItem href="/users">Users</SidebarNavSubItem>
<SidebarNavSubItem href="/groups">Groups</SidebarNavSubItem>
</Stack>
)}
</div>
Expand Down
34 changes: 19 additions & 15 deletions site/src/pages/UsersPage/UsersLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import { useAuthenticated } from "contexts/auth/RequireAuth";
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
import { USERS_LINK } from "modules/navigation";
import { useDashboard } from "modules/dashboard/useDashboard";

Check failure on line 18 in site/src/pages/UsersPage/UsersLayout.tsx

View workflow job for this annotation

GitHub Actions / lint

`modules/dashboard/useDashboard` import should occur before import of `modules/dashboard/useFeatureVisibility`

Check failure on line 18 in site/src/pages/UsersPage/UsersLayout.tsx

View workflow job for this annotation

GitHub Actions / lint

`modules/dashboard/useDashboard` import should occur before import of `modules/dashboard/useFeatureVisibility`

export const UsersLayout: FC = () => {
const { permissions } = useAuthenticated();
const { experiments } = useDashboard();
const { createUser: canCreateUser, createGroup: canCreateGroup } =
permissions;
const navigate = useNavigate();
Expand Down Expand Up @@ -57,21 +59,23 @@
</PageHeader>
</Margins>

<Tabs
css={{ marginBottom: 40, marginTop: -TAB_PADDING_Y }}
active={activeTab}
>
<Margins>
<TabsList>
<TabLink to={USERS_LINK} value="users">
Users
</TabLink>
<TabLink to="/groups" value="groups">
Groups
</TabLink>
</TabsList>
</Margins>
</Tabs>
{!experiments.includes("multi-organization") && (
<Tabs
css={{ marginBottom: 40, marginTop: -TAB_PADDING_Y }}
active={activeTab}
>
<Margins>
<TabsList>
<TabLink to={USERS_LINK} value="users">
Users
</TabLink>
<TabLink to="/groups" value="groups">
Groups
</TabLink>
</TabsList>
</Margins>
</Tabs>
)}

<Margins>
<Suspense fallback={<Loader />}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const WorkspaceSettingsForm: FC<WorkspaceSettingsFormProps> = ({
workspace.allow_renames
? form.values.name !== form.initialValues.name &&
"Depending on the template, renaming your workspace may be destructive"
: "Renaming your workspace can be destructive and has not been enabled for this deployment."
: "Renaming your workspace can be destructive and is disabled by the template."
}
/>
</FormFields>
Expand Down
Loading