forked from openclarity/apiclarity
-
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.
Merge pull request openclarity#66 from eti/MAN-8851_UI_Implement_colu…
…mn_selection_in_event_table MAN-8851_UI_Implement_column_selection_in_event_table
- Loading branch information
Showing
10 changed files
with
359 additions
and
186 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
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
28 changes: 28 additions & 0 deletions
28
ui/src/components/Table/ColumnsSelectPanel/columns-select-panel.scss
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,28 @@ | ||
@import 'utils/scss_variables.module.scss'; | ||
|
||
.columns-select-panel-container { | ||
height: 100%; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
width: 230px; | ||
padding: 15px; | ||
background-color: $color-white; | ||
border: 1px solid $color-grey-lighter; | ||
overflow-y: scroll; | ||
z-index: 3; | ||
|
||
.header-columns-wrapper { | ||
.header-column-title { | ||
text-transform: uppercase; | ||
color: $color-main; | ||
margin-bottom: 10px; | ||
font-weight: bold; | ||
font-size: 9px; | ||
} | ||
.header-columns { | ||
margin-left: 30px; | ||
margin-bottom: 20px; | ||
} | ||
} | ||
} |
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,81 @@ | ||
import React, { useCallback, useEffect, useRef } from 'react'; | ||
import { isEmpty } from 'lodash'; | ||
import Checkbox from 'components/Checkbox'; | ||
|
||
import './columns-select-panel.scss'; | ||
|
||
const ColumnsList = ({columns}) => ( | ||
<React.Fragment> | ||
{ | ||
columns.map(column => { | ||
const {checked, onChange} = column.getToggleHiddenProps(); | ||
const {id, alwaysShow} = column; | ||
|
||
return ( | ||
<Checkbox | ||
key={id} | ||
name={id} | ||
checked={checked} | ||
value={id} | ||
title={column.render('Header')} | ||
onChange={onChange} | ||
disabled={alwaysShow} | ||
small | ||
/> | ||
); | ||
}) | ||
} | ||
</React.Fragment> | ||
); | ||
|
||
const ColumnsListWithHeaders = ({headerColumnNames, columns}) => ( | ||
<React.Fragment> | ||
{ | ||
headerColumnNames.map(headerName => ( | ||
<div key={headerName} className="header-columns-wrapper"> | ||
<div className="header-column-title">{headerName}</div> | ||
<div className="header-columns"> | ||
<ColumnsList columns={columns.filter(column => column.parent.Header === headerName)} /> | ||
</div> | ||
</div> | ||
)) | ||
} | ||
</React.Fragment> | ||
); | ||
|
||
const ColumnsSelectPanel = ({columns, headerColumnNames, onClose, columnsIconClassName}) => { | ||
const columnsPanelRef = useRef(); | ||
|
||
const handleClick = useCallback(({target}) => { | ||
if (target.parentElement.classList.contains(columnsIconClassName)) { | ||
//clicked the columns icon | ||
return; | ||
} | ||
|
||
if (columnsPanelRef.current.contains(target)) { | ||
//clicked inside the panel | ||
return; | ||
} | ||
|
||
onClose(); | ||
}, [onClose, columnsIconClassName]); | ||
|
||
useEffect(() => { | ||
document.addEventListener("mousedown", handleClick); | ||
|
||
return () => { | ||
document.removeEventListener("mousedown", handleClick); | ||
}; | ||
}, [handleClick]); | ||
|
||
return ( | ||
<div className="columns-select-panel-container" ref={columnsPanelRef}> | ||
{ | ||
isEmpty(headerColumnNames) ? <ColumnsList columns={columns} /> : | ||
<ColumnsListWithHeaders columns={columns} headerColumnNames={headerColumnNames} /> | ||
} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ColumnsSelectPanel; |
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