-
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.
[Th2-5208] Add ability to cancel notebooks, option to change default …
…view type of result group,#display-table field, option to view last N results of Notebook, file path and timestamp types (#571) * fix parameters type parsing * add ability to cancel launch and proccess failed notebook request * created DisplayTeble component * created ParametersRow component * added option to change viewType of group * added remove node to store * change position of Results Result * add display-table view type * update launchNotebook and getResults api * change display when none node is selected * change split behaviour on selection * added filepath and timestamp parameters
- Loading branch information
Showing
21 changed files
with
1,191 additions
and
323 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
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,56 @@ | ||
import React from 'react'; | ||
|
||
const shownCapacity = 50; | ||
|
||
const DisplayTable = ({ value }: { value: string[][] | undefined }) => { | ||
const [shownSize, setShownSize] = React.useState(shownCapacity); | ||
if (!value) return <div className='display-table-error'>#display-table is undefined</div>; | ||
|
||
const header = value[0]; | ||
const rows = value.slice(1); | ||
|
||
return ( | ||
<div className='display-table'> | ||
<table style={{ gridTemplateColumns: `repeat(${header.length}, 1fr) 16px` }}> | ||
<thead> | ||
<tr> | ||
{header.map((key, index) => ( | ||
<th key={index}>{key}</th> | ||
))} | ||
<th style={{ width: '16px' }}></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{rows.slice(0, shownSize).map((row, index) => ( | ||
<tr key={index}> | ||
{row.slice(0, header.length).map((val, ind) => ( | ||
<td key={ind}>{typeof val === 'string' ? `"${val}"` : String(val)}</td> | ||
))} | ||
{row.length < header.length && | ||
Array(header.length - row.length) | ||
.fill('') | ||
.map((_val, ind) => <td key={ind}></td>)} | ||
<td style={{ width: '16px' }}> | ||
{header.length < row.length && ( | ||
<div | ||
className='display-table-info' | ||
title={`Not included extra cells: ${JSON.stringify(row.slice(header.length))}`} | ||
/> | ||
)} | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
{shownSize < rows.length && ( | ||
<button | ||
onClick={() => setShownSize(shownSize + shownCapacity)} | ||
className='actions-list__load-button'> | ||
Show More | ||
</button> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DisplayTable; |
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,112 @@ | ||
/** **************************************************************************** | ||
* Copyright 2020-2020 Exactpro (Exactpro Systems Limited) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************** */ | ||
|
||
import React, { useRef, useState } from 'react'; | ||
import { AnimatePresence, motion } from 'framer-motion'; | ||
import { TreeViewType } from '../../models/JSONSchema'; | ||
import { useOutsideClickListener } from '../../hooks'; | ||
import { createBemElement } from '../../helpers/styleCreators'; | ||
import { MessageViewType } from '../../models/EventMessage'; | ||
|
||
export type LeafToolsConfig = { | ||
activeViewType: TreeViewType | MessageViewType; | ||
toggleViewType: (viewType: any) => void; | ||
viewTypes: TreeViewType[] | MessageViewType[]; | ||
}; | ||
|
||
const LeafTools = ({ activeViewType, toggleViewType, viewTypes }: LeafToolsConfig) => { | ||
const [isViewMenuOpen, setIsViewMenuOpen] = useState(false); | ||
const rootRef = useRef<HTMLDivElement>(null); | ||
|
||
useOutsideClickListener( | ||
rootRef, | ||
(e: MouseEvent) => { | ||
if (e.target instanceof Element && rootRef.current && !rootRef.current.contains(e.target)) { | ||
setIsViewMenuOpen(false); | ||
} | ||
}, | ||
isViewMenuOpen, | ||
); | ||
|
||
return ( | ||
<div className='message-card-tools' ref={rootRef}> | ||
<div | ||
className={createBemElement( | ||
'message-card-tools', | ||
'button', | ||
isViewMenuOpen ? 'active' : null, | ||
)} | ||
onClick={e => { | ||
e.stopPropagation(); | ||
setIsViewMenuOpen(isOpen => !isOpen); | ||
}}> | ||
<div className='message-card-tools__ellipsis' style={{ display: 'block' }} /> | ||
</div> | ||
<ToolsPopup isOpen={isViewMenuOpen}> | ||
<div className='message-card-tools__controls-group'> | ||
{viewTypes.map(viewType => { | ||
const iconClassName = createBemElement('message-card-tools', 'icon', viewType); | ||
const indicatorClassName = createBemElement( | ||
'message-card-tools', | ||
'indicator', | ||
viewType === activeViewType ? 'active' : null, | ||
); | ||
|
||
return ( | ||
<div | ||
title={viewType} | ||
className='message-card-tools__item' | ||
key={viewType} | ||
onClick={e => { | ||
e.stopPropagation(); | ||
toggleViewType(viewType); | ||
}}> | ||
<span className='message-card-tools__item-title'>{viewType}</span> | ||
<div className={iconClassName} /> | ||
<div className={indicatorClassName} /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</ToolsPopup> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LeafTools; | ||
|
||
interface ToolsPopupProps { | ||
isOpen: boolean; | ||
children: React.ReactNode; | ||
} | ||
|
||
function ToolsPopup({ isOpen, children }: ToolsPopupProps) { | ||
return ( | ||
<AnimatePresence> | ||
{isOpen && ( | ||
<motion.div | ||
className='message-card-tools__controls' | ||
style={{ transformOrigin: 'top' }} | ||
initial={{ opacity: 0, scale: 0.5 }} | ||
animate={{ opacity: 1, scale: 1 }} | ||
exit={{ opacity: 0, scale: 0.5 }} | ||
transition={{ duration: 0.15, ease: 'easeOut' }}> | ||
{children} | ||
</motion.div> | ||
)} | ||
</AnimatePresence> | ||
); | ||
} |
Oops, something went wrong.