8000 fix: fix loading states and permissions checks in organization settings by aslilac · Pull Request #16465 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix: fix loading states and permissions checks in organization settings #16465

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 25 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
🧹
  • Loading branch information
aslilac committed Feb 18, 2025
commit 5cd198bb067acee80ade32d3f483581c67537ec0
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useMutation, useQuery, useQueryClient } from "react-query";
import { useNavigate, useParams } from "react-router-dom";
import { pageTitle } from "utils/page";
import CreateEditRolePageView from "./CreateEditRolePageView";
import { ErrorAlert } from "components/Alert/ErrorAlert";

export const CreateEditRolePage: FC = () => {
const queryClient = useQueryClient();
Expand All @@ -35,10 +36,14 @@ export const CreateEditRolePage: FC = () => {
);
const role = roleData?.find((role) => role.name === roleName);

if (isLoading || !organizationPermissions) {
if (isLoading) {
return <Loader />;
}

if (!organizationPermissions) {
return <ErrorAlert error="Failed to load organization permissions" />;
}

return (
<>
<Helmet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
MockEntitlementsWithMultiOrg,
MockOrganization,
MockOrganizationAuditorRole,
MockOrganizationPermissions,
MockUser,
} from "testHelpers/entities";
import {
Expand All @@ -23,10 +24,14 @@ beforeEach(() => {
return HttpResponse.json(MockEntitlementsWithMultiOrg);
}),
http.post("/api/v2/authcheck", async () => {
return HttpResponse.json({
editMembers: true,
viewDeploymentValues: true,
});
return HttpResponse.json(
Object.fromEntries(
Object.entries(MockOrganizationPermissions).map(([key, value]) => [
`${MockOrganization.id}.${key}`,
value,
]),
),
);
}),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { OrganizationMemberWithUserData, User } from "api/typesGenerated";
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
import { EmptyState } from "components/EmptyState/EmptyState";
import { displayError, displaySuccess } from "components/GlobalSnackbar/utils";
import { Loader } from "components/Loader/Loader";
import { Stack } from "components/Stack/Stack";
import { useAuthenticated } from "contexts/auth/RequireAuth";
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const OrganizationMembersPageView: FC<
onSubmit={addMember}
/>
)}

<Table>
<TableHeader>
<TableRow>
Expand Down
Loading
0