Skip to content

Commit

Permalink
bump antd and typescript, and update build tools and components to wo… (
Browse files Browse the repository at this point in the history
#609)

* bump antd and typescript, and update build tools and components to work with new versions

* consolidate ts.config
  • Loading branch information
interim17 authored Nov 18, 2024
1 parent 696f7bd commit 8cbde6c
Show file tree
Hide file tree
Showing 14 changed files with 2,842 additions and 3,698 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"presets": [
"@babel/preset-react",
["@babel/preset-env", { "modules": false }],
["@babel/preset-env", { "modules": "auto" }],
"@babel/preset-typescript"
],
"env": {
Expand Down
6,356 changes: 2,803 additions & 3,553 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@types/jest": "^26.0.24",
"@types/jsdom": "12.2.2",
"@types/lodash": "4.14.121",
"@types/node": "^22.8.4",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"@types/react-plotly.js": "^2.2.4",
Expand Down Expand Up @@ -85,7 +86,7 @@
"style-loader": "3.3.1",
"ts-jest": "^29.0.3",
"ts-node": "10.9.1",
"typescript": "4.5",
"typescript": "5.6.3",
"typescript-plugin-css-modules": "5.0.0",
"url-loader": "^4.1.1",
"webpack": "^5.94.0",
Expand All @@ -97,7 +98,7 @@
"@aics/simularium-viewer": "^3.8.4",
"@ant-design/css-animation": "^1.7.3",
"@ant-design/icons": "^4.0.6",
"antd": "^4.23.6",
"antd": "^5.21.6",
"axios": "^1.7.4",
"bowser": "^2.11.0",
"classnames": "2.2.5",
Expand All @@ -121,11 +122,5 @@
"reselect": "4.0.0",
"use-debounce": "^9.0.4",
"uuid": "^9.0.1"
},
"resolutions": {
"react": "^16",
"react-dom": "^16",
"@types/react": "^16",
"@types/react-dom": "^16"
}
}
3 changes: 1 addition & 2 deletions src/components/AgentTreeSubmenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import { Checkbox as AntdCheckbox } from "antd";
import { map, noop } from "lodash";
import { CheckboxChangeEvent, CheckboxOptionType } from "antd/lib/checkbox";
import { CheckboxValueType } from "antd/lib/checkbox/Group";
const CheckboxGroup = AntdCheckbox.Group;

