Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove immutable.js #16823

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 7 additions & 35 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@superset-ui/legacy-plugin-chart-heatmap": "^0.18.6",
"@superset-ui/legacy-plugin-chart-histogram": "^0.18.6",
"@superset-ui/legacy-plugin-chart-horizon": "^0.18.6",
"@superset-ui/legacy-plugin-chart-map-box": "^0.18.6",
"@superset-ui/legacy-plugin-chart-map-box": "^0.18.7",
"@superset-ui/legacy-plugin-chart-paired-t-test": "^0.18.6",
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "^0.18.6",
"@superset-ui/legacy-plugin-chart-partition": "^0.18.6",
Expand Down Expand Up @@ -119,7 +119,6 @@
"global-box": "^1.2.0",
"html-webpack-plugin": "^5.3.2",
"immer": "^9.0.6",
"immutable": "^4.0.0-rc.12",
"interweave": "^11.2.0",
"jquery": "^3.5.1",
"js-levenshtein": "^1.1.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { List } from 'immutable';
import JSONbig from 'json-bigint';
import React, { PureComponent } from 'react';
import JSONTree from 'react-json-tree';
Expand Down Expand Up @@ -128,7 +127,7 @@ export default class FilterableTable extends PureComponent<
expandedColumns: [],
};

list: List<Datum>;
list: Datum[];

complexColumns: Record<string, boolean>;

Expand All @@ -142,7 +141,7 @@ export default class FilterableTable extends PureComponent<

constructor(props: FilterableTableProps) {
super(props);
this.list = List(this.formatTableData(props.data));
this.list = this.formatTableData(props.data);
this.addJsonModal = this.addJsonModal.bind(this);
this.getCellContent = this.getCellContent.bind(this);
this.renderGridCell = this.renderGridCell.bind(this);
Expand Down Expand Up @@ -182,19 +181,20 @@ export default class FilterableTable extends PureComponent<
this.fitTableToWidthIfNeeded();
}

getDatum(list: List<Datum>, index: number) {
return list.get(index % list.size);
getDatum(list: Datum[], index: number) {
return list[index % list.length];
}

getWidthsForColumns() {
const PADDING = 40; // accounts for cell padding and width of sorting icon
const widthsByColumnKey = {};
const cellContent = [].concat(
const cellContent = ([] as string[]).concat(
...this.props.orderedColumnKeys.map(key => {
const cellContentList = this.list.map((data: Datum) =>
this.getCellContent({ cellData: data[key], columnKey: key }),
) as List<string | JSX.Element>;
return cellContentList.push(key).toJS();
);
cellContentList.push(key);
return cellContentList;
}),
);

Expand All @@ -210,8 +210,8 @@ export default class FilterableTable extends PureComponent<
widthsByColumnKey[key] =
colWidths
.slice(
index * (this.list.size + 1),
(index + 1) * (this.list.size + 1),
index * (this.list.length + 1),
(index + 1) * (this.list.length + 1),
)
.reduce((a, b) => Math.max(a, b)) + PADDING;
});
Expand All @@ -225,9 +225,9 @@ export default class FilterableTable extends PureComponent<
}: {
cellData: CellDataType;
columnKey: string;
}): string | JSX.Element {
}) {
if (cellData === null) {
return <i className="text-muted">NULL</i>;
return 'NULL';
}
const content = String(cellData);
const firstCharacter = content.substring(0, 1);
Expand Down Expand Up @@ -414,8 +414,15 @@ export default class FilterableTable extends PureComponent<
style: React.CSSProperties;
}) {
const columnKey = this.props.orderedColumnKeys[columnIndex];
const cellData = this.list.get(rowIndex)[columnKey];
const content = this.getCellContent({ cellData, columnKey });
const cellData = this.list[rowIndex][columnKey];
const content =
cellData === null ? (
<i className="text-muted">
{this.getCellContent({ cellData, columnKey })}
</i>
) : (
this.getCellContent({ cellData, columnKey })
);
const cellNode = (
<div
key={key}
Expand Down Expand Up @@ -493,7 +500,7 @@ export default class FilterableTable extends PureComponent<
onScroll={onScroll}
overscanColumnCount={overscanColumnCount}
overscanRowCount={overscanRowCount}
rowCount={this.list.size}
rowCount={this.list.length}
rowHeight={rowHeight}
width={this.totalTableWidth}
/>
Expand Down Expand Up @@ -530,18 +537,18 @@ export default class FilterableTable extends PureComponent<
rowHeight,
} = this.props;

let sortedAndFilteredList: List<Datum> = this.list;
let sortedAndFilteredList = this.list;
// filter list
if (filterText) {
sortedAndFilteredList = this.list.filter((row: Datum) =>
this.hasMatch(filterText, row),
) as List<Datum>;
);
}
// sort list
if (sortBy) {
sortedAndFilteredList = sortedAndFilteredList.sort(
this.sortResults(sortBy, sortDirection === SortDirection.DESC),
) as List<Datum>;
);
}

let { height } = this.props;
Expand Down Expand Up @@ -572,7 +579,7 @@ export default class FilterableTable extends PureComponent<
rowClassName={this.rowClassName}
rowHeight={rowHeight}
rowGetter={rowGetter}
rowCount={sortedAndFilteredList.size}
rowCount={sortedAndFilteredList.length}
sort={this.sort}
sortBy={sortBy}
sortDirection={sortDirection}
Expand Down