Skip to content

Commit

Permalink
feat(plugin-chart-table): rewrite with react-table (apache#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud authored and zhaoyongjie committed Nov 26, 2021
1 parent 2a28128 commit 92ac471
Show file tree
Hide file tree
Showing 42 changed files with 23,297 additions and 25,198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"babel:esm": "nimbus babel --clean --workspaces=\"@superset-ui/!(demo|generator-superset)\" --esm --config-file=../../babel.config.js",
"demo": "cd packages/superset-ui-demo && yarn demo:build",
"demo:clean": "cd packages/superset-ui-demo && yarn demo:clean",
"demo:build": "cd packages/superset-ui-demo && yarn demo:build",
"storybook": "cd packages/superset-ui-demo && yarn storybook",
"sb": "yarn storybook",
"clean": "rm -rf ./{packages,plugins}/**/{lib,esm,tsconfig.tsbuildinfo} build/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export type Formattable = string | number;
export type Formatted = [Formattable, string];

/** Turns an array of string/number options into options for a select input */
export function formatSelectOptions(options: Formattable[]): Formatted[] {
return options.map(opt => [opt, opt.toString()]);
export function formatSelectOptions<T extends Formattable>(
options: (T | [T, string])[],
): [T, string][] {
return options.map(opt => (Array.isArray(opt) ? opt : [opt, opt.toString()]));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ describe('formatSelectOptions', () => {
['unlimited', 'unlimited'],
]);
});
it('formats a mix of values and already formated options', () => {
expect(
formatSelectOptions<number | string>([[0, 'all'], 1, 5, 10, 25, 50, 'unlimited']),
).toEqual([
[0, 'all'],
[1, '1'],
[5, '5'],
[10, '10'],
[25, '25'],
[50, '50'],
['unlimited', 'unlimited'],
]);
});
});

describe('formatSelectOptionsForRange', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@superset-ui/legacy-plugin-chart-sankey": "0.14.1",
"@superset-ui/legacy-plugin-chart-sankey-loop": "0.14.1",
"@superset-ui/legacy-plugin-chart-sunburst": "0.14.1",
"@superset-ui/legacy-plugin-chart-table": "0.14.1",
"@superset-ui/plugin-chart-table": "0.14.0",
"@superset-ui/legacy-plugin-chart-treemap": "0.14.1",
"@superset-ui/legacy-plugin-chart-word-cloud": "^0.11.15",
"@superset-ui/legacy-plugin-chart-world-map": "0.14.1",
Expand All @@ -76,6 +76,7 @@
"core-js": "3.6.5",
"gh-pages": "^3.0.0",
"jquery": "^3.4.1",
"memoize-one": "^5.1.1",
"react": "^16.13.1",
"react-resizable": "^1.10.1",
"storybook-addon-jsx": "^7.2.3"
Expand Down

This file was deleted.

Loading

0 comments on commit 92ac471

Please sign in to comment.