Skip to content

Commit

Permalink
Merge branch 'main' into add_filter_on_reports
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelHedhili authored Sep 27, 2024
2 parents 60fb5b2 + c5dbc5b commit a42df9c
Show file tree
Hide file tree
Showing 43 changed files with 1,118 additions and 477 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"extends": ["react-app", "plugin:prettier/recommended"],
"ignorePatterns": [
// node_modules is implicitly always ignored
"build"
"build",
"coverage"
],
"rules": {
"prettier/prettier": "warn",
Expand Down
1 change: 1 addition & 0 deletions .github/config/.licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ header:
- '**/*.svg'
- '**/*.css'
- '**/*.conf'
- '**/*.properties'

comment: on-failure
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI

on: [push]
on:
push:
branches:
- 'main'
tags:
- 'v[0-9]*'
pull_request:

jobs:
license-headers:
Expand All @@ -26,6 +32,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
fetch-depth: 0
persist-credentials: false

- name: Parse tag
Expand All @@ -39,9 +46,15 @@ jobs:
npm install
npm run licenses-check
npm run lint
npm run test
npm run test:coverage
npm run build
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Build and publish Docker image - Main
if: github.ref == 'refs/heads/main'
uses: elgohr/Publish-Docker-Github-Action@33a481be3e179353cb7793a92b57cf9a6c985860 # v4
Expand Down
4 changes: 4 additions & 0 deletions .sonarlint/connectedMode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sonarCloudOrganization": "gridsuite",
"projectKey": "gridsuite_gridstudy-app"
}
8 changes: 4 additions & 4 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@gridsuite/commons-ui": "0.65.1",
"@gridsuite/commons-ui": "0.65.2",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.15.14",
"@mui/lab": "5.0.0-alpha.169",
Expand Down Expand Up @@ -59,6 +59,7 @@
"build": "tsc && vite build",
"serve": "vite preview",
"test": "jest",
"test:coverage": "jest --coverage",
"lint": "eslint . --ext js,mjs,jsx,ts,mts,tsx --max-warnings 0",
"licenses-check": "license-checker --summary --excludePrivatePackages --production --onlyAllow \"$( jq -r .onlyAllow[] license-checker-config.json | tr '\n' ';')\" --excludePackages \"$( jq -r .excludePackages[] license-checker-config.json | tr '\n' ';')\""
},
Expand Down
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.projectKey=gridsuite_gridstudy-app
sonar.organization=gridsuite
sonar.projectBaseDir=src
sonar.javascript.lcov.reportPaths=./coverage/lcov.info
13 changes: 11 additions & 2 deletions src/components/diagrams/diagram-pane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { useNameOrId } from '../utils/equipmentInfosHandler';
import { syncDiagramStateWithSessionStorage } from '../../redux/session-storage/diagram-state';
import SingleLineDiagramContent from './singleLineDiagram/single-line-diagram-content';
import NetworkAreaDiagramContent from './networkAreaDiagram/network-area-diagram-content';
import { useDebounce, useSnackMessage } from '@gridsuite/commons-ui';
import { OverflowableText, useDebounce, useSnackMessage } from '@gridsuite/commons-ui';
import { setNetworkAreaDiagramNbVoltageLevels } from '../../redux/actions';
import { useIntl } from 'react-intl';
import { getSubstationSingleLineDiagram, getVoltageLevelSingleLineDiagram } from '../../services/study/network';
Expand Down Expand Up @@ -263,6 +263,10 @@ const styles = {
position: 'absolute',
marginLeft: '3em',
},
minimizedDiagramTitle: {
maxWidth: '17em',
paddingTop: '4px',
},
separator: {
flexGrow: 1,
display: 'flex',
Expand Down Expand Up @@ -1010,7 +1014,12 @@ export function DiagramPane({ studyUuid, showInSpreadsheet, currentNode, visible
<ArrowUpwardIcon />
)
}
label={getDiagramTitle(diagramView)}
label={
<OverflowableText
sx={styles.minimizedDiagramTitle}
text={getDiagramTitle(diagramView)}
/>
}
onClick={() => handleOpenDiagramView(diagramView.id, diagramView.svgType)}
onDelete={() => handleCloseDiagramView(diagramView.id, diagramView.svgType)}
/>
Expand Down
45 changes: 21 additions & 24 deletions src/components/diagrams/diagram.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,28 @@ const Diagram = (props) => {
showCloseControl
onClose={onCloseHandler}
/>

{props.warningToDisplay ? (
<Box position="relative" left={0} right={0} top={0}>
<Box sx={{ position: 'relative', top: '2em', height: '100%' }}>
{props.warningToDisplay ? (
<AlertCustomMessageNode message={props.warningToDisplay} noMargin />
</Box>
) : (
<Box height={'100%'}>
{props.children}
<DiagramFooter
showCounterControls={props.svgType === DiagramType.NETWORK_AREA_DIAGRAM}
counterText={intl.formatMessage({
id: 'depth',
})}
counterValue={networkAreaDiagramDepth}
onIncrementCounter={onIncrementDepthHandler}
onDecrementCounter={onDecrementDepthHandler}
showFullscreenControl
fullScreenActive={shouldBeFullscreen}
onStartFullScreen={onShowFullScreenHandler}
onStopFullScreen={onHideFullScreenHandler}
incrementCounterDisabled={incrementCounterDisabled}
decrementCounterDisabled={decrementCounterDisabled}
/>
</Box>
)}
) : (
<>{props.children}</>
)}
</Box>
<DiagramFooter
showCounterControls={props.svgType === DiagramType.NETWORK_AREA_DIAGRAM}
counterText={intl.formatMessage({
id: 'depth',
})}
counterValue={networkAreaDiagramDepth}
onIncrementCounter={onIncrementDepthHandler}
onDecrementCounter={onDecrementDepthHandler}
showFullscreenControl
fullScreenActive={shouldBeFullscreen}
onStartFullScreen={onShowFullScreenHandler}
onStopFullScreen={onHideFullScreenHandler}
incrementCounterDisabled={incrementCounterDisabled}
decrementCounterDisabled={decrementCounterDisabled}
/>
</Paper>
</DiagramResizableBox>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,93 @@ const dynamicCssRules = [
cssSelector: '.nad-edge-infos', // data on edges (arrows and values)
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 2200,
threshold: 2500,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
{
cssSelector: '.nad-label-box', // tooltips linked to nodes
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 3000,
threshold: 3500,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
{
cssSelector: '.nad-text-edges', // visual link between nodes and their tooltip
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 3000,
threshold: 3500,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
{
cssSelector: '[class^="nad-vl0to30"], [class*=" nad-vl0to30"]',
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 4000,
threshold: 12000,
thresholdStatus: THRESHOLD_STATUS.BELOW,
},
{
cssSelector: '[class^="nad-vl30to50"], [class*=" nad-vl30to50"]',
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 4000,
threshold: 12000,
thresholdStatus: THRESHOLD_STATUS.BELOW,
},
{
cssSelector: '[class^="nad-vl50to70"], [class*=" nad-vl50to70"]',
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 9000,
threshold: 27000,
thresholdStatus: THRESHOLD_STATUS.BELOW,
},
{
cssSelector: '[class^="nad-vl70to120"], [class*=" nad-vl70to120"]',
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 9000,
threshold: 27000,
thresholdStatus: THRESHOLD_STATUS.BELOW,
},
{
cssSelector: '[class^="nad-vl120to180"], [class*=" nad-vl120to180"]',
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 12000,
threshold: 36000,
thresholdStatus: THRESHOLD_STATUS.BELOW,
},
{
cssSelector: '[class^="nad-vl180to300"], [class*=" nad-vl180to300"]',
belowThresholdCssDeclaration: { display: 'block' },
aboveThresholdCssDeclaration: { display: 'none' },
threshold: 20000,
threshold: 80000,
thresholdStatus: THRESHOLD_STATUS.BELOW,
},
{
cssSelector: '.nad-disconnected .nad-edge-path',
belowThresholdCssDeclaration: { 'stroke-dasharray': '10, 10' },
aboveThresholdCssDeclaration: { 'stroke-dasharray': '0.5%, 0.5%' },
threshold: 2500,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
{
cssSelector: '.nad-branch-edges .nad-edge-path, .nad-3wt-edges .nad-edge-path',
belowThresholdCssDeclaration: { 'stroke-width': '3' },
aboveThresholdCssDeclaration: { 'stroke-width': '0.25%' },
threshold: 1000,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
{
cssSelector: '.nad-branch-edges .nad-winding, .nad-3wt-nodes .nad-winding',
belowThresholdCssDeclaration: { 'stroke-width': '3' },
aboveThresholdCssDeclaration: { 'stroke-width': '0.25%' },
threshold: 1000,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
{
cssSelector: '.nad-vl-nodes circle.nad-unknown-busnode',
belowThresholdCssDeclaration: { 'stroke-width': '3' },
aboveThresholdCssDeclaration: { 'stroke-width': '0.25%' },
threshold: 1000,
thresholdStatus: THRESHOLD_STATUS.ABOVE,
},
];

function NetworkAreaDiagramContent(props) {
Expand Down
78 changes: 78 additions & 0 deletions src/components/dialogs/connectivity/branch-connectivity-form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Grid } from '@mui/material';
import { gridItem, GridSection } from '../dialogUtils';
import { ConnectivityForm } from './connectivity-form';
import { CONNECTIVITY, CONNECTIVITY_1, CONNECTIVITY_2 } from 'components/utils/field-constants';
import React, { FunctionComponent } from 'react';
import useVoltageLevelsListInfos from '../../../hooks/use-voltage-levels-list-infos';
import { CurrentTreeNode } from '../../../redux/reducer';
import { UUID } from 'crypto';

interface BranchConnectivityFormProps {
currentNode: CurrentTreeNode;
studyUuid: UUID;
isModification?: boolean;
previousValues?: any;
}

const BranchConnectivityForm: FunctionComponent<BranchConnectivityFormProps> = ({
currentNode,
studyUuid,
isModification = false,
previousValues,
}) => {
const voltageLevelOptions = useVoltageLevelsListInfos(studyUuid, currentNode.id);
const id1 = `${CONNECTIVITY}.${CONNECTIVITY_1}`;
const id2 = `${CONNECTIVITY}.${CONNECTIVITY_2}`;

const connectivity1Field = (
<ConnectivityForm
id={id1}
studyUuid={studyUuid}
currentNode={currentNode}
voltageLevelOptions={voltageLevelOptions}
withPosition={true}
isEquipmentModification={isModification}
previousValues={{
connectablePosition: previousValues?.connectablePosition1,
terminalConnected: previousValues?.terminal1Connected,
}}
/>
);

const connectivity2Field = (
<ConnectivityForm
id={id2}
studyUuid={studyUuid}
currentNode={currentNode}
voltageLevelOptions={voltageLevelOptions}
withPosition={true}
isEquipmentModification={isModification}
previousValues={{
connectablePosition: previousValues?.connectablePosition2,
terminalConnected: previousValues?.terminal2Connected,
}}
/>
);

return (
<>
<GridSection title="Side1" heading="4" />
<Grid container spacing={2}>
{gridItem(connectivity1Field, 12)}
</Grid>
<GridSection title="Side2" heading="4" />
<Grid container spacing={2}>
{gridItem(connectivity2Field, 12)}
</Grid>
</>
);
};

export default BranchConnectivityForm;
Loading

0 comments on commit a42df9c

Please sign in to comment.