Skip to content

Commit

Permalink
fix(plugin-chart-table): value undefined when table name has dot (apa…
Browse files Browse the repository at this point in the history
…che#686)

* fix(plugin-chart-table): value undefined when table name has dot

* Upgrade react everywhere

* add comment
  • Loading branch information
ktmud authored and zhaoyongjie committed Nov 25, 2021
1 parent 6a31c7e commit d855d2b
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"access": "public"
},
"dependencies": {
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"@vx/responsive": "^0.0.197",
"csstype": "^2.6.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"access": "public"
},
"dependencies": {
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"@types/react-loadable": "^5.4.2",
"@vx/responsive": "^0.0.197",
"prop-types": "^15.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,57 +35,67 @@ export const basicFormData = {
timeseriesLimitMetric: null,
};
export const basicData = {
columns: ['name', 'sum__num', 'MAX(ds)'],
columns: ['name', 'sum__num', 'MAX(ds)', 'Abc.com'],
records: [
{
name: 'Michael',
sum__num: 2467063,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 110,
},
{
name: 'Christopher',
sum__num: 1725265,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 119,
},
{
name: 'David',
sum__num: 1570516,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'James',
sum__num: 1506025,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'John',
sum__num: 1426074,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'Matthew',
sum__num: 1355803,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'Robert',
sum__num: 1314800,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'Daniel',
sum__num: 1159354,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'Joseph',
sum__num: 1114098,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
{
name: 'William',
sum__num: 1113701,
'MAX(ds)': '2008-01-01T00:00:00',
'Abc.com': 120,
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@data-ui/sparkline": "^0.0.84",
"@types/d3-scale": "^2.0.2",
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"d3-scale": "^3.2.1",
"emotion-theming": "^10.0.27",
"moment": "^2.26.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@types/d3-geo": "^1.11.1",
"@types/geojson": "^7946.0.3",
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"@types/topojson-client": "^3.0.0",
"@types/topojson-specification": "^1.0.0",
"@vx/clip-path": "^0.0.197",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"@emotion/core": "^10.0.28",
"@types/d3-array": "^2.0.0",
"@types/match-sorter": "^4.0.0",
"@types/react": "^16.9.35",
"@types/react-dom": "^16.9.8",
"@types/react": "^16.9.43",
"@types/react-table": "^7.0.19",
"d3-array": "^2.4.0",
"match-sorter": "^4.1.0",
Expand All @@ -49,7 +48,6 @@
"@superset-ui/time-format": "^0.14.0",
"@superset-ui/translation": "^0.14.0",
"@superset-ui/validator": "^0.14.0",
"jquery": "^3.4.1",
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ export default function TableChart<D extends DataRecord = DataRecord>(
};
return {
id: String(i), // to allow duplicate column keys
accessor: key,
// must use custom accessor to allow `.` in column names
// typing is incorrect in current version of `@types/react-table`
// so we ask TS not to check.
accessor: ((datum: D) => datum[key]) as never,
Header: label,
SortIcon,
sortDescFirst: sortDesc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ describe('plugin-chart-table', () => {
wrap = mount(<TableChart {...transformProps(testData.basic)} sticky={false} />);
tree = wrap.render(); // returns a CheerioWrapper with jQuery-like API
const cells = tree.find('td');
expect(cells).toHaveLength(6);
expect(cells).toHaveLength(8);
expect(cells.eq(0).text()).toEqual('2020-01-01 12:34:56');
expect(cells.eq(1).text()).toEqual('Michael');
// number is not in `metrics` list, so it should output raw value
// (in real world Superset, this would mean the column is used in GROUP BY)
expect(cells.eq(5).text()).toEqual('2467');
expect(cells.eq(2).text()).toEqual('2467063');
// should not render column with `.` in name as `undefined`
expect(cells.eq(3).text()).toEqual('foo');
expect(cells.eq(6).text()).toEqual('2467');
});

it('render advanced data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,21 @@ const basic = {
...new ChartProps(basicChartProps),
queryData: {
data: {
columns: ['__timestamp', 'name', 'sum__num'],
columns: ['__timestamp', 'name', 'sum__num', 'abc.com'],
records: [
{
__timestamp: '2020-01-01T12:34:56',
name: 'Michael',
sum__num: 2467063,
'%pct_nice': 0.123456,
'abc.com': 'foo',
},
{
__timestamp: 1585932584140,
name: 'Joe',
sum__num: 2467,
'%pct_nice': 0.00001,
'abc.com': 'bar',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@types/d3-cloud": "^1.2.1",
"@types/d3-scale": "^2.0.2",
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"d3-cloud": "^1.2.5",
"d3-scale": "^3.0.1",
"emotion-theming": "^10.0.27",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ if (glob) {
if (extraArgs.includes('--lint')) {
run(`nimbus eslint {packages,plugins}/${glob}/{src,test}`);
}
rimraf.sync(`./{packages,plugins}/${glob}/{lib,esm,tsconfig.tsbuildinfo}`);
run(`nimbus babel --clean --workspaces="@superset-ui/${glob}" ${BABEL_CONFIG}`);
run(`nimbus babel --clean --workspaces="@superset-ui/${glob}" --esm ${BABEL_CONFIG}`);
run(`nimbus typescript --build --workspaces="@superset-ui/${glob}"`);
rimraf.sync(
`./{packages,plugins}/${glob}/{lib,esm,tsconfig.tsbuildinfo,node_modules/@types/react}`,
);
const packageName = glob.replace(/^superset-ui-/, '');
run(`nimbus babel --clean --workspaces="@superset-ui/${packageName}" ${BABEL_CONFIG}`);
run(`nimbus babel --clean --workspaces="@superset-ui/${packageName}" --esm ${BABEL_CONFIG}`);
run(`nimbus typescript --build --workspaces="@superset-ui/${packageName}"`);
// eslint-disable-next-line global-require
require('./copyAssets');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/enzyme": "^3.10.3",
"@types/jest": "^25.1.3",
"@types/jsdom": "^12.2.4",
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"@types/react-test-renderer": "^16.9.2",
"csstype": "^2.6.3",
"enzyme": "^3.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@storybook/addon-links": "^5.0.9",
"@storybook/addons": "^5.0.9",
"@storybook/react": "^5.0.9",
"@types/react": "^16.9.38",
"@types/react": "^16.9.43",
"@types/storybook__react": "4.0.2",
"bootstrap": "^3.4.1",
"jquery": "^3.4.1",
Expand Down
10 changes: 5 additions & 5 deletions superset-frontend/temporary_superset_ui/superset-ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4024,7 +4024,7 @@
dependencies:
"@types/react" "*"

"@types/react-dom@*", "@types/react-dom@^16.9.8":
"@types/react-dom@*":
version "16.9.8"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.8.tgz#fe4c1e11dfc67155733dfa6aa65108b4971cb423"
integrity sha512-ykkPQ+5nFknnlU6lDd947WbQ6TE3NNzbQAkInC2EKY1qeYdTKp7onFusmYZb+ityzx2YviqT6BXSu+LyWWJwcA==
Expand Down Expand Up @@ -4074,10 +4074,10 @@
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@^16.9.11", "@types/react@^16.9.35", "@types/react@^16.9.38":
version "16.9.38"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.38.tgz#868405dace93a4095d3e054f4c4a1de7a1ac0680"
integrity sha512-pHAeZbjjNRa/hxyNuLrvbxhhnKyKNiLC6I5fRF2Zr/t/S6zS41MiyzH4+c+1I9vVfvuRt1VS2Lodjr4ZWnxrdA==
"@types/react@*", "@types/react@^16.9.11", "@types/react@^16.9.43":
version "16.9.43"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.43.tgz#c287f23f6189666ee3bebc2eb8d0f84bcb6cdb6b"
integrity sha512-PxshAFcnJqIWYpJbLPriClH53Z2WlJcVZE+NP2etUtWQs2s7yIMj3/LDKZT/5CHJ/F62iyjVCDu2H3jHEXIxSg==
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"
Expand Down

0 comments on commit d855d2b

Please sign in to comment.