import Checkbox from "../Checkbox";
Expand All @@ -11,7 +10,7 @@ import { CHECKBOX_TYPE_STAR } from "../../constants";
interface AgentTreeSubmenuProps {
checkedAgents: string[];
options: CheckboxOptionType[];
onChange: (values: CheckboxValueType[]) => void;
onChange: (values: string[]) => void;
checkboxType?: CHECKBOX_TYPE_STAR;
}
import styles from "./style.css";
Expand Down
15 changes: 7 additions & 8 deletions src/components/ErrorNotification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ const ErrorNotification = ({

return notification[level]({
message: convertToSentenceCase(message),
description:
(
<div
dangerouslySetInnerHTML={{
__html: htmlData as string,
}}
/>
) || "",
description: (
<div
dangerouslySetInnerHTML={{
__html: htmlData as string,
}}
/>
),
duration: getDuration(),
onClose: onClose,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/NavButtonWithTooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const NavButtonWithTooltip: React.FC<NavButtonWithTooltipProps> = ({
title={tooltipRenderText}
color={TOOLTIP_COLOR}
mouseEnterDelay={TOOLTIP_DELAY}
arrowPointAtCenter={true}
arrow={{ pointAtCenter: true }}
align={{ targetOffset: NAV_BAR_TOOLTIP_OFFSET }}
trigger={["hover", "focus"]}
open={tooltipVisible}
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "core-js/es6/map";
import "core-js/es6/promise";
import "core-js/es6/set";

import React from "react";
import React, { useEffect } from "react";
import { createRoot } from "react-dom/client";
import { Provider, useDispatch, batch } from "react-redux";
import { Layout } from "antd";
Expand Down Expand Up @@ -31,7 +31,7 @@ function useLocationChange() {
const location = useLocation() as LocationWithState;
const dispatch = useDispatch();

React.useEffect(() => {
useEffect(() => {
if (
location.pathname !== VIEWER_PATHNAME &&
location.pathname !== EMBED_PATHNAME
Expand Down
3 changes: 2 additions & 1 deletion src/state/trajectory/logics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,11 @@ const cancelConversionLogic = createLogic({
});

const setInitialSelectedUIData = createLogic({
process(deps: ReduxLogicDeps, dispatch) {
process(deps: ReduxLogicDeps, dispatch, done) {
const { action } = deps;
const uiData = action.payload;
dispatch(setSelectedUIDisplayData(uiData));
done();
},
type: SET_DEFAULT_UI_DATA,
});
Expand Down
17 changes: 0 additions & 17 deletions src/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import { forOwn, isFunction } from "lodash";
import React from "react";
import { IconGlyphs } from "../constants/interfaces";
import { UIDisplayData } from "@aics/simularium-viewer";

type AnyFunction = () => any;

export function bindAll<T extends React.Component>(
obj: T,
methods: AnyFunction[]
) {
const setOfMethods = new Set(methods);

forOwn(obj.constructor.prototype, (value, key) => {
if (setOfMethods.has(value) && isFunction(value)) {
Object.assign(obj, { [key]: value.bind(obj) });
}
});
}

export function convertToSentenceCase(string: string): string {
if (!string) {
return "";
Expand Down
49 changes: 0 additions & 49 deletions src/util/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import * as React from "react";

import {
URL_PARAM_KEY_FILE_NAME,
URL_PARAM_KEY_USER_URL,
USER_TRAJ_REDIRECTS,
} from "../../constants";
import {
bindAll,
convertToSentenceCase,
roundTimeForDisplay,
wrapText,
Expand Down Expand Up @@ -34,52 +31,6 @@ import { UIDisplayData } from "@aics/simularium-viewer";

process.env.GOOGLE_API_KEY = "key";
describe("General utilities", () => {
describe("bindAll", () => {
it("binds class methods to a class", () => {
class Foo extends React.Component {
private message = "Hello from Foo";

constructor(props: any) {
super(props);
bindAll(this, [this.bar]);
}

public bar() {
return this.message;
}
}

const foo = new Foo({});
const bar = foo.bar;
expect(foo.bar()).toBe(bar());
});

it("does not bind a method that it was not asked to bind", () => {
class Foo extends React.Component {
private message = "Hello from Foo";

constructor(props: Record<string, never>) {
super(props);
bindAll(this, [this.bar]);
}

public bar() {
return this.message;
}

public baz() {
return this.message;
}
}

const foo = new Foo({});
const baz = foo.baz;

expect(foo.baz()).toBe("Hello from Foo");
expect(baz).toThrowError(TypeError);
});
});

describe("toSentenceCase", () => {
it("returns an empty string as is", () => {
const startingString = "";
Expand Down
25 changes: 0 additions & 25 deletions tsconfig.base.json

This file was deleted.

6 changes: 0 additions & 6 deletions tsconfig.commonjs.json

This file was deleted.

25 changes: 22 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
{
"extends": "./tsconfig.base",
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"downlevelIteration": true,
"jsx": "react",
"lib": ["DOM", "ES2015", "ES6", "DOM.Iterable", "ScriptHost"],
"moduleResolution": "Node",
"skipLibCheck": true,
"noEmit": true,
"preserveConstEnums": true,
"sourceMap": true,
"strict": true,
"module": "ES6",
"resolveJsonModule": true,
"esModuleInterop": true
}
"esModuleInterop": true,
"plugins": [
{
"name": "typescript-plugin-css-modules",

}
]
},
"include": [
"src/**/*"
]
}
22 changes: 0 additions & 22 deletions webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const path = require("path");
const fs = require("fs");

const lessToJs = require("less-vars-to-js");
const themeVariables = lessToJs(
fs.readFileSync(path.join(__dirname, "../src/styles/ant-vars.less"), "utf8")
);
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const { devServer, Env, stats } = require("./constants");
Expand Down Expand Up @@ -104,24 +100,6 @@ module.exports = ({ analyze, env, dest = "dist" } = {}) => ({
},
],
},
{
test: /\.less$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{
loader: "css-loader",
},
{
loader: "less-loader",
options: {
lessOptions: {
javascriptEnabled: true,
modifyVars: themeVariables,
},
},
},
],
},
{
test: /\.(eot|woff|woff2)([\?]?.*)$/,
include: [path.resolve(__dirname, "../src/assets/fonts")],
Expand Down

0 comments on commit 8cbde6c

Please sign in to comment.