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
yay polish time
  • Loading branch information
aslilac committed Feb 11, 2025
commit c8db4f73a20ed9c85a06ec62802a1efd38f64596
17 changes: 8 additions & 9 deletions coderd/rbac/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,17 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
Identifier: RoleAuditor(),
DisplayName: "Auditor",
Site: Permissions(map[string][]policy.Action{
// Should be able to read all template details, even in orgs they
// are not in.
ResourceTemplate.Type: {policy.ActionRead, policy.ActionViewInsights},
ResourceAuditLog.Type: {policy.ActionRead},
ResourceUser.Type: {policy.ActionRead},
ResourceGroup.Type: {policy.ActionRead},
ResourceGroupMember.Type: {policy.ActionRead},
ResourceAuditLog.Type: {policy.ActionRead},
// Allow auditors to see the resources that audit logs reflect.
ResourceTemplate.Type: {policy.ActionRead, policy.ActionViewInsights},
ResourceUser.Type: {policy.ActionRead},
ResourceGroup.Type: {policy.ActionRead},
ResourceGroupMember.Type: {policy.ActionRead},
ResourceOrganization.Type: {policy.ActionRead},
ResourceOrganizationMember.Type: {policy.ActionRead},
// Allow auditors to query deployment stats and insights.
ResourceDeploymentStats.Type: {policy.ActionRead},
ResourceDeploymentConfig.Type: {policy.ActionRead},
// Org roles are not really used yet, so grant the perm at the site level.
ResourceOrganizationMember.Type: {policy.ActionRead},
}),
Org: map[string][]Permission{},
User: []Permission{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Stack } from "components/Stack/Stack";
import { usePopover } from "components/deprecated/Popover/Popover";
import type { FC } from "react";
import { Link } from "react-router-dom";

export const Language = {
accountLabel: "Account",
signOutLabel: "Sign Out",
Expand Down Expand Up @@ -129,7 +130,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
</a>
</Tooltip>

{Boolean(buildInfo?.deployment_id) && (
{buildInfo?.deployment_id && (
<div
css={css`
font-size: 12px;
Expand All @@ -145,11 +146,11 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
text-overflow: ellipsis;
`}
>
{buildInfo?.deployment_id}
{buildInfo.deployment_id}
</div>
</Tooltip>
<CopyButton
text={buildInfo!.deployment_id}
text={buildInfo.deployment_id}
buttonStyles={css`
width: 16px;
height: 16px;
Expand Down
6 changes: 3 additions & 3 deletions site/src/modules/management/OrganizationSidebarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function urlForSubpage(organizationName: string, subpage = ""): string {

interface OrganizationSettingsNavigationProps {
organization: Organization;
orgPermissions: AuthorizationResponse;
orgPermissions: OrganizationPermissions;
}

const OrganizationSettingsNavigation: FC<
Expand All @@ -184,7 +184,7 @@ const OrganizationSettingsNavigation: FC<
Groups
</SettingsSidebarNavItem>
)}
{orgPermissions.assignOrgRole && (
{orgPermissions.assignOrgRoles && (
<SettingsSidebarNavItem
href={urlForSubpage(organization.name, "roles")}
>
Expand All @@ -205,7 +205,7 @@ const OrganizationSettingsNavigation: FC<
IdP Sync
</SettingsSidebarNavItem>
)}
{orgPermissions.editOrganization && (
{orgPermissions.editSettings && (
<SettingsSidebarNavItem
href={urlForSubpage(organization.name, "settings")}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import {
deleteOrganization,
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";
import { Loader } from "components/Loader/Loader";
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout";
import type { FC } from "react";
import { useMutation, useQuery, useQueryClient } from "react-query";
import { Navigate, useNavigate, useParams } from "react-router-dom";
import { useMutation, useQueryClient } from "react-query";
import { useNavigate } from "react-router-dom";
import { OrganizationSettingsPageView } from "./OrganizationSettingsPageView";

const OrganizationSettingsPage: FC = () => {
Expand Down
Loading