Skip to content

Commit c5c6a79

Browse files
committed
improvement(org): one section rule and an organization-owned error policy
1 parent facda8f commit c5c6a79

4 files changed

Lines changed: 27 additions & 21 deletions

File tree

‎apps/sim/app/api/organizations/[id]/home/workspace-activity/route.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import { getOrganizationHomeWorkspaceActivityContract } from '@/lib/api/contracts/organization-home'
22
import {
3+
createInternalResourceConcealmentPolicy,
34
defineInternalJsonRoute,
5+
internalErrorResponse,
6+
internalOrchestrationErrorPolicy,
47
internalRateLimits,
58
internalSessionAuth,
69
} from '@/lib/api/server/routes'
710
import {
811
organizationHomeWorkspaceOperations,
912
readOrganizationHomeWorkspaceActivity,
1013
} from '@/lib/organizations/application/home-workspaces'
11-
import { createCredentialGroupInternalErrorPolicy } from '@/app/api/workspaces/[id]/credential-groups/error-policy'
1214

1315
export const GET = defineInternalJsonRoute({
1416
contract: getOrganizationHomeWorkspaceActivityContract,
1517
auth: internalSessionAuth,
1618
operation: organizationHomeWorkspaceOperations.readActivity,
1719
rateLimit: internalRateLimits.user({ bucketName: 'organization-home-workspace-activity' }),
18-
errorPolicy: createCredentialGroupInternalErrorPolicy(
19-
'Failed to load workspace activity',
20-
'Organization not found'
21-
),
20+
errorPolicy: createInternalResourceConcealmentPolicy({
21+
base: {
22+
project: internalOrchestrationErrorPolicy.project,
23+
unhandled: () => internalErrorResponse(500, { error: 'Failed to load workspace activity' }),
24+
},
25+
notFoundMessage: 'Organization not found',
26+
}),
2227
mapInput: ({ params }) => ({ organizationId: params.id }),
2328
useCase: readOrganizationHomeWorkspaceActivity,
2429
staticResponseHeaders: { 'Cache-Control': 'private, no-store' },

‎apps/sim/lib/organizations/home/workspace-activity.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export function readRunningWorkflows(
5353

5454
/**
5555
* Per workspace, one workflow waiting on a person and the newest retained run. Each is a `LIMIT 1`
56-
* probe, so a workspace with thousands of unanswered pauses costs what one does. The waiting workflow
57-
* is therefore any of them rather than the newest, since finding the newest would read them all.
56+
* probe, so many unanswered pauses cost what one does once a match exists. The waiting workflow is
57+
* therefore any of them rather than the newest. With no match, the probe reads every live pause.
5858
*/
5959
export function readReviewAndLastRun(workspaceIds: readonly string[]) {
6060
const logs = workflowExecutionLogs

‎apps/sim/lib/organizations/settings-sections.ts‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ import {
22
ACCOUNT_SETTINGS_ITEMS,
33
type AccountSettingsSection,
44
getSettingsSectionMeta,
5-
isOrganizationSettingsSectionAvailable,
65
ORGANIZATION_SETTINGS_GROUPS,
76
ORGANIZATION_SETTINGS_ITEMS,
87
type OrganizationSettingsFeatures,
98
type OrganizationSettingsSection,
109
parseSettingsPathSection,
11-
resolveOrganizationSectionAccess,
1210
type SettingsNavigationItem,
1311
toSettingsHeaderMeta,
1412
} from '@/components/settings/navigation'
1513
import type { SettingsHeaderMeta } from '@/components/settings/settings-header'
14+
import { organizationSupportsSettingsSection } from '@/lib/settings/section-availability'
1615

1716
/**
1817
* A section on the organization surface's settings, tagged with the plane that
@@ -84,18 +83,8 @@ export function organizationSettingsNavigation(
8483
features: OrganizationSettingsFeatures,
8584
availability: { connectedAccounts: boolean; search: boolean; knowledgeGraphs?: boolean }
8685
) {
87-
return ORGANIZATION_SETTINGS_ITEMS.filter(
88-
(item) =>
89-
(item.id !== 'knowledge-graphs' || availability.knowledgeGraphs === true) &&
90-
(item.id !== 'connected-accounts' || availability.connectedAccounts) &&
91-
((item.id !== 'search-mcp' && item.id !== 'search-slack' && item.id !== 'integrations') ||
92-
availability.search) &&
93-
resolveOrganizationSectionAccess({
94-
section: item.id,
95-
isTargetOrganizationMember: true,
96-
isTargetOrganizationAdmin: isAdmin,
97-
}) !== 'unavailable' &&
98-
isOrganizationSettingsSectionAvailable(item.id, features)
86+
return ORGANIZATION_SETTINGS_ITEMS.filter((item) =>
87+
organizationSupportsSettingsSection(item.id, features, availability, isAdmin)
9988
)
10089
}
10190

‎apps/sim/platform/checks/live/zone.spec.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ for (const [from, to] of REDIRECTS) {
3333
})
3434
}
3535

36+
test('the component workbench is not served by a live zone', async ({ page }) => {
37+
const response = await page.goto('/org/workbench?recipe=C1084')
38+
expect(response?.status()).toBe(404)
39+
})
40+
41+
test('a Slack handoff link stays on the legacy integrations page', async ({ page }) => {
42+
await signInAsAdmin(page, '/org/home')
43+
const target = legacy('/integrations?slack=not-a-token')
44+
await page.goto(target)
45+
await expect(page).not.toHaveURL(/\/org\//)
46+
})
47+
3648
test('a route with no Platform counterpart stays legacy', async ({ page }) => {
3749
await signInAsAdmin(page, legacy(UNMAPPED))
3850
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(legacy(UNMAPPED))}$`))

0 commit comments

Comments
 (0)