Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(site): add basic organization management ui#13288

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 24 commits intomainfromorg-management-ui
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
24 commits
Select commitHold shift + click to select a range
f36f106
rebased old version
aslilacJun 3, 2024
325148c
move out of deployment settings
aslilacJun 3, 2024
c304463
padding and cleanup
aslilacJun 4, 2024
2cb6c5d
🧹
aslilacJun 6, 2024
25a8ee7
Merge branch 'main' into org-management-ui
aslilacJun 6, 2024
b297d3d
w h o o p s
aslilacJun 6, 2024
5f84937
Merge branch 'main' into org-management-ui
aslilacJun 7, 2024
0f9de62
a mostly nice org settings page
aslilacJun 7, 2024
17a890d
🧹
aslilacJun 7, 2024
050d553
wibbles
aslilacJun 10, 2024
bed1bd4
Merge branch 'main' into org-management-ui
aslilacJun 10, 2024
3bab8cb
🔮
aslilacJun 10, 2024
353ef76
Merge branch 'main' into org-management-ui
aslilacJun 11, 2024
b071231
formik strikes again
aslilacJun 11, 2024
f8ccd96
🧹
aslilacJun 11, 2024
98b66a2
Merge branch 'main' into org-management-ui
aslilacJun 12, 2024
0a2bfea
add support for icon
aslilacJun 13, 2024
ed57254
🧹
aslilacJun 13, 2024
d07a319
🧹
aslilacJun 13, 2024
c2263f1
fix footer stories
aslilacJun 13, 2024
1c397bc
🧹
aslilacJun 13, 2024
551191d
🧹
aslilacJun 14, 2024
ab91af8
show update errors and fix padding
aslilacJun 17, 2024
e5bddc6
🧹
aslilacJun 17, 2024
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
2 changes: 1 addition & 1 deletioncodersdk/organizations.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,7 +61,7 @@ type OrganizationMember struct {
type CreateOrganizationRequest struct {
Name string `json:"name" validate:"required,organization_name"`
// DisplayName will default to the same value as `Name` if not provided.
DisplayName string `json:"display_name" validate:"omitempty,organization_display_name"`
DisplayName string `json:"display_name,omitempty" validate:"omitempty,organization_display_name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
}
Expand Down
25 changes: 25 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -505,6 +505,31 @@ class ApiMethods {
return response.data;
};

createOrganization = async (params: TypesGen.CreateOrganizationRequest) => {
const response = await this.axios.post<TypesGen.Organization>(
"/api/v2/organizations",
params,
);
return response.data;
};

updateOrganization = async (
orgId: string,
params: TypesGen.UpdateOrganizationRequest,
) => {
const response = await this.axios.patch<TypesGen.Organization>(
`/api/v2/organizations/${orgId}`,
params,
);
return response.data;
};

deleteOrganization = async (orgId: string) => {
await this.axios.delete<TypesGen.Organization>(
`/api/v2/organizations/${orgId}`,
);
};

getOrganization = async (
organizationId: string,
): Promise<TypesGen.Organization> => {
Expand Down
46 changes: 46 additions & 0 deletionssite/src/api/queries/organizations.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
import type { QueryClient } from "react-query";
import { API } from "api/api";
import type {
CreateOrganizationRequest,
UpdateOrganizationRequest,
} from "api/typesGenerated";
import { meKey, myOrganizationsKey } from "./users";

export const createOrganization = (queryClient: QueryClient) => {
return {
mutationFn: (params: CreateOrganizationRequest) =>
API.createOrganization(params),

onSuccess: async () => {
await queryClient.invalidateQueries(meKey);
await queryClient.invalidateQueries(myOrganizationsKey);
},
};
};

interface UpdateOrganizationVariables {
orgId: string;
req: UpdateOrganizationRequest;
}

export const updateOrganization = (queryClient: QueryClient) => {
return {
mutationFn: (variables: UpdateOrganizationVariables) =>
API.updateOrganization(variables.orgId, variables.req),

onSuccess: async () => {
await queryClient.invalidateQueries(myOrganizationsKey);
},
};
};

export const deleteOrganization = (queryClient: QueryClient) => {
return {
mutationFn: (orgId: string) => API.deleteOrganization(orgId),

onSuccess: async () => {
await queryClient.invalidateQueries(meKey);
await queryClient.invalidateQueries(myOrganizationsKey);
},
};
};
6 changes: 4 additions & 2 deletionssite/src/api/queries/users.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,7 +124,7 @@ export const authMethods = () => {
};
};

const meKey = ["me"];
exportconst meKey = ["me"];

export const me = (metadata: MetadataState<User>) => {
return cachedQuery({
Expand DownExpand Up@@ -250,9 +250,11 @@ export const updateAppearanceSettings = (
};
};

export const myOrganizationsKey = ["organizations", "me"] as const;

export const myOrganizations = () => {
return {
queryKey:["organizations", "me"],
queryKey:myOrganizationsKey,
queryFn: () => API.getOrganizations(),
};
};
2 changes: 1 addition & 1 deletionsite/src/api/typesGenerated.ts
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

12 changes: 10 additions & 2 deletionssite/src/components/FormFooter/FormFooter.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
import { action } from "@storybook/addon-actions";
import type { Meta, StoryObj } from "@storybook/react";
import { FormFooter } from "./FormFooter";

const meta: Meta<typeof FormFooter> = {
title: "components/FormFooter",
component: FormFooter,
args: {
isLoading: false,
onCancel: action("onCancel"),
},
};

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

export const Ready: Story = {
args: {},
};

export const NoCancel: Story = {
args: {
isLoading: false,
onCancel: undefined,
},
};

export const Custom: Story = {
args: {
isLoading: false,
submitLabel: "Create",
},
};
Expand Down
22 changes: 12 additions & 10 deletionssite/src/components/FormFooter/FormFooter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ export interface FormFooterStyles {
}

export interface FormFooterProps {
onCancel: () => void;
onCancel?: () => void;
isLoading: boolean;
styles?: FormFooterStyles;
submitLabel?: string;
Expand DownExpand Up@@ -45,15 +45,17 @@ export const FormFooter: FC<FormFooterProps> = ({
>
{submitLabel}
</LoadingButton>
<Button
size="large"
type="button"
css={styles.button}
onClick={onCancel}
tabIndex={0}
>
{Language.cancelLabel}
</Button>
{onCancel && (
<Button
size="large"
type="button"
css={styles.button}
onClick={onCancel}
tabIndex={0}
>
{Language.cancelLabel}
</Button>
)}
{extraActions}
</div>
);
Expand Down
17 changes: 13 additions & 4 deletionssite/src/components/Margins/Margins.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,20 +13,29 @@ const widthBySize: Record<Size, number> = {
small: containerWidth / 3,
};

export const Margins: FC<JSX.IntrinsicElements["div"] & { size?: Size }> = ({
type MarginsProps = JSX.IntrinsicElements["div"] & {
size?: Size;
};

export const Margins: FC<MarginsProps> = ({
size = "regular",
children,
...divProps
}) => {
const maxWidth = widthBySize[size];
return (
<div
{...divProps}
css={{
margin: "0 auto",
marginLeft: "auto",
marginRight: "auto",
maxWidth: maxWidth,
padding: `0 ${sidePadding}px`,
paddingLeft: sidePadding,
paddingRight: sidePadding,
width: "100%",
}}
/>
>
{children}
</div>
);
};
23 changes: 19 additions & 4 deletionssite/src/modules/dashboard/Navbar/DeploymentDropdown.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,22 +13,25 @@ import {
import { USERS_LINK } from "modules/navigation";

interface DeploymentDropdownProps {
canViewAuditLog: boolean;
canViewDeployment: boolean;
canViewOrganizations: boolean;
canViewAllUsers: boolean;
canViewAuditLog: boolean;
canViewHealth: boolean;
}

export const DeploymentDropdown: FC<DeploymentDropdownProps> = ({
canViewAuditLog,
canViewDeployment,
canViewOrganizations,
canViewAllUsers,
canViewAuditLog,
canViewHealth,
}) => {
const theme = useTheme();

if (
!canViewAuditLog &&
!canViewOrganizations &&
!canViewDeployment &&
!canViewAllUsers &&
!canViewHealth
Expand DownExpand Up@@ -64,9 +67,10 @@ export const DeploymentDropdown: FC<DeploymentDropdownProps> = ({
}}
>
<DeploymentDropdownContent
canViewAuditLog={canViewAuditLog}
canViewDeployment={canViewDeployment}
canViewOrganizations={canViewOrganizations}
canViewAllUsers={canViewAllUsers}
canViewAuditLog={canViewAuditLog}
canViewHealth={canViewHealth}
/>
</PopoverContent>
Expand All@@ -75,9 +79,10 @@ export const DeploymentDropdown: FC<DeploymentDropdownProps> = ({
};

const DeploymentDropdownContent: FC<DeploymentDropdownProps> = ({
canViewAuditLog,
canViewDeployment,
canViewOrganizations,
canViewAllUsers,
canViewAuditLog,
canViewHealth,
}) => {
const popover = usePopover();
Expand All@@ -96,6 +101,16 @@ const DeploymentDropdownContent: FC<DeploymentDropdownProps> = ({
Settings
</MenuItem>
)}
{canViewOrganizations && (
<MenuItem
component={NavLink}
to="/organizations"
css={styles.menuItem}
onClick={onPopoverClose}
>
Organizations
</MenuItem>
)}
{canViewAllUsers && (
<MenuItem
component={NavLink}
Expand Down
5 changes: 3 additions & 2 deletionssite/src/modules/dashboard/Navbar/Navbar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@ export const Navbar: FC = () => {
const { metadata } = useEmbeddedMetadata();
const buildInfoQuery = useQuery(buildInfo(metadata["build-info"]));

const { appearance } = useDashboard();
const { appearance, experiments } = useDashboard();
const { user: me, permissions, signOut } = useAuthenticated();
const featureVisibility = useFeatureVisibility();
const canViewAuditLog =
Expand All@@ -29,10 +29,11 @@ export const Navbar: FC = () => {
buildInfo={buildInfoQuery.data}
supportLinks={appearance.support_links}
onSignOut={signOut}
canViewAuditLog={canViewAuditLog}
canViewDeployment={canViewDeployment}
canViewOrganizations={experiments.includes("multi-organization")}
canViewAllUsers={canViewAllUsers}
canViewHealth={canViewHealth}
canViewAuditLog={canViewAuditLog}
proxyContextValue={proxyContextValue}
/>
);
Expand Down
15 changes: 10 additions & 5 deletionssite/src/modules/dashboard/Navbar/NavbarView.test.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,10 +28,11 @@ describe("NavbarView", () => {
proxyContextValue={proxyContextValue}
user={MockUser}
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewOrganizations
canViewAllUsers
canViewHealth
canViewAuditLog
/>,
);
const workspacesLink = await screen.findByText(navLanguage.workspaces);
Expand All@@ -44,10 +45,11 @@ describe("NavbarView", () => {
proxyContextValue={proxyContextValue}
user={MockUser}
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewOrganizations
canViewAllUsers
canViewHealth
canViewAuditLog
/>,
);
const templatesLink = await screen.findByText(navLanguage.templates);
Expand All@@ -60,10 +62,11 @@ describe("NavbarView", () => {
proxyContextValue={proxyContextValue}
user={MockUser}
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewOrganizations
canViewAllUsers
canViewHealth
canViewAuditLog
/>,
);
const deploymentMenu = await screen.findByText("Deployment");
Expand All@@ -78,10 +81,11 @@ describe("NavbarView", () => {
proxyContextValue={proxyContextValue}
user={MockUser}
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewOrganizations
canViewAllUsers
canViewHealth
canViewAuditLog
/>,
);
const deploymentMenu = await screen.findByText("Deployment");
Expand All@@ -96,10 +100,11 @@ describe("NavbarView", () => {
proxyContextValue={proxyContextValue}
user={MockUser}
onSignOut={noop}
canViewAuditLog
canViewDeployment
canViewOrganizations
canViewAllUsers
canViewHealth
canViewAuditLog
/>,
);
const deploymentMenu = await screen.findByText("Deployment");
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp