From 2da030c5415c9d63a55d86e0ee1f5489850b7b5b Mon Sep 17 00:00:00 2001 From: Sharad S Date: Mon, 5 Aug 2024 10:47:33 -0400 Subject: [PATCH 1/7] use new table icons in workbench column headers --- .../lib/components/WorkBench/hotProps.tsx | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx index e91763f109c..4c582185e4d 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx @@ -2,9 +2,8 @@ import React from 'react'; import ReactDOMServer from 'react-dom/server'; import { wbPlanText } from '../../localization/wbPlan'; -import { f } from '../../utils/functools'; import { icons } from '../Atoms/Icons'; -import { getTable } from '../DataModel/tables'; +import { TableIcon } from '../Molecules/TableIcon'; import { userPreferences } from '../Preferences/userPreferences'; import type { Dataset } from '../WbPlanView/Wrapped'; import type { WbMapping } from './mapping'; @@ -62,23 +61,19 @@ export function useHotProps({ const colHeaders = React.useCallback( (physicalCol: number) => { - const tableIcon = mappings?.mappedHeaders?.[physicalCol]; - const isMapped = tableIcon !== undefined; + const tableIconUrl = mappings?.mappedHeaders?.[physicalCol]; + const isMapped = tableIconUrl !== undefined; const mappingCol = physicalColToMappingCol(physicalCol); const tableName = (typeof mappingCol === 'number' ? mappings?.tableNames[mappingCol] - : undefined) ?? tableIcon?.split('/').slice(-1)?.[0]?.split('.')?.[0]; - const tableLabel = isMapped - ? f.maybe(tableName, getTable)?.label ?? tableName ?? '' - : ''; - // REFACTOR: use new table icons + : undefined) ?? tableIconUrl?.split('/').slice(-1)?.[0]?.split('.')?.[0]; + return ReactDOMServer.renderToString( ); }, @@ -133,22 +128,19 @@ export function useHotProps({ function ColumnHeader({ isMapped, - tableLabel, - tableIcon, columnName, + tableName }: { readonly isMapped: boolean; - readonly tableLabel: string; - readonly tableIcon: string | undefined; readonly columnName: string; + readonly tableName: string | undefined; }): JSX.Element { return (
- {isMapped ? ( - {tableLabel} ) : ( Date: Mon, 5 Aug 2024 14:51:24 +0000 Subject: [PATCH 2/7] Lint code with ESLint and Prettier Triggered by 2da030c5415c9d63a55d86e0ee1f5489850b7b5b on branch refs/heads/issue-2864 --- .../js_src/lib/components/WorkBench/hotProps.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx index 4c582185e4d..d17e4b40b4a 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx @@ -67,7 +67,8 @@ export function useHotProps({ const tableName = (typeof mappingCol === 'number' ? mappings?.tableNames[mappingCol] - : undefined) ?? tableIconUrl?.split('/').slice(-1)?.[0]?.split('.')?.[0]; + : undefined) ?? + tableIconUrl?.split('/').slice(-1)?.[0]?.split('.')?.[0]; return ReactDOMServer.renderToString( {isMapped && tableName !== undefined ? ( - + ) : ( Date: Tue, 6 Aug 2024 10:04:32 -0400 Subject: [PATCH 3/7] remove conditional call Co-authored-by: Max Patiiuk --- .../frontend/js_src/lib/components/WorkBench/hotProps.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx index d17e4b40b4a..5e34220414a 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx @@ -68,7 +68,7 @@ export function useHotProps({ (typeof mappingCol === 'number' ? mappings?.tableNames[mappingCol] : undefined) ?? - tableIconUrl?.split('/').slice(-1)?.[0]?.split('.')?.[0]; + tableIconUrl?.split('/').slice(-1)[0]?.split('.')[0]; return ReactDOMServer.renderToString( Date: Tue, 6 Aug 2024 14:07:55 +0000 Subject: [PATCH 4/7] Lint code with ESLint and Prettier Triggered by cdc8fbeaa2091c22a8d900266fd71f4c428d36f7 on branch refs/heads/issue-2864 --- .../frontend/js_src/lib/components/WorkBench/hotProps.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx index 5e34220414a..369922d229f 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/hotProps.tsx @@ -67,8 +67,7 @@ export function useHotProps({ const tableName = (typeof mappingCol === 'number' ? mappings?.tableNames[mappingCol] - : undefined) ?? - tableIconUrl?.split('/').slice(-1)[0]?.split('.')[0]; + : undefined) ?? tableIconUrl?.split('/').at(-1)?.split('.')[0]; return ReactDOMServer.renderToString( Date: Tue, 6 Aug 2024 10:16:33 -0400 Subject: [PATCH 5/7] remove ban legacy icon --- specifyweb/frontend/js_src/lib/components/Atoms/Icons.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/Atoms/Icons.tsx b/specifyweb/frontend/js_src/lib/components/Atoms/Icons.tsx index 5d526e9bd26..cefe3fcb775 100644 --- a/specifyweb/frontend/js_src/lib/components/Atoms/Icons.tsx +++ b/specifyweb/frontend/js_src/lib/components/Atoms/Icons.tsx @@ -26,7 +26,6 @@ export const iconClassName = 'w-6 h-6 flex-shrink-0'; */ export const legacyNonJsxIcons = { arrowsExpand: ``, - ban: ``, link: ``, printer: ``, } as const; From 1c61d3753393d54db30a9cec197044d4a6bbcf82 Mon Sep 17 00:00:00 2001 From: Sharad S Date: Tue, 6 Aug 2024 10:54:28 -0400 Subject: [PATCH 6/7] force svg text vertical alignment --- specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx b/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx index 77bf5c00302..b1dc9f28281 100644 --- a/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx +++ b/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx @@ -61,6 +61,8 @@ export function SvgIcon({ Date: Tue, 6 Aug 2024 14:57:53 +0000 Subject: [PATCH 7/7] Lint code with ESLint and Prettier Triggered by 1c61d3753393d54db30a9cec197044d4a6bbcf82 on branch refs/heads/issue-2864 --- specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx b/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx index b1dc9f28281..bc167939298 100644 --- a/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx +++ b/specifyweb/frontend/js_src/lib/components/Molecules/SvgIcon.tsx @@ -60,9 +60,9 @@ export function SvgIcon({