feat(table): add getCopyDeepLinkAction utility and TableAction type#1656
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new TableAction type and a helper function getCopyDeepLinkAction to standardise the "Copy link" action within the ResponsiveDataTable component, exporting them from the module's entry point. Feedback suggests making the action's title configurable with a default value to avoid hardcoded UI strings and support internationalization (i18n).
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| export const getCopyDeepLinkAction = (onCopy: () => void): TableAction => ({ | ||
| title: 'Copy link', | ||
| icon: <CopyLinkIcon width={20} height={20} />, | ||
| onClick: onCopy, | ||
| }); |
There was a problem hiding this comment.
Avoid hardcoding UI strings in shared components and utilities. To support internationalization (i18n) and localization, expose the title string as a configurable parameter with a default value of 'Copy link' to maintain backward compatibility.
| export const getCopyDeepLinkAction = (onCopy: () => void): TableAction => ({ | |
| title: 'Copy link', | |
| icon: <CopyLinkIcon width={20} height={20} />, | |
| onClick: onCopy, | |
| }); | |
| export const getCopyDeepLinkAction = (onCopy: () => void, title = 'Copy link'): TableAction => ({ | |
| title, | |
| icon: <CopyLinkIcon width={20} height={20} />, | |
| onClick: onCopy, | |
| }); |
References
- Avoid hardcoding UI strings (such as button labels) in shared components. Expose these strings as configurable props to support internationalization (i18n) and localization.
- When exposing UI strings as configurable props in shared components to support localization, provide a default value to maintain backward compatibility.
There was a problem hiding this comment.
Good call — fixed in the follow-up commit. getCopyDeepLinkAction now accepts an optional title parameter (default 'Copy link') so consumers can pass a localized string without breaking existing call sites.
Expose a pre-built TableAction descriptor that produces a 'Copy link' row-action menu entry. Callers pass an onCopy callback; the action renders CopyLinkIcon and a 'Copy link' label. Export getCopyDeepLinkAction and the TableAction type from the custom index so Meshery UI and other consumers can use them without reaching into the component internals. Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
95fb225 to
d64abf3
Compare
Expand the custom directory description in CONTRIBUTING.md to cover ResponsiveDataTable: key exports, getCopyDeepLinkAction helper signature and i18n title param, and the steps for adding a new responsive column. Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
df7b0fa to
cb03dd2
Compare
The helper and its TableAction type were defined inline in ResponsiveDataTable
and reached the package entry only through 'export * from ./custom'.
rollup-plugin-dts drops such nested re-exports from the bundled declarations,
so 'import { getCopyDeepLinkAction, TableAction } from @sistent/sistent'
resolved to nothing in consumers despite the runtime export existing.
Re-exporting them directly from ResponsiveDataTable is not viable: it imports
the untyped @sistent/mui-datatables, which makes the dts build resolve that
module and fail (TS7016). Move both into a new leaf module TableActions (free
of untyped imports) and re-export it explicitly from src/index.tsx, the same
workaround already used for FeedbackButton, so both the value and the type land
in the published bundle.
Verified: build exits 0 and dist/index.d.ts declares both symbols.
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
feat(table): add getCopyDeepLinkAction utility and TableAction type
Summary
TableActiontype and agetCopyDeepLinkAction(onCopy, title?)helper that returns a pre-built row-action descriptor (withCopyLinkIconand the provided callback);titledefaults to'Copy link'and is overridable for i18nResponsiveDataTableactionsListChanges
src/custom/TableActions.tsx(new) - holds theTableActiontype andgetCopyDeepLinkActionhelpersrc/custom/ResponsiveDataTable.tsx- importsTableActionfrom the leaf for theColumn.options.actionsListtypingsrc/custom/index.tsx- re-exports both from the leaf modulesrc/index.tsx- explicit root re-export of the leaf so the symbols land in the published declaration bundleWhy a separate
TableActionsleaf moduleThe type and helper were originally inline in
ResponsiveDataTable, reaching the entry only throughexport * from './custom'. rollup-plugin-dts (used by tsup for the declaration bundle) drops such nested re-exports, soimport { getCopyDeepLinkAction, TableAction } from '@sistent/sistent'resolved to nothing in consumers even though the runtime export existed. Re-exporting directly fromResponsiveDataTableis not viable - it imports the untyped@sistent/mui-datatables, which makes the dts build resolve that module and fail (TS7016). Moving the symbols into a leaf module free of untyped imports lets the explicit root re-export force them into the published bundle (the same workaround already used forFeedbackButton).Usage
Test plan
getCopyDeepLinkActionreturns a descriptor withtitle,icon,onClick(default title'Copy link')getCopyDeepLinkAction(dist/index.js)dist/index.d.tsdeclares bothTableActionandgetCopyDeepLinkActionat the package roottsupbuild (JS + declaration bundle) exits 0CopyLinkIconrenders in theDataTableEllipsisMenuaction list - visual, exercised by consumers