From 0c79993b655764e87d9b1b473f5d2b68fe469190 Mon Sep 17 00:00:00 2001 From: sylenien Date: Fri, 30 Sep 2022 12:35:02 +0200 Subject: [PATCH] change(ui): change jump button position, add diffs and tte titles --- .../components/Session_/BottomBlock/Header.js | 3 +- .../components/Session_/Storage/DiffRow.tsx | 4 +- .../components/Session_/Storage/Storage.js | 83 ++++++++----------- .../Session_/Storage/storage.module.css | 5 +- 4 files changed, 42 insertions(+), 53 deletions(-) diff --git a/frontend/app/components/Session_/BottomBlock/Header.js b/frontend/app/components/Session_/BottomBlock/Header.js index 15dd7a0c9..15cdf3365 100644 --- a/frontend/app/components/Session_/BottomBlock/Header.js +++ b/frontend/app/components/Session_/BottomBlock/Header.js @@ -11,9 +11,10 @@ const Header = ({ closeBottomBlock, onFilterChange, showClose = true, + customStyle, ...props }) => ( -
+
{ children }
{ showClose && } diff --git a/frontend/app/components/Session_/Storage/DiffRow.tsx b/frontend/app/components/Session_/Storage/DiffRow.tsx index 72a9bed46..4dbd39345 100644 --- a/frontend/app/components/Session_/Storage/DiffRow.tsx +++ b/frontend/app/components/Session_/Storage/DiffRow.tsx @@ -7,14 +7,14 @@ interface Props { diff: Record; } -function DiffRow({ diff, path, pathRoot, shades }: Props) { +function DiffRow({ diff, path }: Props) { const [shorten, setShorten] = React.useState(true); const oldValue = diff.item ? JSON.stringify(diff.item.lhs) : JSON.stringify(diff.lhs); const newValue = diff.item ? JSON.stringify(diff.item.rhs) : JSON.stringify(diff.rhs); const pathStr = path.length > 15 && shorten ? path.slice(0, 5) + '...' + path.slice(10) : path; return ( -
+
15 ? 'cursor-pointer' : ''} onClick={() => setShorten(false)}> {pathStr} {': '} diff --git a/frontend/app/components/Session_/Storage/Storage.js b/frontend/app/components/Session_/Storage/Storage.js index f4f2cd80b..f159ab8ce 100644 --- a/frontend/app/components/Session_/Storage/Storage.js +++ b/frontend/app/components/Session_/Storage/Storage.js @@ -17,6 +17,7 @@ import BottomBlock from '../BottomBlock/index'; import DiffRow from './DiffRow'; import cn from 'classnames'; import stl from './storage.module.css'; +import { Tooltip } from 'react-tippy' // const STATE = 'STATE'; // const DIFF = 'DIFF'; @@ -25,7 +26,6 @@ import stl from './storage.module.css'; function getActionsName(type) { switch (type) { case STORAGE_TYPES.MOBX: - return 'MUTATIONS'; case STORAGE_TYPES.VUEX: return 'MUTATIONS'; default: @@ -33,26 +33,6 @@ function getActionsName(type) { } } -const PATH_BGS = [ - '255, 173, 173', - '202, 255, 191', - '155, 246, 255', - '255, 198, 255', - '160, 196, 255', - '251, 248, 204', - '253, 228, 207', - '255, 207, 210', - '241, 192, 232', - '207, 186, 240', - '163, 196, 243', - '144, 219, 244', - '142, 236, 245', - '152, 245, 225', - '185, 251, 192', -]; - -const buildBg = (shade) => `rgba(${shade}, 0.2)`; - @connectPlayer((state) => ({ type: selectStorageType(state), list: selectStorageList(state), @@ -68,9 +48,8 @@ const buildBg = (shade) => `rgba(${shade}, 0.2)`; ) //@withEnumToggle('activeTab', 'setActiveTab', DIFF) export default class Storage extends React.PureComponent { - pathShades = {}; - lastBtnRef = React.createRef(); + state = { showDiffs: false }; focusNextButton() { if (this.lastBtnRef.current) { @@ -105,39 +84,33 @@ export default class Storage extends React.PureComponent { } return ( -
+
{stateDiff.map((d, i) => this.renderDiffs(d, i))}
); } renderDiffs(diff, i) { - const [path, pathRoot] = this.createPathAndBg(diff); + const path = this.createPath(diff); return ( - + ); } - createPathAndBg = (diff) => { + createPath = (diff) => { let path = []; - let pathRoot; if (diff.path) { path = path.concat(diff.path); - pathRoot = diff.path[0]; - if (!this.pathShades[pathRoot]) { - const randomShade = PATH_BGS[Math.floor(Math.random() * PATH_BGS.length)]; - this.pathShades[pathRoot] = buildBg(randomShade); - } } if (typeof diff.index !== 'undefined') { path.push(diff.index); } const pathStr = path.length ? path.join('.') : ''; - return [pathStr, pathRoot]; + return pathStr; }; ensureString(actionType) { @@ -182,6 +155,10 @@ export default class Storage extends React.PureComponent { name = item.mutation.join(''); } + if (src !== null && !this.state.showDiffs) { + this.setState({ showDiffs: true }) + } + return (
)} -
- {i + 1 < listNow.length && ( - - )} - {i + 1 === listNow.length && i + 1 < list.length && ( - - )} +
{typeof item.duration === 'number' && (
{formatMs(item.duration)}
)} +
+ {i + 1 < listNow.length && ( + + )} + {i + 1 === listNow.length && i + 1 < list.length && ( + + )} +
); @@ -233,8 +212,18 @@ export default class Storage extends React.PureComponent { {list.length > 0 && (
- {showStore &&

{'STORE'}

} -

{getActionsName(type)}

+ {showStore &&

{'STATE'}

} + {this.state.showDiffs ? ( +

+ DIFFS +

+ ) : null} +

{getActionsName(type)}

+

+ + TTE + +

)}
diff --git a/frontend/app/components/Session_/Storage/storage.module.css b/frontend/app/components/Session_/Storage/storage.module.css index 55f04d5db..d34ab27b9 100644 --- a/frontend/app/components/Session_/Storage/storage.module.css +++ b/frontend/app/components/Session_/Storage/storage.module.css @@ -1,8 +1,7 @@ .button { - padding: 2px 6px; + padding: 3px 6px; cursor: pointer; - width: 60px; border-radius: 3px; color: $gray-light; &:hover { @@ -14,4 +13,4 @@ font-size: 12px; margin-right: 5px; -} \ No newline at end of file +}