An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
Add disabling options for TableWalker (#445)
Elwynn Chenb1e9de5a38d9
diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.ymldeleted file mode 100644index 8ce82088..00000000--- a/.github/workflows/code-review.yml+++ /dev/null@@ -1,20 +0,0 @@-name: Code Review GPT--on:- pull_request:- branches: [main]--jobs:- run_code_review:- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v3- with:- fetch-depth: 0-- - name: Code Review GPT- uses: mattzcarey/[email protected]- with:- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}- MODEL: 'gpt-4'- GITHUB_TOKEN: ${{ github.token }}\ No newline at end of filediff --git a/packages/graphic-walker/src/Table.tsx b/packages/graphic-walker/src/Table.tsxindex 822b0276..5d165abf 100644--- a/packages/graphic-walker/src/Table.tsx+++ b/packages/graphic-walker/src/Table.tsx@@ -95,6 +95,9 @@ export const TableApp = observer(function VizApp(props: BaseTableProps) {displayOffset={props.displayOffset}hidePaginationAtOnepage={props.hidePaginationAtOnepage}hideProfiling={props.hideProfiling}+ disableFilter={props.disableFilter}+ disableSorting={props.disableSorting}+ hideSemanticType={props.hideSemanticType}/></div><div ref={setPortal} />diff --git a/packages/graphic-walker/src/components/dataTable/index.tsx b/packages/graphic-walker/src/components/dataTable/index.tsxindex 8745a842..f2f1ca0e 100644--- a/packages/graphic-walker/src/components/dataTable/index.tsx+++ b/packages/graphic-walker/src/components/dataTable/index.tsx@@ -25,6 +25,8 @@ interface DataTableProps {computation: IComputationFunction;onMetaChange?: (fid: string, fIndex: number, meta: Partial<IMutField>) => void;disableFilter?: boolean;+ disableSorting?: boolean;+ hideSemanticType?: boolean;hideProfiling?: boolean;hidePaginationAtOnepage?: boolean;displayOffset?: number;@@ -239,7 +241,18 @@ const DataTable = forwardRef(getFilters: () => IVisFilter[];}>) => {- const { size = 10, onMetaChange, metas, computation, disableFilter, displayOffset, hidePaginationAtOnepage, hideProfiling } = props;+ const {+ size = 10,+ onMetaChange,+ metas,+ computation,+ disableFilter,+ disableSorting,+ hideSemanticType,+ displayOffset,+ hidePaginationAtOnepage,+ hideProfiling,+ } = props;const [pageIndex, setPageIndex] = useState(0);const { t } = useTranslation();const computationFunction = computation;@@ -319,7 +332,7 @@ const DataTable = forwardRef(setDataLoading(true);const taskId = ++taskIdRef.current;dataReadRaw(computationFunction, size, pageIndex, {- sorting,+ sorting: disableSorting ? undefined : sorting,filters: filters.filter((x) => x.rule).map((x) => ({ ...x, rule: x.rule! })),}).then((data) => {@@ -338,7 +351,7 @@ const DataTable = forwardRef(return () => {taskIdRef.current++;};- }, [computationFunction, pageIndex, size, sorting, filters]);+ }, [computationFunction, pageIndex, size, sorting, filters, disableSorting]);const filteredComputation = useMemo((): IComputationFunction => {const filterRules = filters.filter((f) => f.rule).map(createFilter);@@ -431,12 +444,12 @@ const DataTable = forwardRef(}><div className="font-normal block">- {!onMetaChange && (+ {!hideSemanticType && !onMetaChange && (<span className={'inline-flex p-0.5 text-xs mt-1 rounded ' + getSemanticColors(f.value)}><DataTypeIcon dataType={f.value.semanticType} analyticType={f.value.analyticType} /></span>)}- {onMetaChange && (+ {!hideSemanticType && onMetaChange && (<DropdownContextoptions={semanticTypeList}onSelect={(value) => {@@ -458,7 +471,8 @@ const DataTable = forwardRef(</div><bclassName="inline-block"- onClick={() =>+ onClick={() => {+ if (disableSorting) return;setSorting((s) => {if (s?.fid === f.value.fid && s.sort === 'descending') {return {@@ -470,12 +484,12 @@ const DataTable = forwardRef(fid: f.value.fid,sort: 'descending',};- })- }+ });+ }}>{f.value.basename || f.value.name || f.value.fid}</b>- {sorting?.fid === f.value.fid && (+ {!disableSorting && sorting?.fid === f.value.fid && (<div className="mx-1">{sorting.sort === 'ascending' && <BarsArrowUpIcon className="w-3" />}{sorting.sort === 'descending' && <BarsArrowDownIcon className="w-3" />}diff --git a/packages/graphic-walker/src/interfaces.ts b/packages/graphic-walker/src/interfaces.tsindex 78da4bd6..b5a73dfd 100644--- a/packages/graphic-walker/src/interfaces.ts+++ b/packages/graphic-walker/src/interfaces.ts@@ -989,6 +989,9 @@ export interface ITableSpecProps {hideProfiling?: boolean;hidePaginationAtOnepage?: boolean;displayOffset?: number;+ disableFilter?: boolean;+ disableSorting?: boolean;+ hideSemanticType?: boolean;/** @deprecated use vizThemeConfig instead */themeKey?: IThemeKey;/** @deprecated use vizThemeConfig instead */diff --git a/packages/playground/src/examples/nav.tsx b/packages/playground/src/examples/nav.tsxindex 6bcb0245..7672c652 100644--- a/packages/playground/src/examples/nav.tsx+++ b/packages/playground/src/examples/nav.tsx@@ -27,6 +27,10 @@ export const pages = [comp: () => import('./pages/table'),name: 'TableWalker',},+ {+ comp: () => import('./pages/tableSettings'),+ name: 'TableWalker Settings',+ },{comp: () => import('./pages/filterContext'),name: 'Filter Context',diff --git a/packages/playground/src/examples/pages/tableSettings.stories.tsx b/packages/playground/src/examples/pages/tableSettings.stories.tsxnew file mode 100644index 00000000..38f21fb4--- /dev/null+++ b/packages/playground/src/examples/pages/tableSettings.stories.tsx@@ -0,0 +1,94 @@+import { useState, useContext } from 'react';+import { TableWalker } from '@kanaries/graphic-walker';+import { themeContext } from '../context';+import { useFetch, IDataSource } from '../util';+import { Switch } from '@headlessui/react';++export default function TableSettingsShowcase() {+ const { theme } = useContext(themeContext);+ const { dataSource, fields } = useFetch<IDataSource>('https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-students-service.json');++ // State for toggle settings+ const [disableFilter, setDisableFilter] = useState(false);+ const [disableSorting, setDisableSorting] = useState(false);+ const [hideSemanticType, setHideSemanticType] = useState(false);++ // Switch option component+ const SwitchOption = ({+ label,+ checked,+ onChange+ }: {+ label: string;+ checked: boolean;+ onChange: (checked: boolean) => void+ }) => {+ return (+ <div className="flex items-center gap-2">+ <Switch+ checked={checked}+ onChange={onChange}+ className={`${+ checked ? 'bg-blue-600' : 'bg-gray-200 dark:bg-gray-700'+ } relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2`}+ >+ <span className="sr-only">{label}</span>+ <span+ className={`${+ checked ? 'translate-x-6' : 'translate-x-1'+ } inline-block h-4 w-4 transform rounded-full bg-white transition-transform`}+ />+ </Switch>+ <span className="text-sm font-medium">{label}</span>+ </div>+ );+ };++ return (+ <div className="flex flex-col gap-4">+ <div className="p-4 border rounded-md dark:border-gray-700">+ <h2 className="text-lg font-semibold mb-3">TableWalker API Settings</h2>+ <div className="flex flex-wrap gap-4 mb-4">+ <SwitchOption+ label="Disable Filter"+ checked={disableFilter}+ onChange={setDisableFilter}+ />+ <SwitchOption+ label="Disable Sorting"+ checked={disableSorting}+ onChange={setDisableSorting}+ />+ <SwitchOption+ label="Hide Semantic Type"+ checked={hideSemanticType}+ onChange={setHideSemanticType}+ />+ </div>+ <div className="text-sm mb-4">+ <p>Current settings:</p>+ <code className="block p-2 bg-gray-100 dark:bg-gray-800 rounded mt-1">+ {`{+ disableFilter: ${disableFilter},+ disableSorting: ${disableSorting},+ hideSemanticType: ${hideSemanticType}+}`}+ </code>+ </div>+ </div>++ {dataSource && fields && (+ <TableWalker+ fields={fields}+ data={dataSource}+ appearance={theme}+ disableFilter={disableFilter}+ disableSorting={disableSorting}+ hideSemanticType={hideSemanticType}+ pageSize={20}+ vizThemeConfig="g2"+ />+ )}+ </div>+ );+}\ No newline at end of filediff --git a/packages/playground/src/examples/pages/tableSettings.tsx b/packages/playground/src/examples/pages/tableSettings.tsxnew file mode 100644index 00000000..7ae758a7--- /dev/null+++ b/packages/playground/src/examples/pages/tableSettings.tsx@@ -0,0 +1,11 @@+import Example from '../components/examplePage';+import code from './tableSettings.stories?raw';+import Comp from './tableSettings.stories';++export default function TableSettingsPage() {+ return (+ <Example name="TableWalker Settings" code={code}>+ <Comp />+ </Example>+ );+}\ No newline at end of filediff --git a/yarn.lock b/yarn.lockindex 8a4243b2..b89b8026 100644--- a/yarn.lock+++ b/yarn.lock@@ -2076,12 +2076,10 @@"@types/react" "*""@types/reactcss" "*"-"@types/react-dom@*", "@types/react-dom@^18.2.15":- version "18.3.0"- resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.3.0.tgz#0cbc818755d87066ab6ca74fbedb2547d74a82b0"- integrity sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==- dependencies:- "@types/react" "*"+"@types/react-dom@*", "@types/react-dom@^18.2.15", "@types/react-dom@^18.x":+ version "18.3.7"+ resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz#b89ddf2cd83b4feafcc4e2ea41afdfb95a0d194f"+ integrity sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ=="@types/react-syntax-highlighter@^15.5.10":version "15.5.10"@@ -2090,10 +2088,10 @@dependencies:"@types/react" "*"-"@types/react@*", "@types/react@^18.2.37":- version "18.3.3"- resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.3.tgz#9679020895318b0915d7a3ab004d92d33375c45f"- integrity sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==+"@types/react@*", "@types/react@^18.2.37", "@types/react@^18.x":+ version "18.3.21"+ resolved "https://registry.npmjs.org/@types/react/-/react-18.3.21.tgz#ba9bdc8833ceaf2b5edabbbabfbf9a84040df89a"+ integrity sha512-gXLBtmlcRJeT09/sI4PxVwyrku6SaNUj/6cMubjE6T6XdY1fDmBL7r0nX0jbSZPU/Xr0KuwLLZh6aOYY5d91Xw==dependencies:"@types/prop-types" "*"csstype "^3.0.2"