From 4798a8799791d3245ea8d55fd56e1d93998fbee8 Mon Sep 17 00:00:00 2001 From: Zamfirov Date: Mon, 15 Jan 2024 16:30:03 +0100 Subject: [PATCH] Formatted code with Prettier --- src/viewer/structures/StructureDialog.tsx | 67 +++++---- .../structures/StructureSettingsDropdown.tsx | 139 +++++++++--------- 2 files changed, 108 insertions(+), 98 deletions(-) diff --git a/src/viewer/structures/StructureDialog.tsx b/src/viewer/structures/StructureDialog.tsx index 39ffc8f..d9d9bf2 100644 --- a/src/viewer/structures/StructureDialog.tsx +++ b/src/viewer/structures/StructureDialog.tsx @@ -1,7 +1,7 @@ import React from "react"; import Tooltip, { TooltipProps, tooltipClasses } from "@mui/material/Tooltip"; import CloseIcon from "@mui/icons-material/Close"; -import IconButton from '@mui/material/IconButton'; +import IconButton from "@mui/material/IconButton"; import StructureTable from "./StructureTable"; import { ContextMenuItem, Header, StructureDefinition, StructureEntry, Wildcard } from "../types"; import { StructureHeaderColumnType } from "../constants"; @@ -45,8 +45,8 @@ interface Props { onStructureUpdate: () => void; onNavigateStructureMatches: (isGoingForward: boolean) => void; onMatchStructure: (expression: string) => void; - onStructureDefinitionSave:(structureDefinition: string) => void; - onStructureDefinitionLoad:() => void; + onStructureDefinitionSave: (structureDefinition: string) => void; + onStructureDefinitionLoad: () => void; onExportStructureMatches: () => void; onDefineSegment: (expression: string) => void; } @@ -62,7 +62,6 @@ interface State { } export default class StructureDialog extends React.Component { - constructor(props: Props) { super(props); const { logHeaderColumns, logHeaderColumnsTypes, logSelectedRows } = this.props; @@ -88,7 +87,7 @@ export default class StructureDialog extends React.Component { componentDidMount(): void { // trigger manually, as update function isn't called for initial render. // removing the trigger to keep persistence - //this.props.onStructureUpdate(); + //this.props.onStructureUpdate(); } shouldComponentUpdate( @@ -96,9 +95,7 @@ export default class StructureDialog extends React.Component { nextState: Readonly, _nextContext: any, ): boolean { - const isLoadingStructureDefinition = ( - nextProps.loadedStructureDefinition !== null - ); + const isLoadingStructureDefinition = nextProps.loadedStructureDefinition !== null; const arelogHeaderColumnsUpdating = !isEqual( this.props.logHeaderColumns, nextProps.logHeaderColumns, @@ -158,20 +155,20 @@ export default class StructureDialog extends React.Component { } componentDidUpdate(prevProps: Readonly, _prevState: Readonly): void { - const {loadedStructureDefinition, logSelectedRows} = this.props; + const { loadedStructureDefinition, logSelectedRows } = this.props; - if(this.state.isLoadingStructureDefintion && loadedStructureDefinition !== null) { + if (this.state.isLoadingStructureDefintion && loadedStructureDefinition !== null) { this.setState({ isLoadingStructureDefintion: false, isStructureMatching: false, structureHeaderColumns: loadedStructureDefinition.headerColumns, structureHeaderColumnsTypes: loadedStructureDefinition.headerColumnsTypes, - structureEntries: loadedStructureDefinition.entries, - wildcards: loadedStructureDefinition.wildcards}); - + structureEntries: loadedStructureDefinition.entries, + wildcards: loadedStructureDefinition.wildcards, + }); + this.props.onStructureUpdate(); - } - else if (logSelectedRows !== prevProps.logSelectedRows) { + } else if (logSelectedRows !== prevProps.logSelectedRows) { this.updateStructure(); } } @@ -492,10 +489,16 @@ export default class StructureDialog extends React.Component { } saveStructureDefinition() { - const {structureHeaderColumns, structureHeaderColumnsTypes, structureEntries, wildcards} = this.state; - const {onStructureDefinitionSave} = this.props; + const { structureHeaderColumns, structureHeaderColumnsTypes, structureEntries, wildcards } = + this.state; + const { onStructureDefinitionSave } = this.props; - const structureDefiniton: StructureDefinition = { headerColumns: structureHeaderColumns, headerColumnsTypes: structureHeaderColumnsTypes, entries: structureEntries, wildcards: wildcards}; + const structureDefiniton: StructureDefinition = { + headerColumns: structureHeaderColumns, + headerColumnsTypes: structureHeaderColumnsTypes, + entries: structureEntries, + wildcards: wildcards, + }; const structureDefinitonJSON = JSON.stringify(structureDefiniton); onStructureDefinitionSave(structureDefinitonJSON); @@ -503,7 +506,7 @@ export default class StructureDialog extends React.Component { loadStructureDefinition() { this.props.onStructureDefinitionLoad(); - this.setState({isLoadingStructureDefintion:true}); + this.setState({ isLoadingStructureDefintion: true }); } render() { @@ -545,7 +548,7 @@ export default class StructureDialog extends React.Component { display: "flex", flexDirection: "row", alignItems: "center", - justifyContent: "space-between" + justifyContent: "space-between", }} > { > - - this.props.onClose()}> - - + + this.props.onClose()} + > + + void; - onStructureDefinitionLoad: () => void; + onStructureDefinitionSave: () => void; + onStructureDefinitionLoad: () => void; } -export const StructureSettingsDropdown: React.FunctionComponent = ({onStructureDefinitionSave, onStructureDefinitionLoad}) => { - const [anchorEl, setAnchorEl] = React.useState(null); - const open = Boolean(anchorEl); - const handleClick = (event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); - }; - const handleClose = (action: string) => { - if (action === 'save') - onStructureDefinitionSave(); - else if (action === 'load') - onStructureDefinitionLoad(); +export const StructureSettingsDropdown: React.FunctionComponent = ({ + onStructureDefinitionSave, + onStructureDefinitionLoad, +}) => { + const [anchorEl, setAnchorEl] = React.useState(null); + const open = Boolean(anchorEl); + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + const handleClose = (action: string) => { + if (action === "save") onStructureDefinitionSave(); + else if (action === "load") onStructureDefinitionLoad(); - setAnchorEl(null); - }; + setAnchorEl(null); + }; - return ( -
- - - - handleClose('')} - MenuListProps={{ - 'aria-labelledby': 'basic-button', - sx: { py: 0 } - }} - > - - handleClose('save')}> - - - - Save Structure Definition - - handleClose('load')}> - - - - Load Structure Definition - - - -
- ); -} \ No newline at end of file + return ( +
+ + + + handleClose("")} + MenuListProps={{ + "aria-labelledby": "basic-button", + sx: { py: 0 }, + }} + > + + handleClose("save")}> + + + + + Save Structure Definition + + + handleClose("load")}> + + + + + Load Structure Definition + + + + +
+ ); +};