Skip to content

Commit

Permalink
🪟 Hide organization info if workspace is not in Cloud for Teams (#12118)
Browse files Browse the repository at this point in the history
  • Loading branch information
teallarson committed Apr 15, 2024
1 parent 8388d2f commit 68d5fd0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions airbyte-webapp/src/core/services/features/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export const defaultEnterpriseFeatures = [
FeatureItem.AllowAllRBACRoles,
FeatureItem.APITokenManagement,
FeatureItem.ConnectionHistoryGraphs,
FeatureItem.DisplayOrganizationUsers,
FeatureItem.EnterpriseBranding,
FeatureItem.IndicateGuestUsers,
FeatureItem.MultiWorkspaceUI,
FeatureItem.RBAC,
];
Expand Down
2 changes: 2 additions & 0 deletions airbyte-webapp/src/core/services/features/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ export enum FeatureItem {
Billing = "BILLING",
ConnectionHistoryGraphs = "CONNECTION_HISTORY_GRAPHS",
ConnectorBreakingChangeDeadlines = "CONNECTOR_BREAKING_CHANGE_DEADLINES",
DisplayOrganizationUsers = "DISPLAY_ORGANIZATION_USERS",
EmailNotifications = "EMAIL_NOTIFICATIONS",
EnterpriseBranding = "ENTERPRISE_BRANDING",
ExternalInvitations = "EXTERNAL_INVITATIONS",
IndicateGuestUsers = "INDICATE_GUEST_USERS",
KeycloakAuthentication = "KEYCLOAK_AUTHENTICATION",
MultiWorkspaceUI = "MULTI_WORKSPACE_UI",
RBAC = "RBAC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useListPermissions } from "core/api";
import { useListCloudWorkspacesInfinite } from "core/api/cloud";
import { OrganizationRead } from "core/api/types/AirbyteClient";

import { CloudWorkspacesPage } from "./CloudWorkspacesPage";
import { CloudWorkspacesPageInner } from "./CloudWorkspacesPage";

jest.mock("core/services/auth", () => ({
useAuthService: () => ({}),
Expand Down Expand Up @@ -47,7 +47,7 @@ describe("CloudWorkspacesPage", () => {
{ permissionType: "organization_member", userId: "123", permissionId: "123", organizationId: "321" },
],
});
const wrapper = await render(<CloudWorkspacesPage />);
const wrapper = await render(<CloudWorkspacesPageInner />);
expect(wrapper.queryByTestId("noWorkspacePermissionsBanner")).toBeInTheDocument();
expect(wrapper.getByTestId("noWorkspacePermissionsBanner")).toHaveTextContent("[email protected]");
});
Expand All @@ -58,7 +58,7 @@ describe("CloudWorkspacesPage", () => {
{ permissionType: "organization_member", userId: "123", permissionId: "123", organizationId: "456" },
],
});
const wrapper = await render(<CloudWorkspacesPage />);
const wrapper = await render(<CloudWorkspacesPageInner />);
expect(wrapper.queryByTestId("noWorkspacePermissionsBanner")).toBeInTheDocument();
expect(wrapper.getByTestId("noWorkspacePermissionsBanner")).toHaveTextContent("[email protected]");
});
Expand All @@ -76,7 +76,7 @@ describe("CloudWorkspacesPage", () => {
{ permissionType: "instance_admin", userId: "123", permissionId: "2" },
],
});
const wrapper = await render(<CloudWorkspacesPage />);
const wrapper = await render(<CloudWorkspacesPageInner />);
expect(wrapper.queryByTestId("noWorkspacePermissionsBanner")).not.toBeInTheDocument();
});
it("should not show if you see any workspaces (e.g. as an instance admin)", async () => {
Expand All @@ -92,7 +92,7 @@ describe("CloudWorkspacesPage", () => {
{ permissionType: "organization_member", userId: "123", permissionId: "123", organizationId: "321" },
],
});
const wrapper = await render(<CloudWorkspacesPage />);
const wrapper = await render(<CloudWorkspacesPageInner />);
expect(wrapper.queryByTestId("noWorkspacePermissionsBanner")).not.toBeInTheDocument();
});

