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

Migrate Utils to TS #2380

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"extends": ["react-app", "plugin:prettier/recommended"],
"extends": ["plugin:jest-extended/all", "react-app", "plugin:prettier/recommended"],
"ignorePatterns": [
// node_modules is implicitly always ignored
"build",
Expand Down
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const config: Config = {
transformIgnorePatterns: ['node_modules/(?!@gridsuite/commons-ui|react-dnd|dnd-core|@react-dnd)'], // transform from ESM
moduleDirectories: ['node_modules', 'src'], // to allow absolute path from ./src
setupFiles: ['<rootDir>/jest.setup.ts'],
setupFilesAfterEnv: ['jest-extended/all'],
};

export default config;
179 changes: 179 additions & 0 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@reduxjs/toolkit": "^2.2.3",
"@svgdotjs/svg.js": "^3.2.0",
"@svgdotjs/svg.panzoom.js": "^2.1.2",
"@xyflow/react": "^12.3.2",
"ag-grid-community": "^31.0.0",
"ag-grid-react": "^31.2.0",
"cheap-ruler": "^3.0.2",
Expand All @@ -36,7 +37,6 @@
"react-beautiful-dnd": "^13.1.1",
"react-csv-downloader": "^3.1.0",
"react-dom": "^18.2.0",
"@xyflow/react": "^12.3.2",
"react-grid-layout": "^1.4.4",
"react-hook-form": "^7.51.2",
"react-intl": "^6.6.4",
Expand Down Expand Up @@ -101,15 +101,18 @@
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest-extended": "^2.4.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2",
"license-checker": "^25.0.1",
"prettier": "^2.8.8",
"ts-arithmetic": "^0.1.1",
"ts-node": "^10.9.2",
"type-fest": "^4.22.1",
"typescript": "5.1.6",
Expand Down
12 changes: 5 additions & 7 deletions src/components/diagrams/diagram-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { isNodeBuilt, isNodeInNotificationList } from '../graph/util/model-funct
import { AutoSizer } from 'react-virtualized';
import Diagram from './diagram';
import { SLD_DISPLAY_MODE } from '../network/constants';
import { useNameOrId } from '../utils/equipmentInfosHandler';
import useNameOrId from '../utils/use-name-or-id';
import { syncDiagramStateWithSessionStorage } from '../../redux/session-storage/diagram-state';
import SingleLineDiagramContent from './singleLineDiagram/single-line-diagram-content';
import NetworkAreaDiagramContent from './networkAreaDiagram/network-area-diagram-content';
Expand Down Expand Up @@ -210,17 +210,15 @@ const useDisplayView = (studyUuid: UUID, currentNode: CurrentTreeNode) => {
let nadTitle = '';
let substationsIds: UUID[] = [];
svg.additionalMetadata?.voltageLevels
.map((vl: { name: string; substationId: UUID }) => ({
.map((vl) => ({
name: getNameOrId(vl),
substationId: vl.substationId,
}))
.sort(
(
vlA: { name: string; substationId: UUID },
vlB: { name: string; substationId: UUID }
) => vlA.name.toLowerCase().localeCompare(vlB.name.toLowerCase())
(vlA, vlB) =>
vlA.name?.toLowerCase()?.localeCompare(vlB.name?.toLowerCase() ?? '') ?? -1
)
.forEach((voltageLevel: { name: string; substationId: UUID }) => {
.forEach((voltageLevel) => {
const name = voltageLevel.name;
if (name !== null) {
nadTitle += (nadTitle !== '' ? ', ' : '') + name;
Expand Down
Loading
Loading