Skip to content

Commit

Permalink
chore: Remove immutable.js (#16823)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Ritter authored Sep 24, 2021
1 parent 76f0408 commit c933250
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 56 deletions.
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

0 comments on commit c933250

Please sign in to comment.