Expand All @@ -103,7 +103,7 @@ describe("CloudWorkspacesPage", () => {
{ permissionType: "organization_editor", userId: "123", permissionId: "2", organizationId: "456" },
],
});
const wrapper = await render(<CloudWorkspacesPage />);
const wrapper = await render(<CloudWorkspacesPageInner />);
expect(wrapper.queryByTestId("noWorkspacePermissionsBanner")).not.toBeInTheDocument();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMutation } from "@tanstack/react-query";
import React, { useDeferredValue, useState } from "react";
import { FormattedMessage } from "react-intl";

import { HeadTitle } from "components/common/HeadTitle";
import AirbyteLogo from "components/illustrations/airbyte-logo.svg?react";
import { Box } from "components/ui/Box";
import { Button } from "components/ui/Button";
Expand All @@ -22,7 +23,7 @@ import { WORKSPACE_LIST_LENGTH } from "pages/workspaces/WorkspacesPage";
import { CloudWorkspacesCreateControl } from "./CloudWorkspacesCreateControl";
import styles from "./CloudWorkspacesPage.module.scss";

export const CloudWorkspacesPage: React.FC = () => {
export const CloudWorkspacesPageInner: React.FC = () => {
const { isLoading: isLogoutLoading, mutateAsync: handleLogout } = useMutation(() => logout?.() ?? Promise.resolve());
useTrackPage(PageTrackingCodes.WORKSPACES);
const [searchValue, setSearchValue] = useState("");
Expand Down Expand Up @@ -107,3 +108,12 @@ export const CloudWorkspacesPage: React.FC = () => {
</div>
);
};

export const CloudWorkspacesPage = () => {
return (
<>
<HeadTitle titles={[{ id: "workspaces.title" }]} />
<CloudWorkspacesPageInner />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UpdateOrganizationSettingsForm } from "./UpdateOrganizationSettingsForm
export const GeneralOrganizationSettingsPage: React.FC = () => {
useTrackPage(PageTrackingCodes.SETTINGS_ORGANIZATION);
const isAccessManagementEnabled = useFeature(FeatureItem.RBAC);
const displayOrganizationUsers = useFeature(FeatureItem.DisplayOrganizationUsers);

return (
<FlexContainer direction="column" gap="xl">
Expand All @@ -22,7 +23,7 @@ export const GeneralOrganizationSettingsPage: React.FC = () => {
</Heading>
<UpdateOrganizationSettingsForm />

{isAccessManagementEnabled && (
{isAccessManagementEnabled && displayOrganizationUsers && (
<>
<Separator />
<OrganizationAccessManagementSection />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Tooltip } from "components/ui/Tooltip";

import { useCurrentOrganizationInfo, useCurrentWorkspace } from "core/api";
import { useCurrentUser } from "core/services/auth";
import { FeatureItem, useFeature } from "core/services/features";
import { useIntent } from "core/utils/rbac";

import { GuestBadge } from "./GuestBadge";
Expand Down Expand Up @@ -49,6 +50,7 @@ export const RoleManagementCell: React.FC<RoleManagementCellProps> = ({ user, re
const canListOrganizationUsers = useIntent("ListOrganizationMembers", {
organizationId: organizationInfo?.organizationId,
});
const indicateGuestUsers = useFeature(FeatureItem.IndicateGuestUsers);
const cannotDemoteUser = resourceType === "workspace" && orgPermissionType === "organization_admin";
const shouldHidePopover = cannotDemoteUser || !canEditPermissions || user.id === currentUser.userId;

Expand Down Expand Up @@ -77,7 +79,7 @@ export const RoleManagementCell: React.FC<RoleManagementCellProps> = ({ user, re
<FormattedMessage id="role.organizationAdmin" />
</Badge>
)}
{canListOrganizationUsers && organizationInfo?.organizationId && (
{canListOrganizationUsers && organizationInfo?.organizationId && indicateGuestUsers && (
<GuestBadge userId={user.id} organizationId={organizationInfo.organizationId} />
)}
{user.invitationStatus === "pending" && (
Expand Down

0 comments on commit 68d5fd0

Please sign in to comment.