@jsb188/mday-web 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,10 @@
1
1
  import type { ServerErrorObj } from '@jsb188/app/types/app.d.ts';
2
- import {
3
- ContentGate,
4
- ErrorMessage,
5
- ErrorMessageContainer,
6
- } from '@jsb188/react-web/modules/layout/MainLayout';
2
+ import { ContentGate, ErrorMessage, ErrorMessageContainer } from '@jsb188/react-web/modules/layout/MainLayout';
7
3
  import { memo, type Dispatch, type SetStateAction } from 'react';
8
4
 
9
5
  interface AppRouteShellProps {
10
- layoutOpen: boolean;
11
- setLayoutOpen: Dispatch<SetStateAction<boolean>>;
6
+ layoutOpen?: boolean;
7
+ setLayoutOpen?: Dispatch<SetStateAction<boolean>>;
12
8
  }
13
9
 
14
10
  interface AppRouteErrorMessageProps extends AppRouteShellProps {
@@ -25,17 +21,7 @@ interface AppRouteErrorMessageProps extends AppRouteShellProps {
25
21
  * Render a reusable route error inside the app shell layout.
26
22
  */
27
23
  export const AppRouteErrorMessage = memo((p: AppRouteErrorMessageProps) => {
28
- const {
29
- buttonColorClassName,
30
- buttonHref,
31
- buttonText,
32
- error,
33
- iconName,
34
- layoutOpen,
35
- message,
36
- setLayoutOpen,
37
- title,
38
- } = p;
24
+ const { buttonColorClassName, buttonHref, buttonText, error, iconName, layoutOpen, message, setLayoutOpen, title } = p;
39
25
 
40
26
  return (
41
27
  <ErrorMessageContainer
@@ -68,7 +54,11 @@ export const AppRouteLoading = memo((p: AppRouteShellProps) => {
68
54
  layoutOpen={layoutOpen}
69
55
  setLayoutOpen={setLayoutOpen}
70
56
  >
71
- <ContentGate loading notReady showLoadingIfNotReady />
57
+ <ContentGate
58
+ loading
59
+ notReady
60
+ showLoadingIfNotReady
61
+ />
72
62
  </ErrorMessageContainer>
73
63
  );
74
64
  });
@@ -4,7 +4,11 @@ import { makeAddressSchema } from '@jsb188/auth-web/schemas/address';
4
4
  import { defineForm } from '@jsb188/form/libs/defineForm';
5
5
  import { z } from 'zod';
6
6
  import type { OrganizationGQL, OrganizationSettingsObj } from '@jsb188/mday/types/organization.d.ts';
7
- import { getOrganizationDisplayTranslatedLogsSetting, getOrganizationLogLanguageSetting } from '@jsb188/mday/utils/organization.ts';
7
+ import {
8
+ getOrganizationAllowMcpConnectionsSetting,
9
+ getOrganizationDisplayTranslatedLogsSetting,
10
+ getOrganizationLogLanguageSetting,
11
+ } from '@jsb188/mday/utils/organization.ts';
8
12
 
9
13
  /* Keep the existing organization settings popovers consistent across selectors. */
10
14
  function settingsPopover(name: string, options: object[], designClassName?: string, className?: string) {
@@ -21,10 +25,10 @@ function settingsPopover(name: string, options: object[], designClassName?: stri
21
25
  };
22
26
  }
23
27
 
24
- /* Define organization information, language preferences, and address in display order. */
28
+ /* Define organization information, language preferences, AI app connections, and address in display order. */
25
29
  export function makeEditOrganizationSchema(
26
30
  organization: OrganizationGQL,
27
- settings: Pick<OrganizationSettingsObj, 'displayTranslatedLogs' | 'translateLanguage'>,
31
+ settings: Pick<OrganizationSettingsObj, 'displayTranslatedLogs' | 'translateLanguage' | 'allowMcpConnections'>,
28
32
  ) {
29
33
  const address = makeAddressSchema(organization.address);
30
34
  const disabledLanguageText = i18n.t('org.translate_language_disabled');
@@ -35,6 +39,7 @@ export function makeEditOrganizationSchema(
35
39
  operation: z.string(),
36
40
  translateLanguage: z.string().nullable(),
37
41
  displayTranslatedLogs: z.boolean(),
42
+ allowMcpConnections: z.boolean(),
38
43
  }),
39
44
  defaults: {
40
45
  ...address.defaults,
@@ -42,6 +47,7 @@ export function makeEditOrganizationSchema(
42
47
  operation: organization.operation,
43
48
  translateLanguage: getOrganizationLogLanguageSetting(settings, 'translateLanguage'),
44
49
  displayTranslatedLogs: getOrganizationDisplayTranslatedLogsSetting(settings),
50
+ allowMcpConnections: getOrganizationAllowMcpConnectionsSetting(settings),
45
51
  },
46
52
  fields: {
47
53
  name: {
@@ -112,6 +118,24 @@ export function makeEditOrganizationSchema(
112
118
  ),
113
119
  }),
114
120
  },
121
+ allowMcpConnections: {
122
+ kind: 'click',
123
+ label: i18n.t('org.allow_mcp_connections'),
124
+ info: i18n.t('org.allow_mcp_connections_description'),
125
+ getter: (value: boolean) => i18n.t(value === false ? 'c.no' : 'c.yes'),
126
+ resolve: ({ values }) => ({
127
+ popOverProps: settingsPopover(
128
+ 'allowMcpConnections',
129
+ [true, false].map((value) => ({
130
+ __type: 'LIST_ITEM',
131
+ text: i18n.t(value ? 'c.yes' : 'c.no'),
132
+ name: 'allowMcpConnections',
133
+ value,
134
+ selected: values.allowMcpConnections === value,
135
+ })),
136
+ ),
137
+ }),
138
+ },
115
139
  ...address.fields,
116
140
  },
117
141
  layout: [
@@ -121,6 +145,8 @@ export function makeEditOrganizationSchema(
121
145
  { kind: 'section', id: 'language', title: i18n.t('account.language') },
122
146
  'translateLanguage',
123
147
  'displayTranslatedLogs',
148
+ { kind: 'section', id: 'integrations', title: i18n.t('app.integrations') },
149
+ 'allowMcpConnections',
124
150
  { kind: 'section', id: 'address', title: i18n.t('c.address'), description: i18n.t('org.address_notice_msg') },
125
151
  ...(address.layout || []),
126
152
  ],
@@ -1,7 +1,7 @@
1
1
  import i18n from '@jsb188/app/i18n/index.ts';
2
2
  import { getFullDate, getFullDateTime } from '@jsb188/app/utils/datetime.ts';
3
3
  import { ucFirst } from '@jsb188/app/utils/string.ts';
4
- import type { EmailMessageGQL, EmailMessageStatusEnum } from '@jsb188/mday/types/email.d.ts';
4
+ import type { EmailMessageHeadingFields, EmailMessageStatusEnum } from '@jsb188/mday/types/email.d.ts';
5
5
 
6
6
  /*
7
7
  * Describe one email event with its recorded local time and a capitalized sentence.
@@ -56,9 +56,9 @@ export function getOutboundEmailHeading(
56
56
  }
57
57
 
58
58
  /*
59
- * Describe outbound delivery or inbound AI processing using the appropriate person and event time.
59
+ * Show the inbound status summary when available, with an event heading as the fallback.
60
60
  */
61
- export function getEmailMessageHeading(email: EmailMessageGQL, timeZone: string | null): string {
61
+ export function getEmailMessageHeading(email: EmailMessageHeadingFields, timeZone: string | null): string {
62
62
  if (email.direction === 'OUTBOUND') {
63
63
  return getOutboundEmailHeading(
64
64
  {
@@ -73,6 +73,9 @@ export function getEmailMessageHeading(email: EmailMessageGQL, timeZone: string
73
73
  timeZone,
74
74
  );
75
75
  }
76
+ const summary = email.statusSummary?.trim();
77
+ if (summary) return summary;
78
+
76
79
  const name = email.fromName?.trim() || email.fromEmail || i18n.t('c.unknown');
77
80
  switch (email.status) {
78
81
  case 'RECEIVED':
@@ -82,7 +85,7 @@ export function getEmailMessageHeading(email: EmailMessageGQL, timeZone: string
82
85
  case 'PROCESSING':
83
86
  return getEmailEventHeading('inbound_processing', name, timeZone, email.processingStartedAt);
84
87
  case 'COMPLETED':
85
- return getEmailEventHeading('inbound_completed', name, timeZone, email.processingCompletedAt);
88
+ return getEmailEventHeading('inbound_completed', name, timeZone, email.occurredAt);
86
89
  case 'ERRORED':
87
90
  return getEmailEventHeading('inbound_failed', name, timeZone, email.processingCompletedAt);
88
91
  case 'IGNORED':
@@ -109,7 +112,9 @@ export function getOutboundEmailSuppressionReasonText(reason: string | null | un
109
112
  return i18n.t('campaign.email_suppression_manual');
110
113
  case 'AUDIENCE_INELIGIBLE':
111
114
  return i18n.t('campaign.email_suppression_audience_ineligible');
112
- case 'CAMPAIGN_UNAVAILABLE':
115
+ case 'ALREADY_REPLIED':
116
+ return i18n.t('campaign.email_suppression_already_replied');
117
+ case 'EMAIL_OUTREACH_UNAVAILABLE':
113
118
  return i18n.t('campaign.email_suppression_campaign_unavailable');
114
119
  default:
115
120
  return i18n.t('campaign.email_suppression_unknown');
@@ -0,0 +1,110 @@
1
+ import type { LinkedEntityType } from '@jsb188/mday/constants/linkedEntity.ts';
2
+ import type { LinkedEntityRef, LinkedEntitySummary } from '@jsb188/mday/types/linkedEntity.d.ts';
3
+ import type { LogTaxonomyGQL } from '@jsb188/mday/types/log.d.ts';
4
+ import { serializePageFilters } from '@jsb188/react/libs/page-filters';
5
+ import { COMMON_ICON_NAMES, getFileTypeIconName } from '@jsb188/react-web/svgs/Icon';
6
+ import { makeFieldDocFormPath } from './route-helpers';
7
+
8
+ /*
9
+ * Describe a linked entity's ordinary destination without loading its viewer. A workflow (workflowKind WORKFLOW) opens
10
+ * only its modal; a scheduled task, or a WORKFLOW link whose kind is not known yet, keeps its runs page.
11
+ */
12
+ export function getLinkedEntityDestination(
13
+ ref: LinkedEntityRef & Pick<LinkedEntitySummary, 'fieldDocProgramId' | 'workflowKind' | 'fileName' | 'fileContentType'>,
14
+ ): {
15
+ to?: string;
16
+ iconName: string;
17
+ modalName?: string;
18
+ } {
19
+ const id = encodeURIComponent(ref.entityId);
20
+ switch (ref.entityType) {
21
+ case 'SHEET':
22
+ return {
23
+ to: `/app/s/${id}${ref.sheetTabId ? `?tab=${encodeURIComponent(ref.sheetTabId)}` : ''}`,
24
+ iconName: COMMON_ICON_NAMES.sheet,
25
+ };
26
+ case 'DATA_TABLE':
27
+ return { to: `/app/d/${id}`, iconName: COMMON_ICON_NAMES.data_table };
28
+ case 'EMAIL_OUTREACH':
29
+ return { to: `/app/oe/${id}`, iconName: COMMON_ICON_NAMES.email_outreach };
30
+ case 'AGENT_NOTE':
31
+ return { iconName: COMMON_ICON_NAMES.description, modalName: 'AGENT_NOTE' };
32
+ case 'WORKFLOW':
33
+ return ref.workflowKind === 'WORKFLOW'
34
+ ? { iconName: COMMON_ICON_NAMES.ai_workflow, modalName: 'WORKFLOW' }
35
+ : { to: `/app/runs/${id}`, iconName: COMMON_ICON_NAMES.ai_workflow, modalName: 'WORKFLOW' };
36
+ case 'WORKFLOW_RUN':
37
+ return { iconName: COMMON_ICON_NAMES.ai_workflow, modalName: 'WORKFLOW_RUN' };
38
+ case 'FIELD_DOC':
39
+ return {
40
+ to: ref.fieldDocProgramId ? makeFieldDocFormPath(ref.fieldDocProgramId, ref.entityId) : undefined,
41
+ iconName: COMMON_ICON_NAMES.field_document,
42
+ };
43
+ case 'FIELD_DOC_SUBMISSION':
44
+ return { to: `/app/p/${id}`, iconName: COMMON_ICON_NAMES.field_document };
45
+ case 'GENERATED_FILE':
46
+ return { to: `/app/downloads?file=${id}`, iconName: 'download', modalName: 'DOWNLOAD_GENERATED_FILE' };
47
+ case 'LIBRARY_FILE':
48
+ return {
49
+ to: `/app/y/${id}`,
50
+ iconName:
51
+ ref.fileName || ref.fileContentType
52
+ ? getFileTypeIconName(ref.fileContentType ?? '', ref.fileName)
53
+ : COMMON_ICON_NAMES.description,
54
+ };
55
+ case 'LOG_ACTIVITY':
56
+ return {
57
+ to: ref.logActivityKey ? makeLinkedLogPath('activities', ref.logActivityKey) : undefined,
58
+ iconName: COMMON_ICON_NAMES.logs,
59
+ };
60
+ case 'LOG_ACTIVITY_GROUP':
61
+ return {
62
+ to: ref.logActivityGroupKey ? makeLinkedLogPath('types', ref.logActivityGroupKey) : undefined,
63
+ iconName: COMMON_ICON_NAMES.logs,
64
+ };
65
+ case 'CHILD_ORG':
66
+ return { iconName: COMMON_ICON_NAMES.team, modalName: 'ORG_PROFILE' };
67
+ }
68
+ }
69
+
70
+ /* Resolve same-origin document links into identities that can open in the chat pane. */
71
+ export function parseLinkedEntityPath(
72
+ href: string,
73
+ origin = typeof window === 'undefined' ? 'https://marketday.local' : window.location.origin,
74
+ ): LinkedEntityRef | null {
75
+ try {
76
+ const url = new URL(href, origin);
77
+ if (url.origin !== origin) return null;
78
+ const match = /^\/app\/(s|d|p|outreach|runs)\/([^/]+)\/?$/.exec(url.pathname);
79
+ if (!match) return null;
80
+ const types: Record<string, LinkedEntityType> = {
81
+ s: 'SHEET',
82
+ d: 'DATA_TABLE',
83
+ p: 'FIELD_DOC_SUBMISSION',
84
+ outreach: 'EMAIL_OUTREACH',
85
+ runs: 'WORKFLOW',
86
+ };
87
+ return {
88
+ entityType: types[match[1]],
89
+ entityId: decodeURIComponent(match[2]),
90
+ ...(match[1] === 's' && url.searchParams.get('tab') ? { sheetTabId: url.searchParams.get('tab') } : {}),
91
+ };
92
+ } catch {
93
+ return null;
94
+ }
95
+ }
96
+
97
+ /* Match existing taxonomy-key links without guessing registry ids or display labels. */
98
+ export function resolveLinkedLogRef(ref: LinkedEntityRef, taxonomy?: LogTaxonomyGQL | null): LinkedEntityRef {
99
+ if (ref.entityType === 'LOG_ACTIVITY' && taxonomy?.activities.some((activity) => activity.key === ref.entityId))
100
+ return { ...ref, logActivityKey: ref.entityId };
101
+ if (ref.entityType === 'LOG_ACTIVITY_GROUP' && taxonomy?.groups.some((group) => group.key === ref.entityId))
102
+ return { ...ref, logActivityGroupKey: ref.entityId };
103
+ return ref;
104
+ }
105
+
106
+ /* Encode one log scope using the same canonical filter grammar as the logs page. */
107
+ function makeLinkedLogPath(field: 'activities' | 'types', key: string): string {
108
+ const filter = serializePageFilters({ filter: { [field]: { type: 'array', items: { type: 'string' } } } }, { [field]: [key] });
109
+ return `/app/logs?${new URLSearchParams({ filter })}`;
110
+ }
@@ -1,11 +1,10 @@
1
1
  // Schedule and projects are not ready.
2
- // import { getScheduleDefaultSurface } from '@jsb188/schedule/utils/defaults.ts';
2
+ // import { SCHEDULING_TYPE_BY_OPERATION } from '@jsb188/mday/constants/logTaxonomy.generated.ts';
3
3
  import i18n from '@jsb188/app/i18n/index.ts';
4
4
  import type { OrganizationOperationEnum, OrganizationSidebarItemObj } from '@jsb188/mday/types/organization.d.ts';
5
5
  import type { OperationName } from '@jsb188/mday/utils/organization.ts';
6
6
  import { definePageFilterSchema, serializePageFilters, stringifyPageSearchParams } from '@jsb188/react/libs/page-filters';
7
7
  import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
8
- import { getOperationPageMetadata, OPERATION_PAGES, type OperationPageSlug } from './operation-pages.ts';
9
8
 
10
9
  // Use this for fieldDoc periods, etc
11
10
  // const CURRENT_YEAR = String(new Date().getFullYear());
@@ -16,7 +15,6 @@ import { getOperationPageMetadata, OPERATION_PAGES, type OperationPageSlug } fro
16
15
 
17
16
  const LOGIN_CHANGED_ERROR_CODES = new Set(['20080', '20081']);
18
17
  const AUTH_RETURN_TO_BASE_URL = 'https://marketday.invalid';
19
- const AUTH_RETURN_TO_PUBLIC_FORM_PATH_PATTERN = /^\/form\/[^/]+$/;
20
18
 
21
19
  /**
22
20
  * Build the translated title and description metadata for a Marketday route.
@@ -40,18 +38,13 @@ export function getMarketdayRouteMeta(titleKey: string, descriptionKey: string)
40
38
  type StaticRoutePath =
41
39
  | '/app'
42
40
  | '/app/c/'
41
+ | '/app/library'
42
+ | '/app/library/'
43
+ | '/app/y/'
43
44
  | '/app/calendar'
44
45
  | '/app/projects'
45
- | '/app/workflows'
46
- | '/app/grids'
47
46
  | '/app/workspace'
48
47
  | '/app/s/'
49
- | '/app/emails'
50
- | '/app/outbound/forms'
51
- | '/app/outbound/emails'
52
- | '/app/downloads'
53
- | '/app/qrcodes'
54
- | '/app/logs'
55
48
 
56
49
  // FieldDocs
57
50
  | '/app/fd/'
@@ -59,8 +52,8 @@ type StaticRoutePath =
59
52
  | '/app/d/'
60
53
  | '/app/p/';
61
54
 
62
- type OperationPageRoutePath = `/app/${OperationPageSlug}`;
63
- type ValidRoutePath = StaticRoutePath | OperationPageRoutePath;
55
+ type TablePageRoutePath = `/app/${string}`;
56
+ type ValidRoutePath = StaticRoutePath | TablePageRoutePath;
64
57
 
65
58
  interface RouteDictObj {
66
59
  to: ValidRoutePath;
@@ -76,8 +69,7 @@ interface RouteDictObj {
76
69
  type CheckACLClientFn = (opName: OperationName) => boolean;
77
70
 
78
71
  /*
79
- * Return a same-origin auth destination only when it targets a public form or
80
- * an authenticated app route.
72
+ * Return a same-origin auth destination only when it targets an authenticated app route.
81
73
  */
82
74
  export function getSafeAuthReturnToPath(returnTo?: string | null) {
83
75
  if (!returnTo?.startsWith('/') || returnTo.startsWith('//')) {
@@ -86,10 +78,9 @@ export function getSafeAuthReturnToPath(returnTo?: string | null) {
86
78
 
87
79
  try {
88
80
  const url = new URL(returnTo, AUTH_RETURN_TO_BASE_URL);
89
- const isPublicFormPath = AUTH_RETURN_TO_PUBLIC_FORM_PATH_PATTERN.test(url.pathname);
90
81
  const isAppPath = url.pathname === '/app' || url.pathname.startsWith('/app/');
91
82
 
92
- if (url.origin !== AUTH_RETURN_TO_BASE_URL || (!isPublicFormPath && !isAppPath)) {
83
+ if (url.origin !== AUTH_RETURN_TO_BASE_URL || !isAppPath) {
93
84
  return null;
94
85
  }
95
86
 
@@ -134,11 +125,6 @@ const STATIC_ROUTES_DICT: Record<StaticRoutePath, RouteDictObj> = {
134
125
  to: '/app',
135
126
  text: 'app.home',
136
127
  },
137
- '/app/grids': {
138
- to: '/app/grids',
139
- text: 'app.grids',
140
- iconName: COMMON_ICON_NAMES.grids,
141
- },
142
128
  '/app/workspace': {
143
129
  to: '/app/workspace',
144
130
  text: 'app.workspace',
@@ -166,50 +152,30 @@ const STATIC_ROUTES_DICT: Record<StaticRoutePath, RouteDictObj> = {
166
152
 
167
153
  hasPhysicalToolbar: 'ALWAYS',
168
154
  },
155
+ '/app/library': {
156
+ to: '/app/library',
157
+ text: 'app.route_library',
158
+ iconName: COMMON_ICON_NAMES.library,
159
+ hasPhysicalToolbar: 'ALWAYS',
160
+ },
161
+ '/app/library/': {
162
+ to: '/app/library/',
163
+ text: 'app.route_library',
164
+ iconName: COMMON_ICON_NAMES.library,
165
+ hasPhysicalToolbar: 'ALWAYS',
166
+ },
167
+ '/app/y/': {
168
+ to: '/app/y/',
169
+ text: 'c.document',
170
+ hasPhysicalToolbar: 'ALWAYS',
171
+ },
169
172
  // Advanced
170
173
 
171
- '/app/workflows': {
172
- to: '/app/workflows',
173
- text: 'c.ai_workflows',
174
- iconName: COMMON_ICON_NAMES.ai_workflow,
175
- },
176
174
  '/app/s/': {
177
175
  to: '/app/s/',
178
176
  text: 'sheet.sheets',
179
177
  iconName: COMMON_ICON_NAMES.sheet,
180
178
  },
181
- '/app/emails': {
182
- to: '/app/emails',
183
- text: 'app.emails',
184
- iconName: COMMON_ICON_NAMES.email_history,
185
- requiredACL: 'ai_inbox_read',
186
- },
187
- '/app/outbound/forms': {
188
- to: '/app/outbound/forms',
189
- text: 'campaign.web_forms',
190
- iconName: COMMON_ICON_NAMES.public_form,
191
- },
192
- '/app/outbound/emails': {
193
- to: '/app/outbound/emails',
194
- text: 'campaign.email_campaigns',
195
- iconName: COMMON_ICON_NAMES.email_campaign,
196
- },
197
- '/app/downloads': {
198
- to: '/app/downloads',
199
- text: 'c.downloads',
200
- iconName: 'download',
201
- },
202
- '/app/qrcodes': {
203
- to: '/app/qrcodes',
204
- text: 'c.qr_codes',
205
- iconName: COMMON_ICON_NAMES.qr_code,
206
- requiredACL: 'general_read',
207
- },
208
- '/app/logs': {
209
- to: '/app/logs',
210
- text: 'log.logs',
211
- iconName: COMMON_ICON_NAMES.logs,
212
- },
213
179
 
214
180
  // FieldDocs
215
181
 
@@ -239,32 +205,44 @@ const STATIC_ROUTES_DICT: Record<StaticRoutePath, RouteDictObj> = {
239
205
  },
240
206
  };
241
207
 
242
- /*
243
- * Build route-helper entries from shared operation-page navigation metadata.
244
- */
245
- function getOperationPageRoutes(): Record<OperationPageRoutePath, RouteDictObj> {
246
- return Object.fromEntries(
247
- Object.values(OPERATION_PAGES).map((page): [OperationPageRoutePath, RouteDictObj] => {
248
- const to: OperationPageRoutePath = `/app/${page.slug}`;
249
-
250
- return [to, { to, text: page.navigationTitleKey, iconName: page.iconName, allowedOperations: page.allowedOperations }];
251
- }),
252
- ) as Record<OperationPageRoutePath, RouteDictObj>;
208
+ export interface TablePageRouteMetadata {
209
+ path: TablePageRoutePath;
210
+ navigationTitleKey: string;
211
+ iconName: string;
212
+ allowedOperations?: readonly OrganizationOperationEnum[];
213
+ requiredACL?: OperationName;
253
214
  }
254
215
 
255
- // Explicit routes own their metadata when their path also names an operation page.
256
- const ROUTES_DICT: Record<ValidRoutePath, RouteDictObj> = {
257
- ...getOperationPageRoutes(),
258
- ...STATIC_ROUTES_DICT,
259
- };
216
+ let ROUTES_DICT: Record<ValidRoutePath, RouteDictObj> = { ...STATIC_ROUTES_DICT };
260
217
 
261
218
  /*
262
- * Normalize trailing slashes only for exact operation-page paths, matching the client router.
219
+ * Register app-owned table navigation and access metadata on client and server startup.
263
220
  */
264
- function getOperationPageRoutePath(pathname: string): OperationPageRoutePath | null {
265
- const page = pathname.startsWith('/app/') ? getOperationPageMetadata(pathname.slice(5).replace(/\/+$/, '')) : null;
221
+ export function configureTablePageRoutes(pages: readonly TablePageRouteMetadata[]) {
222
+ ROUTES_DICT = {
223
+ ...Object.fromEntries(
224
+ pages.map((page) => [
225
+ page.path,
226
+ {
227
+ to: page.path,
228
+ text: page.navigationTitleKey,
229
+ iconName: page.iconName,
230
+ allowedOperations: page.allowedOperations,
231
+ requiredACL: page.requiredACL,
232
+ },
233
+ ]),
234
+ ),
235
+ ...STATIC_ROUTES_DICT,
236
+ };
237
+ ROUTES_DICT_ORDERED = Object.keys(ROUTES_DICT).sort((a, b) => b.length - a.length);
238
+ }
266
239
 
267
- return page ? `/app/${page.slug}` : null;
240
+ /*
241
+ * Normalize trailing slashes only for registered table paths, without inheriting their rules for deeper URLs.
242
+ */
243
+ function getTablePageRoutePath(pathname: string): TablePageRoutePath | null {
244
+ const path = pathname.replace(/\/+$/, '') as TablePageRoutePath;
245
+ return Object.hasOwn(ROUTES_DICT, path) && !Object.hasOwn(STATIC_ROUTES_DICT, path) ? path : null;
268
246
  }
269
247
 
270
248
  /**
@@ -313,7 +291,7 @@ export function isRouteValid(routePath: ValidRoutePath, pathSegment?: string | n
313
291
  * @returns The route name if found.
314
292
  */
315
293
 
316
- const ROUTES_DICT_ORDERED = Object.keys(ROUTES_DICT).sort((a, b) => b.length - a.length);
294
+ let ROUTES_DICT_ORDERED = Object.keys(ROUTES_DICT).sort((a, b) => b.length - a.length);
317
295
 
318
296
  interface RouteConfigObj extends Omit<RouteDictObj, 'hasPhysicalToolbar'> {
319
297
  routeName: ValidRoutePath;
@@ -326,13 +304,13 @@ export function getRouteConfigs(
326
304
  operation?: OrganizationOperationEnum | null,
327
305
  checkACLClient?: CheckACLClientFn | null,
328
306
  ): RouteConfigObj {
329
- const operationPageRoutePath = getOperationPageRoutePath(pathname);
307
+ const tablePageRoutePath = getTablePageRoutePath(pathname);
330
308
 
331
309
  for (const routeName of ROUTES_DICT_ORDERED) {
332
310
  if (
333
311
  pathname === routeName ||
334
- operationPageRoutePath === routeName ||
335
- (Object.hasOwn(STATIC_ROUTES_DICT, routeName) && pathname.startsWith(routeName))
312
+ tablePageRoutePath === routeName ||
313
+ (Object.hasOwn(STATIC_ROUTES_DICT, routeName) && pathname.startsWith(routeName.endsWith('/') ? routeName : routeName + '/'))
336
314
  ) {
337
315
  // Scroll position fix + breadcrumb / TOC cleanup on unmount
338
316
  // This will retain scroll position for deeper links,
@@ -375,13 +353,13 @@ export function isRouteAllowed(
375
353
  operation?: OrganizationOperationEnum | null,
376
354
  checkACLClient?: CheckACLClientFn | null,
377
355
  ): boolean {
378
- let routeDict = ROUTES_DICT[(getOperationPageRoutePath(pathname) || pathname) as ValidRoutePath];
356
+ let routeDict = ROUTES_DICT[(getTablePageRoutePath(pathname) || pathname) as ValidRoutePath];
379
357
  if (!routeDict) {
380
358
  const parts = pathname.split('/');
381
359
  for (let i = parts.length; i > 0; i--) {
382
360
  const subPath = parts.slice(0, i).join('/');
383
361
 
384
- // Operation pages match only their exact path; only explicit routes inherit rules for deeper links.
362
+ // Table pages match only their exact path; only explicit routes inherit rules for deeper links.
385
363
  routeDict = STATIC_ROUTES_DICT[subPath as StaticRoutePath] || STATIC_ROUTES_DICT[`${subPath}/` as StaticRoutePath];
386
364
  if (routeDict || i <= 3) {
387
365
  break;
@@ -808,7 +786,6 @@ export function getOptionalNavigationItems(
808
786
  export function getDefaultNav(
809
787
  operation: OrganizationOperationEnum | null,
810
788
  checkACLClient?: CheckACLClientFn | null,
811
- _defaultSurface?: 'PROJECT' | 'COVERAGE' | null,
812
789
  ): NavigationItem[] {
813
790
  const breakItem = {
814
791
  break: true,
@@ -871,14 +848,14 @@ export function getDefaultNav(
871
848
  // text: i18n.t('schedule.title'),
872
849
  // initialExpanded: true,
873
850
  // navList:
874
- // (_defaultSurface || getScheduleDefaultSurface(operation)) === 'PROJECT'
851
+ // operation && SCHEDULING_TYPE_BY_OPERATION[operation] === 'PROJECT_MANAGEMENT'
875
852
  // ? [ROUTES_DICT['/app/projects'], ROUTES_DICT['/app/calendar']]
876
853
  // : [ROUTES_DICT['/app/calendar'], ROUTES_DICT['/app/projects']],
877
854
  // },
878
855
  {
879
856
  text: i18n.t('campaign.outbound'),
880
857
  initialExpanded: true,
881
- navList: [ROUTES_DICT['/app/outbound/forms'], ROUTES_DICT['/app/outbound/emails']],
858
+ navList: [ROUTES_DICT['/app/outreach']],
882
859
  },
883
860
  {
884
861
  text: i18n.t('c.advanced'),
@@ -902,7 +879,6 @@ export function getNavigationList(
902
879
  operation: OrganizationOperationEnum | null,
903
880
  checkACLClient?: CheckACLClientFn | null,
904
881
  sidebar?: OrganizationSidebarItemObj[] | null,
905
- defaultSurface?: 'PROJECT' | 'COVERAGE' | null,
906
882
  ): NavigationItem[] {
907
883
  const breakItem = { break: true };
908
884
  const pinnedNavList = mapNavigationList(
@@ -920,7 +896,7 @@ export function getNavigationList(
920
896
 
921
897
  const remainingNavList = Array.isArray(sidebar)
922
898
  ? getCustomizedNavigationList(sidebar, operation, checkACLClient)
923
- : getDefaultNav(operation, checkACLClient, defaultSurface);
899
+ : getDefaultNav(operation, checkACLClient);
924
900
 
925
901
  const result = pinnedNavList.concat(remainingNavList);
926
902
  // Schedule and projects are not ready.
@@ -1,8 +1,7 @@
1
- import i18n from '@jsb188/app/i18n/index.ts';
2
1
  import { getCronDescription } from '@jsb188/app/utils/cron.ts';
3
2
  import { getFullDate } from '@jsb188/app/utils/datetime.ts';
4
3
  import type { WorkflowGQL } from '@jsb188/mday/types/workflow.d.ts';
5
- import { getWorkflowShortLabel, isRecurringReminder, isWorkflowActive } from '@jsb188/mday/utils/workflow.ts';
4
+ import { isRecurringReminder } from '@jsb188/mday/utils/workflow.ts';
6
5
  import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
7
6
  import { getLogActivityGroupIconName } from './log-web.ts';
8
7
 
@@ -15,13 +14,6 @@ export function getWorkflowIconName(workflow: WorkflowGQL) {
15
14
  return firstLogType ? getLogActivityGroupIconName(firstLogType) : COMMON_ICON_NAMES.general_workflow;
16
15
  }
17
16
 
18
- /*
19
- * Return the formatted next run date for one workflow, or a table-friendly empty value.
20
- */
21
- export function getWorkflowNextRunText(workflow: WorkflowGQL, timeZone: string | null) {
22
- return workflow.nextAt ? getFullDate(workflow.nextAt, 'NUMERIC_TIME', timeZone) : null;
23
- }
24
-
25
17
  /*
26
18
  * Return the schedule description for one reminder (cron text or one-time date).
27
19
  */
@@ -51,22 +43,3 @@ export function getReminderRecipientsSummaryText(reminder: Pick<WorkflowGQL, 're
51
43
 
52
44
  return `${labels[0]}, ${labels[1]} +${labels.length - 2}`;
53
45
  }
54
-
55
- /*
56
- * Return the modal header description for one workflow's current scheduling state.
57
- */
58
- export function getWorkflowHeaderDescription(workflow: WorkflowGQL, timeZone: string | null, operation?: string | null) {
59
- if (!isWorkflowActive(workflow)) {
60
- return i18n.t('workflow.not_active_msg');
61
- }
62
-
63
- if (workflow.nextAt) {
64
- return `${i18n.t('c.next_run')}: ${getWorkflowNextRunText(workflow, timeZone)}`;
65
- }
66
-
67
- const logTypeShortLabel = workflow.logTypes?.length ? getWorkflowShortLabel(workflow, operation) : null;
68
-
69
- return i18n.t('workflow.active_msg', {
70
- logType: logTypeShortLabel?.toLowerCase(),
71
- });
72
- }