-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tooltip & width change (#7) Co-authored-by: Leon <> * Ui/group-changes-by-change-type (#8) map changes Co-authored-by: Leon <> * ui/ performance optimization (#9) * avoid unnecessery renderes * removed redundant code * added category change header * cleaned redeundant * pr comments * put color Co-authored-by: Leon <> * ui/ restore collapse button (#12) * avoid unnecessery renderes * removed redundant code * recover lost change type header * added category change header * cleaned redeundant * pr comments * put color * split accordions state to 2 atoms * atom rename * spaces removed * fix bad setState * reverst change * rel changed * pr comments Co-authored-by: Leon <> Co-authored-by: Gustavo Massaneiro <[email protected]>
- Loading branch information
1 parent
fb8bf54
commit 99fde1f
Showing
17 changed files
with
1,362 additions
and
1,249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ module.exports = { | |
return webpackConfig | ||
} | ||
}, | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Accordion, AccordionSummary, AccordionDetails } from "@mui/material" | ||
import { Path } from "../../interfaces" | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
import SyntaxHighlighter from "../SyntaxHighlighter" | ||
import { ChangeTypeEnum, infoClass } from "../../consts"; | ||
import { useState, useEffect, useCallback } from "react"; | ||
import { useRecoilValue } from "recoil"; | ||
import { subAccordionsList } from "../../recoil/collapse"; | ||
|
||
export interface PathDisplayProps { | ||
path: Path | ||
} | ||
|
||
export const PathDisplay: React.FC<PathDisplayProps> = ({ path }) => { | ||
const subAccordions = useRecoilValue(subAccordionsList); | ||
const [isExpanded, setIsExpanded] = useState(false) | ||
|
||
const getToTypeColor = (type: string) => { | ||
switch (type) { | ||
case ChangeTypeEnum.Created: | ||
return ChangeTypeEnum.Created | ||
case ChangeTypeEnum.Updated: | ||
return ChangeTypeEnum.Created | ||
case ChangeTypeEnum.Deleted: | ||
return ChangeTypeEnum.Deleted | ||
default: | ||
return infoClass | ||
} | ||
} | ||
|
||
const getFromTypeColor = (type: string) => { | ||
switch (type) { | ||
case ChangeTypeEnum.Created: | ||
return ChangeTypeEnum.Created | ||
case ChangeTypeEnum.Updated: | ||
return ChangeTypeEnum.Deleted | ||
case ChangeTypeEnum.Deleted: | ||
return ChangeTypeEnum.Deleted | ||
default: | ||
return infoClass | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
const isGloballyExpanded = !!subAccordions.find(x => x.id === JSON.stringify(path))?.isCollapsed | ||
setIsExpanded(isGloballyExpanded) | ||
}, [path, subAccordions]) | ||
|
||
const onAccordionClick = useCallback(() => { | ||
setIsExpanded(!isExpanded) | ||
}, [isExpanded]) | ||
|
||
return (<> | ||
<Accordion expanded={isExpanded}> | ||
<AccordionSummary | ||
onClick={onAccordionClick} | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel2a-content"> | ||
<div className="singleLine"> | ||
<span className={`operation ${path.operation}`}>{path.operation}</span> | ||
<span className='pathName'>{path.changelog?.path?.join(" ")}</span> | ||
</div> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
{isExpanded && <><span>Path:</span> | ||
{path.changelog?.path?.slice(1).map((path: string, index: number) => | ||
<div key={index} style={{ paddingLeft: `${(index + 1 * 0.4)}em` }}>{path}</div>) | ||
} | ||
<div style={{ marginTop: "10px" }} className="diffContainer"> | ||
|
||
{path?.changelog?.from && <div style={{ flex: 1, width: "100%" }}> | ||
<div>From:</div> | ||
<SyntaxHighlighter | ||
code={JSON.stringify(path.changelog.from)} | ||
language="json" | ||
className={`${getFromTypeColor(path.changelog.type)}`} | ||
/> | ||
</div>} | ||
{path?.changelog?.to && <div style={{ flex: 1, width: "100%" }}> | ||
<div>To:</div> | ||
<SyntaxHighlighter | ||
code={JSON.stringify(path.changelog.to)} | ||
language="json" | ||
className={`${getToTypeColor(path.changelog.type)}`} | ||
/> | ||
</div>} | ||
</div></>} | ||
|
||
</AccordionDetails> | ||
</Accordion> | ||
</>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.