Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76a7b86

Browse files
committed
fix: use correct group url in multi-org experiment
When not using the experiment, default to the "default" org. Assuming groups are all in the primary org
1 parent 966c888 commit 76a7b86

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

site/src/pages/GroupsPage/CreateGroupPage.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { useNavigate } from "react-router-dom";
55
import { createGroup } from "api/queries/groups";
66
import { pageTitle } from "utils/page";
77
import CreateGroupPageView from "./CreateGroupPageView";
8+
import { useDashboard } from "modules/dashboard/useDashboard";
89

910
export const CreateGroupPage: FC = () => {
1011
const queryClient = useQueryClient();
1112
const navigate = useNavigate();
1213
const createGroupMutation = useMutation(createGroup(queryClient, "default"));
14+
const { experiments } = useDashboard();
1315

1416
return (
1517
<>
@@ -19,7 +21,13 @@ export const CreateGroupPage: FC = () => {
1921
<CreateGroupPageView
2022
onSubmit={async (data) => {
2123
const newGroup = await createGroupMutation.mutateAsync(data);
22-
navigate(`/groups/${newGroup.name}`);
24+
25+
let groupURL = `/groups/${newGroup.name}`;
26+
if (experiments.includes("multi-organization")) {
27+
groupURL = `/organizations/${newGroup.organization_id}/groups/${newGroup.name}`;
28+
}
29+
30+
navigate(groupURL);
2331
}}
2432
error={createGroupMutation.error}
2533
isLoading={createGroupMutation.isLoading}

site/src/pages/GroupsPage/GroupPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ export const GroupPage: FC = () => {
6060
};
6161
const queryClient = useQueryClient();
6262
const navigate = useNavigate();
63-
const groupQuery = useQuery(group(organization, groupName));
63+
// TODO: Always use the correct organization. At present, the url to fetch a group
64+
// is /groups/:groupName, which does not include the organization. So the orgID cannot
65+
// be inferred from the URL. Until this is resolved, assume the group is in the default org.
66+
const groupQuery = useQuery(group(organization ?? "default", groupName));
6467
const groupData = groupQuery.data;
6568
const { data: permissions } = useQuery(
6669
groupData !== undefined

0 commit comments

Comments
 (0)