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 7, 2025
commit 45b2ba62b34727f250da573d8d3aa69cfb6eb913
10 changes: 5 additions & 5 deletions site/src/api/queries/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type {
RoleSyncSettings,
UpdateOrganizationRequest,
} from "api/typesGenerated";
import type { QueryClient } from "react-query";
import { meKey } from "./users";
import {
organizationPermissionChecks,
type OrganizationPermissions,
type AnyOrganizationPermissions,
type OrganizationPermissionName,
type OrganizationPermissions,
anyOrganizationPermissionChecks,
type AnyOrganizationPermissions,
organizationPermissionChecks,
} from "modules/management/organizationPermissions";
import type { QueryClient } from "react-query";
import { meKey } from "./users";

export const createOrganization = (queryClient: QueryClient) => {
return {
Expand Down
2 changes: 0 additions & 2 deletions site/src/contexts/auth/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ export const AuthProvider: FC<PropsWithChildren> = ({ children }) => {
[updateProfileMutation],
);

console.log(permissionsQuery.data);

return (
<AuthContext.Provider
value={{
Expand Down
2 changes: 1 addition & 1 deletion site/src/modules/dashboard/DashboardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import type {
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Loader } from "components/Loader/Loader";
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
import { canViewAnyOrganization } from "modules/management/organizationPermissions";
import { type FC, type PropsWithChildren, createContext } from "react";
import { useQuery } from "react-query";
import { selectFeatureVisibility } from "./entitlements";
import { canViewAnyOrganization } from "modules/management/organizationPermissions";

export interface DashboardValue {
entitlements: Entitlements;
Expand Down
4 changes: 1 addition & 3 deletions site/src/modules/management/OrganizationSettingsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { type FC, Suspense, createContext, useContext } from "react";
import { useQuery } from "react-query";
import { Outlet, useParams } from "react-router-dom";
import {
canViewOrganization,
type OrganizationPermissions,
canViewOrganization,
} from "./organizationPermissions";

export const OrganizationSettingsContext = createContext<
Expand Down Expand Up @@ -83,8 +83,6 @@ const OrganizationSettingsLayout: FC = () => {
return <NotFoundPage />;
}

console.log(orgPermissionsQuery.data);

return (
<RequirePermission isFeatureVisible={canViewOrganizationSettings}>
<OrganizationSettingsContext.Provider
Expand Down
2 changes: 1 addition & 1 deletion site/src/modules/management/OrganizationSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Sidebar as BaseSidebar } from "components/Sidebar/Sidebar";
import { useAuthenticated } from "contexts/auth/RequireAuth";
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout";
import type { FC } from "react";
import { OrganizationSidebarView } from "./OrganizationSidebarView";
import { Sidebar as BaseSidebar } from "components/Sidebar/Sidebar";

/**
* Sidebar for the OrganizationSettingsLayout
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/GroupsPage/GroupsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import GroupAdd from "@mui/icons-material/GroupAddOutlined";
import { getErrorMessage } from "api/errors";
import { groupsByOrganization } from "api/queries/groups";
import { organizationsPermissions } from "api/queries/organizations";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Button } from "components/Button/Button";
import { EmptyState } from "components/EmptyState/EmptyState";
import { displayError } from "components/GlobalSnackbar/utils";
Expand All @@ -16,7 +17,6 @@ import { Link as RouterLink } from "react-router-dom";
import { pageTitle } from "utils/page";
import { useGroupsSettings } from "./GroupsPageProvider";
import GroupsPageView from "./GroupsPageView";
import { ErrorAlert } from "components/Alert/ErrorAlert";

export const GroupsPage: FC = () => {
const { template_rbac: groupsEnabled } = useFeatureVisibility();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { FC } from "react";
import { EmptyState } from "components/EmptyState/EmptyState";
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout";
import { Navigate } from "react-router-dom";
import { canEditOrganization } from "modules/management/organizationPermissions";
import type { FC } from "react";
import { Navigate } from "react-router-dom";

const DefaultOrganizationRedirect: FC = () => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import { useOrganizationSettings } from "modules/management/OrganizationSettings
import { type FC, useState } from "react";
import { Helmet } from "react-helmet-async";
import { useMutation, useQuery, useQueryClient } from "react-query";
import { useParams } from "react-router-dom";
import { pageTitle } from "utils/page";
import { OrganizationMembersPageView } from "./OrganizationMembersPageView";
import { useParams } from "react-router-dom";

const OrganizationMembersPage: FC = () => {
const queryClient = useQueryClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
organizationsPermissions,
updateOrganization,
} from "api/queries/organizations";
import type { AuthorizationResponse } from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { EmptyState } from "components/EmptyState/EmptyState";
import { displaySuccess } from "components/GlobalSnackbar/utils";
Expand All @@ -12,7 +13,6 @@ import type { FC } from "react";
import { useMutation, useQuery, useQueryClient } from "react-query";
import { Navigate, useNavigate, useParams } from "react-router-dom";
import { OrganizationSettingsPageView } from "./OrganizationSettingsPageView";
import type { AuthorizationResponse } from "api/typesGenerated";

const OrganizationSettingsPage: FC = () => {
const { organization: organizationName } = useParams() as {
Expand Down
Loading