Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(organizations): tell organization admins what needs their attention

Petr Bauch009d6f448052
diff --git a/core/switch_core/gateway/organizations.py b/core/switch_core/gateway/organizations.py
index 0ea8b9e68..b847b8204 100644
--- a/core/switch_core/gateway/organizations.py
+++ b/core/switch_core/gateway/organizations.py
@@ -79,6 +79,7 @@ from switch_core.gateway.schemas import (
OrganizationAuditEventDetail,
OrganizationCreateRequest,
OrganizationCreateResponse,
+ OrganizationIssueDetail,
OrganizationMemberDetail,
OrganizationMemberUpdateRequest,
OrganizationSummary,
@@ -99,6 +100,7 @@ from switch_core.organization_access import (
workspaces_where_they_own_agents,
)
from switch_core.organization_directory import DirectoryError, OrganizationDirectory
+from switch_core.organization_issues import organization_issues
router = APIRouter()
@@ -390,6 +392,49 @@ async def list_organization_audit_log(
]
[email protected]("/organizations/current/issues")
+async def list_organization_issues(
+ session: Annotated[AsyncSession, Depends(get_session)],
+ session_factory: Annotated[
+ async_sessionmaker[AsyncSession], Depends(get_session_factory)
+ ],
+ user_store: Annotated[UserStore, Depends(get_user_store)],
+ organization_store: Annotated[OrganizationStore, Depends(get_organization_store)],
+ user: Annotated[User, Depends(get_current_user)],
+) -> list[OrganizationIssueDetail]:
+ """What in the organization needs an admin's attention now
+ (`organization_issues.py`), read from how things stand rather than from
+ the audit log, so an issue is gone once fixed. `org_admin` only, and the
+ platform operator while the organization has none."""
+ access = await _require_organization_admin(
+ session, user_store, organization_store, user, operator_restores=True
+ )
+ organization_id = access.organization_id
+ workspaces = await organization_workspaces_bindable_by(
+ session_factory,
+ user_store,
+ user.id,
+ organization_id,
+ is_operator=access.platform_access,
+ )
+ issues = await organization_issues(
+ session,
+ session_factory,
+ user_store,
+ organization_id=organization_id,
+ workspaces=[(workspace.id, workspace.name) for workspace in workspaces],
+ )
+ return [
+ OrganizationIssueDetail(
+ kind=issue.kind,
+ workspace_id=issue.workspace_id,
+ workspace_name=issue.workspace_name,
+ agents=issue.agents,
+ )
+ for issue in issues
+ ]
+
+
@router.get("/organizations/current/members")
async def list_organization_members(
session: Annotated[AsyncSession, Depends(get_session)],
diff --git a/core/switch_core/gateway/schemas.py b/core/switch_core/gateway/schemas.py
index 440d4cf4f..04593596c 100644
--- a/core/switch_core/gateway/schemas.py
+++ b/core/switch_core/gateway/schemas.py
@@ -25,6 +25,7 @@ from switch_core.db.models import (
MAX_BUDGET_PERIOD_HOURS,
UsageMetric,
)
+from switch_core.organization_issues import IssueKind
# ── Rooms ─────────────────────────────────────────────────────────────────────
@@ -1075,6 +1076,17 @@ class CurrentOrganizationResponse(BaseModel):
role: str | None
+class OrganizationIssueDetail(BaseModel):
+ """Something in the organization that needs an admin's attention now
+ (`organization_issues.py`): its kind, the workspace it is in (None for
+ the organization's own), and the agents it names, if any."""
+
+ kind: IssueKind
+ workspace_id: str | None
+ workspace_name: str | None
+ agents: list[str]
+
+
class OrganizationAuditEventDetail(BaseModel):
"""An organization audit event, with the people it names resolved to
names: an actor or a target removed since, or never a member (the platform
diff --git a/core/switch_core/organization_issues.py b/core/switch_core/organization_issues.py
new file mode 100644
index 000000000..a5c1b4a9d
--- /dev/null
+++ b/core/switch_core/organization_issues.py
@@ -0,0 +1,156 @@
+"""What needs an organization admin's attention, read from how things stand.
+
+Changes brought in from a directory kept outside Switch are applied even
+when they break a rule Switch keeps (`organization_mirror.py`), and each is
+recorded as a `directory_conflict` in the organization's audit log. The audit
+log says what happened; this says what is still wrong, so a notice goes away
+once someone fixes it rather than once someone dismisses it:
+
+- `no_org_admin`: nobody administers the organization (only the platform
+ operator, who may make someone its admin, can then read this).
+- `workspace_without_owner`: a workspace with no `owner`.
+- `agents_without_acting_owner`: agents whose owner is neither a member of
+ their workspace nor the organization's `org_admin`, so nobody can act for
+ them as their owner.
+- `directory_organization_deleted`: the WorkOS organization this one follows
+ was deleted after it was linked.
+"""
+
+from __future__ import annotations
+
+from dataclasses import dataclass
+from typing import Literal
+
+from sqlalchemy import and_, or_, select, true
+from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
+
+from switch_core.authz import ORGANIZATION_ADMIN_ROLE
+from switch_core.db.audit import OrganizationAuditAction
+from switch_core.db.models import (
+ Agent,
+ Organization,
+ OrganizationAuditEvent,
+ OrganizationMember,
+ TenantMember,
+)
+from switch_core.db.session_scope import tenant_session
+from switch_core.db.stores.user_store import UserStore
+
+IssueKind = Literal[
+ "no_org_admin",
+ "workspace_without_owner",
+ "agents_without_acting_owner",
+ "directory_organization_deleted",
+]
+NO_ORG_ADMIN: IssueKind = "no_org_admin"
+WORKSPACE_WITHOUT_OWNER: IssueKind = "workspace_without_owner"
+AGENTS_WITHOUT_ACTING_OWNER: IssueKind = "agents_without_acting_owner"
+DIRECTORY_ORGANIZATION_DELETED: IssueKind = "directory_organization_deleted"
+
+
+@dataclass(frozen=True)
+class OrganizationIssue:
+ """One issue: its kind, the workspace it is in (None for the
+ organization's own), and the agents it names, if any."""
+
+ kind: IssueKind
+ workspace_id: str | None
+ workspace_name: str | None
+ agents: list[str]
+
+
+async def organization_issues(
+ session: AsyncSession,
+ session_factory: async_sessionmaker[AsyncSession],
+ user_store: UserStore,
+ *,
+ organization_id: str,
+ workspaces: list[tuple[str, str]],
+) -> list[OrganizationIssue]:
+ """The issues of `organization_id` as things stand. `session` is bound
+ to one of its workspaces, for the organization's own rows; each of
+ `workspaces`, its workspaces as (id, name), is read on a short session of its own,
+ after `session` has let go of its connection."""
+ admins = set(
+ await session.scalars(
+ select(OrganizationMember.user_id).where(
+ OrganizationMember.organization_id == organization_id,
+ OrganizationMember.role == ORGANIZATION_ADMIN_ROLE,
+ )
+ )
+ )
+ issues = []
+ if not admins:
+ issues.append(OrganizationIssue(NO_ORG_ADMIN, None, None, []))
+ if await _directory_organization_deleted(session, organization_id):
+ issues.append(OrganizationIssue(DIRECTORY_ORGANIZATION_DELETED, None, None, []))
+ await session.commit()
+
+ for workspace_id, workspace_name in sorted(workspaces, key=lambda w: w[1]):
+ async with tenant_session(session_factory, workspace_id) as tenant:
+ if await user_store.count_owners(tenant) == 0:
+ issues.append(
+ OrganizationIssue(
+ WORKSPACE_WITHOUT_OWNER, workspace_id, workspace_name, []
+ )
+ )
+ stranded = list(
+ await tenant.scalars(
+ select(Agent.name)
+ .where(
+ Agent.tenant_id == workspace_id,
+ Agent.owner_id.is_not(None),
+ Agent.owner_id.not_in(admins) if admins else true(),
+ ~select(TenantMember.user_id)
+ .where(
+ TenantMember.tenant_id == workspace_id,
+ TenantMember.user_id == Agent.owner_id,
+ )
+ .exists(),
+ )
+ .order_by(Agent.name)
+ )
+ )
+ if stranded:
+ issues.append(
+ OrganizationIssue(
+ AGENTS_WITHOUT_ACTING_OWNER, workspace_id, workspace_name, stranded
+ )
+ )
+ return issues
+
+
+async def _directory_organization_deleted(
+ session: AsyncSession, organization_id: str
+) -> bool:
+ """Whether the organization is linked and the WorkOS organization it
+ follows was reported deleted after the link was last made."""
+ linked = await session.scalar(
+ select(Organization.workos_organization_id).where(
+ Organization.id == organization_id
+ )
+ )
+ if linked is None:
+ return False
+ latest = await session.scalar(
+ select(OrganizationAuditEvent.action)
+ .where(
+ OrganizationAuditEvent.organization_id == organization_id,
+ or_(
+ OrganizationAuditEvent.action
+ == OrganizationAuditAction.LINKED_TO_DIRECTORY,
+ and_(
+ OrganizationAuditEvent.action
+ == OrganizationAuditAction.DIRECTORY_CONFLICT,
+ OrganizationAuditEvent.details["kind"].astext
+ == DIRECTORY_ORGANIZATION_DELETED,
+ ),
+ ),
+ )
+ .order_by(
+ OrganizationAuditEvent.occurred_at.desc(),
+ OrganizationAuditEvent.id.desc(),
+ )
+ .limit(1)
+ )
+ return latest == OrganizationAuditAction.DIRECTORY_CONFLICT
diff --git a/core/switch_core/workos_mirror.py b/core/switch_core/workos_mirror.py
index af4010383..e79921bd6 100644
--- a/core/switch_core/workos_mirror.py
+++ b/core/switch_core/workos_mirror.py
@@ -66,6 +66,7 @@ from switch_core.db.models import (
from switch_core.db.session_scope import organization_session
from switch_core.db.stores.ownership_lease_store import OwnershipLeaseStore
from switch_core.db.tenant_lookup import directory_organizations
+from switch_core.organization_issues import DIRECTORY_ORGANIZATION_DELETED
from switch_core.organization_mirror import MirrorDependencies, apply_from_directory
from switch_core.ownership import Fence, OwnedKind, Ownership
from switch_core.tenant_context import no_tenant
@@ -369,7 +370,7 @@ class WorkOSMirror:
target_id=organization_id,
details={
"source": FROM_EVENT,
- "kind": "directory_organization_deleted",
+ "kind": DIRECTORY_ORGANIZATION_DELETED,
},
)
await session.commit()
diff --git a/core/tests/switch_core/gateway/test_organization_routes.py b/core/tests/switch_core/gateway/test_organization_routes.py
index 9bda047cc..e232fd6e4 100644
--- a/core/tests/switch_core/gateway/test_organization_routes.py
+++ b/core/tests/switch_core/gateway/test_organization_routes.py
@@ -1300,3 +1300,165 @@ class TestLosingOrgAdmin:
assert first == 200 and second in (403, 409)
async with session_factory() as session:
assert await OrganizationStore().count_admins(session, organization_id) == 1
+
+
+async def _organization_of(
+ session_factory: async_sessionmaker[AsyncSession], tenant_id: str
+) -> str:
+ async with tenant_session(session_factory, tenant_id) as session:
+ tenant = await session.get(Tenant, tenant_id)
+ assert tenant is not None and tenant.organization_id is not None
+ return tenant.organization_id
+
+
+class TestIssues:
+ """What needs an organization admin's attention, read from how things
+ stand: an issue is gone once fixed."""
+
+ async def test_a_healthy_organization_has_none(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ ada = _name("ada")
+ tenant_id = await _workspace(session_factory, {ada: ("owner", "org_admin")})
+
+ async with _client(_app(session_factory), ada, tenant_id) as client:
+ response = await client.get("/organizations/current/issues")
+
+ assert response.status_code == 200, response.text
+ assert response.json() == []
+
+ async def test_a_workspace_without_an_owner_until_one_is_made(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ ada, bob = _name("ada"), _name("bob")
+ tenant_id = await _workspace(
+ session_factory, {ada: ("admin", "org_admin"), bob: ("member", "member")}
+ )
+
+ async with _client(_app(session_factory), ada, tenant_id) as client:
+ before = await client.get("/organizations/current/issues")
+ async with tenant_session(session_factory, tenant_id) as session:
+ member = await session.get(TenantMember, (tenant_id, bob))
+ assert member is not None
+ member.role = "owner"
+ await session.commit()
+ after = await client.get("/organizations/current/issues")
+
+ assert before.json() == [
+ {
+ "kind": "workspace_without_owner",
+ "workspace_id": tenant_id,
+ "workspace_name": "Acme",
+ "agents": [],
+ }
+ ]
+ assert after.json() == []
+
+ async def test_agents_whose_owner_can_no_longer_act_for_them(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ """Bob left the workspace and the organization; his agent stayed.
+ Ada's own agent, held as the organization's admin with no membership
+ row, is no issue."""
+ ada, bob = _name("ada"), _name("bob")
+ tenant_id = await _workspace(
+ session_factory, {ada: ("owner", "org_admin"), bob: ("member", "member")}
+ )
+ await _agent(session_factory, tenant_id, bob)
+ await _agent(session_factory, tenant_id, ada)
+ organization_id = await _organization_of(session_factory, tenant_id)
+ async with tenant_session(session_factory, tenant_id) as session:
+ await session.delete(await session.get(TenantMember, (tenant_id, bob)))
+ await session.delete(await session.get(TenantMember, (tenant_id, ada)))
+ await session.delete(
+ await session.get(OrganizationMember, (organization_id, bob))
+ )
+ await session.commit()
+
+ async with _client(_app(session_factory), ada, tenant_id) as client:
+ response = await client.get("/organizations/current/issues")
+
+ [stranded] = [
+ issue
+ for issue in response.json()
+ if issue["kind"] == "agents_without_acting_owner"
+ ]
+ assert stranded["workspace_id"] == tenant_id
+ assert len(stranded["agents"]) == 1
+
+ async def test_a_deleted_workos_organization_until_it_is_linked_again(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ ada = _name("ada")
+ tenant_id = await _workspace(session_factory, {ada: ("owner", "org_admin")})
+ organization_id = await _organization_of(session_factory, tenant_id)
+ async with session_factory() as session:
+ organization = await session.get(Organization, organization_id)
+ assert organization is not None
+ organization.workos_organization_id = _name("org_workos")
+ for action, details in (
+ (OrganizationAuditAction.LINKED_TO_DIRECTORY, {}),
+ (
+ OrganizationAuditAction.DIRECTORY_CONFLICT,
+ {"kind": "directory_organization_deleted"},
+ ),
+ ):
+ session.add(
+ OrganizationAuditEvent(
+ organization_id=organization_id,
+ actor_user_id=None,
+ action=action,
+ target_type="organization",
+ target_id=organization_id,
+ details=details,
+ )
+ )
+ await session.commit()
+
+ app = _app(session_factory)
+ async with _client(app, ada, tenant_id) as client:
+ deleted = await client.get("/organizations/current/issues")
+ async with session_factory() as session:
+ session.add(
+ OrganizationAuditEvent(
+ organization_id=organization_id,
+ actor_user_id=None,
+ action=OrganizationAuditAction.LINKED_TO_DIRECTORY,
+ target_type="organization",
+ target_id=organization_id,
+ details={},
+ )
+ )
+ await session.commit()
+ relinked = await client.get("/organizations/current/issues")
+
+ assert [issue["kind"] for issue in deleted.json()] == [
+ "directory_organization_deleted"
+ ]
+ assert relinked.json() == []
+
+ async def test_with_no_org_admin_the_operator_is_told(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ bob = _name("bob")
+ tenant_id = await _workspace(session_factory, {bob: ("owner", "member")})
+ operator_id = await _operator(session_factory)
+
+ async with _client(_app(session_factory), operator_id, tenant_id) as client:
+ response = await client.get("/organizations/current/issues")
+
+ assert response.status_code == 200, response.text
+ assert [issue["kind"] for issue in response.json()] == ["no_org_admin"]
+
+ async def test_a_member_is_refused(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ ada, bob = _name("ada"), _name("bob")
+ tenant_id = await _workspace(
+ session_factory, {ada: ("owner", "org_admin"), bob: ("member", "member")}
+ )
+
+ async with _client(_app(session_factory), bob, tenant_id) as client:
+ response = await client.get("/organizations/current/issues")
+
+ assert response.status_code == 403
diff --git a/docs/old/workos-directory.md b/docs/old/workos-directory.md
index 626d1c503..9ea63cc9a 100644
--- a/docs/old/workos-directory.md
+++ b/docs/old/workos-directory.md
@@ -104,6 +104,12 @@ first do. A member with no WorkOS identity (an account nobody linked) can't be
compared, and is logged and left. Deleting a linked organization in WorkOS
removes nobody: it is logged and recorded for an operator to deal with.
+The organization's admins see what is still wrong at the top of its
+Organization page, until it is fixed: no admin (shown to the platform
+operator, who may then make one), a workspace with no owner, agents whose
+owner can no longer act for them, and a linked WorkOS organization that was
+deleted. The audit log keeps the history.
+
## Not done yet
- **Granting from Switch is refused** for a linked organization: adding a
@@ -111,6 +117,4 @@ removes nobody: it is logged and recorded for an operator to deal with.
those changes in WorkOS. Removing a member or taking Org Admin away from
Switch is allowed and changes only Switch; whatever WorkOS still grants
comes back at the next sign-in or check.
-- The organization's admins see conflicts only in its audit log, not yet as a
- notice on the dashboard.
- A new organization created on the server is Switch's own until it is linked.
diff --git a/gateway/src/data/api.ts b/gateway/src/data/api.ts
index 1f703a233..5ca81736f 100644
--- a/gateway/src/data/api.ts
+++ b/gateway/src/data/api.ts
@@ -1362,6 +1362,27 @@ export async function removeOrganizationMember(
);
}
+export type OrganizationIssueKind =
+ | "no_org_admin"
+ | "workspace_without_owner"
+ | "agents_without_acting_owner"
+ | "directory_organization_deleted";
+
+/** Something in the organization that needs an admin's attention now. Read
+ * from how things stand, so it is gone once fixed. */
+export interface OrganizationIssue {
+ kind: OrganizationIssueKind;
+ // Null for an issue of the organization's own.
+ workspace_id: string | null;
+ workspace_name: string | null;
+ agents: string[];
+}
+
+/** Its admins only, and the platform operator while it has none. */
+export async function fetchOrganizationIssues(): Promise<OrganizationIssue[]> {
+ return jsonRequest<OrganizationIssue[]>("/organizations/current/issues", "GET");
+}
+
export const ORGANIZATION_AUDIT_PAGE = 50;
/** One page of the organization's audit log, newest first: the most recent
diff --git a/gateway/src/pages/organization/OrganizationIssuesNotice.tsx b/gateway/src/pages/organization/OrganizationIssuesNotice.tsx
new file mode 100644
index 000000000..5c47c01c0
--- /dev/null
+++ b/gateway/src/pages/organization/OrganizationIssuesNotice.tsx
@@ -0,0 +1,50 @@
+import { Alert, AlertTitle, Box } from "@mui/material";
+import { useCallback } from "react";
+import { type OrganizationIssue, fetchOrganizationIssues } from "../../data/api";
+import { useLoad } from "../workspace/useLoad";
+
+function describe(issue: OrganizationIssue): string {
+ const workspace = issue.workspace_name ?? "";
+ switch (issue.kind) {
+ case "no_org_admin":
+ return "Nobody is an admin of this organization. Make one of its members an organization admin below.";
+ case "workspace_without_owner":
+ return `${workspace} has no owner. Make one of its members owner in that workspace's members.`;
+ case "agents_without_acting_owner":
+ return (
+ `In ${workspace}, these agents are owned by someone who is no longer in the ` +
+ `workspace, so nobody can act for them as their owner: ${issue.agents.join(", ")}. ` +
+ "Delete them from that workspace's agents if they are no longer needed."
+ );
+ case "directory_organization_deleted":
+ return (
+ "The WorkOS organization this organization follows was deleted. Its members are " +
+ "left as they were; ask whoever runs your Switch server to link it again or remove it."
+ );
+ }
+}
+
+/** What needs an organization admin's attention, shown until it is fixed.
+ * Nothing at all when there is nothing, or when the caller is not one the
+ * server answers (the platform operator while the organization has admins). */
+export default function OrganizationIssuesNotice() {
+ const load = useCallback(() => fetchOrganizationIssues(), []);
+ const { data: issues, error, errorStatus } = useLoad(load);
+ if (errorStatus === 403) return null;
+ if (error) {
+ return <Alert severity="error">Could not check this organization for problems: {error}</Alert>;
+ }
+ if (!issues || issues.length === 0) return null;
+ return (
+ <Alert severity="warning">
+ <AlertTitle>
+ {issues.length === 1 ? "One thing needs your attention" : `${issues.length} things need your attention`}
+ </AlertTitle>
+ <Box component="ul" sx={{ m: 0, pl: 2 }}>
+ {issues.map((issue) => (
+ <li key={`${issue.kind}:${issue.workspace_id ?? ""}`}>{describe(issue)}</li>
+ ))}
+ </Box>
+ </Alert>
+ );
+}
diff --git a/gateway/src/pages/organization/OrganizationPage.test.tsx b/gateway/src/pages/organization/OrganizationPage.test.tsx
index 5395b7162..154d8606b 100644
--- a/gateway/src/pages/organization/OrganizationPage.test.tsx
+++ b/gateway/src/pages/organization/OrganizationPage.test.tsx
@@ -107,6 +107,7 @@ describe("OrganizationPage", () => {
details: { from: "member", to: "org_admin", platform_access: true },
},
],
+ "GET /organizations/current/issues": [],
});
render(<OrganizationPage />);
@@ -241,6 +242,7 @@ describe("OrganizationPage", () => {
"GET /organizations/current/workspaces": [workspace("t1", "Acme")],
"GET /organizations/current/members": [bob],
"GET /organizations/current/audit-events": [],
+ "GET /organizations/current/issues": [],
"PATCH /organizations/current/members/u2": {
...bob,
role: "member",
@@ -279,6 +281,7 @@ describe("OrganizationPage", () => {
"GET /organizations/current/workspaces": [workspace("t1", "Acme")],
"GET /organizations/current/members": [],
"GET /organizations/current/audit-events": [],
+ "GET /organizations/current/issues": [],
"POST /organizations/current/workspaces": workspace("t2", "Research"),
};
const fetchMock = answer(routes);
@@ -306,6 +309,7 @@ describe("OrganizationPage", () => {
"GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: null },
"GET /organizations/current/workspaces": [workspace("t1", "Acme")],
"GET /organizations/current/members": membersAnswer,
+ "GET /organizations/current/issues": new Refusal(403, "Only an organization admin may do this"),
});
it("lets the operator make an admin where there is none, and nothing more", async () => {
@@ -340,4 +344,60 @@ describe("OrganizationPage", () => {
expect(await screen.findByText("The database is unavailable")).toBeTruthy();
expect(screen.queryByText(/only while it has no admin/)).toBeNull();
});
+
+ it("tells an organization admin what needs their attention", async () => {
+ signedInAs(session("org_admin", true));
+ answer({
+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },
+ "GET /organizations/current/workspaces": [workspace("t1", "Acme")],
+ "GET /organizations/current/members": [],
+ "GET /organizations/current/audit-events": [],
+ "GET /organizations/current/issues": [
+ { kind: "workspace_without_owner", workspace_id: "t1", workspace_name: "Acme", agents: [] },
+ {
+ kind: "agents_without_acting_owner",
+ workspace_id: "t1",
+ workspace_name: "Acme",
+ agents: ["reviewer", "triage"],
+ },
+ ],
+ });
+
+ render(<OrganizationPage />);
+
+ expect(await screen.findByText("2 things need your attention")).toBeTruthy();
+ expect(screen.getByText(/Acme has no owner/)).toBeTruthy();
+ expect(screen.getByText(/reviewer, triage/)).toBeTruthy();
+ });
+
+ it("says nothing when nothing needs attention", async () => {
+ signedInAs(session("org_admin", true));
+ answer({
+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },
+ "GET /organizations/current/workspaces": [workspace("t1", "Acme")],
+ "GET /organizations/current/members": [],
+ "GET /organizations/current/audit-events": [],
+ "GET /organizations/current/issues": [],
+ });
+
+ render(<OrganizationPage />);
+
+ expect(await screen.findByText("Acme (current)")).toBeTruthy();
+ expect(screen.queryByText(/need(s)? your attention/)).toBeNull();
+ });
+
+ it("shows a failure to check as a failure", async () => {
+ signedInAs(session("org_admin", true));
+ answer({
+ "GET /organizations/current": { id: "o1", slug: "acme", name: "Acme Inc", role: "org_admin" },
+ "GET /organizations/current/workspaces": [workspace("t1", "Acme")],
+ "GET /organizations/current/members": [],
+ "GET /organizations/current/audit-events": [],
+ "GET /organizations/current/issues": new Refusal(500, "The database is unavailable"),
+ });
+
+ render(<OrganizationPage />);
+
+ expect(await screen.findByText(/Could not check this organization for problems/)).toBeTruthy();
+ });
});
diff --git a/gateway/src/pages/organization/OrganizationPage.tsx b/gateway/src/pages/organization/OrganizationPage.tsx
index 3f7f4b6d3..2c7745c16 100644
--- a/gateway/src/pages/organization/OrganizationPage.tsx
+++ b/gateway/src/pages/organization/OrganizationPage.tsx
@@ -7,6 +7,7 @@ import { useLoad } from "../workspace/useLoad";
import OrganizationAuditSection from "./OrganizationAuditSection";
import OrganizationConnectorsSection from "./OrganizationConnectorsSection";
import OrganizationServicesSection from "./OrganizationServicesSection";
+import OrganizationIssuesNotice from "./OrganizationIssuesNotice";
import OrganizationMembersSection from "./OrganizationMembersSection";
import WorkspacesSection from "./WorkspacesSection";
@@ -40,6 +41,7 @@ export default function OrganizationPage() {
</Stack>
{error && <Alert severity="error">{error}</Alert>}
<Stack spacing={4}>
+ {(isAdmin || session.user.is_operator) && <OrganizationIssuesNotice />}
<WorkspacesSection currentId={tenant.id} canAdd={session.can_add_workspace} />
{(isAdmin || session.user.is_operator) && (
<OrganizationMembersSection selfId={session.user.id} asOperator={!isAdmin} />