-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web/add dataset drawer #2672
Web/add dataset drawer #2672
Changes from 7 commits
01f225c
15de5d7
90d11b2
a3c3a42
af2359c
d426a16
047f287
a34870f
7790bc1
45120ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,36 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import * as Redux from 'redux' | ||
import { Box, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material' | ||
import { Chip } from '@mui/material' | ||
import { | ||
Accordion, | ||
Box, | ||
Card, | ||
CardContent, | ||
Divider, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableRow, | ||
} from '@mui/material' | ||
import { Chip, Drawer } from '@mui/material' | ||
import { Field, Run, Tag } from '../../types/api' | ||
import { IState } from '../../store/reducers' | ||
import { connect, useSelector } from 'react-redux' | ||
import { createTheme } from '@mui/material/styles' | ||
import { fetchJobFacets, fetchTags, resetFacets } from '../../store/actionCreators' | ||
import { stopWatchDuration } from '../../helpers/time' | ||
import { useTheme } from '@emotion/react' | ||
import AccordionDetails from '@mui/material/AccordionDetails' | ||
import AccordionSummary from '@mui/material/AccordionSummary' | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore' | ||
import MQTooltip from '../core/tooltip/MQTooltip' | ||
import MqCode from '../core/code/MqCode' | ||
import MqEmpty from '../core/empty/MqEmpty' | ||
import MqJsonView from '../core/json-view/MqJsonView' | ||
import MqText from '../core/text/MqText' | ||
import React, { FunctionComponent, useEffect } from 'react' | ||
import React, { FunctionComponent, useEffect, useState } from 'react' | ||
import ReadMoreIcon from '@mui/icons-material/ReadMore' | ||
import RunStatus from '../jobs/RunStatus' | ||
|
||
export interface DispatchProps { | ||
|
@@ -56,8 +71,9 @@ const formatColumnTags = (tags: string[], tag_desc: Tag[]) => { | |
label={tag} | ||
size='small' | ||
style={{ | ||
display: 'inline', | ||
display: 'row', | ||
marginRight: index < tags.length - 1 ? theme.spacing(1) : 0, | ||
marginTop: 3, | ||
}} | ||
/> | ||
</MQTooltip> | ||
|
@@ -71,6 +87,10 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | |
const { datasetFields, facets, run, jobFacets, fetchJobFacets, resetFacets } = props | ||
const i18next = require('i18next') | ||
|
||
const [open, setOpen] = useState(false) | ||
const [selectedKey, setSelectedKey] = useState<string | undefined>(undefined) | ||
const theme = createTheme(useTheme()) | ||
|
||
useEffect(() => { | ||
run && fetchJobFacets(run.id) | ||
run && fetchTags() | ||
|
@@ -85,6 +105,18 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | |
) | ||
|
||
const tagData = useSelector((state: IState) => state.tags.tags) | ||
const handleOpen = (key: string) => { | ||
setOpen(true) | ||
setSelectedKey(key) | ||
} | ||
|
||
const handleClose = () => { | ||
setOpen(false) | ||
} | ||
|
||
const selectedField = datasetFields.find((field) => field.name === selectedKey) | ||
const selectedFieldTags = selectedField?.tags || [] | ||
const selectedFieldDesc = selectedField?.description || 'No Description' | ||
|
||
return ( | ||
<Box> | ||
|
@@ -95,44 +127,97 @@ const DatasetInfo: FunctionComponent<DatasetInfoProps> = (props) => { | |
/> | ||
)} | ||
{datasetFields.length > 0 && ( | ||
<Table size='small'> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.name')} | ||
</MqText> | ||
</TableCell> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.type')} | ||
</MqText> | ||
</TableCell> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.description')} | ||
<> | ||
<Table size='small'> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.name')} | ||
</MqText> | ||
</TableCell> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.type')} | ||
</MqText> | ||
</TableCell> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.description')} | ||
</MqText> | ||
</TableCell> | ||
<TableCell align='left'></TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{datasetFields.map((field) => { | ||
return ( | ||
<TableRow key={field.name}> | ||
<TableCell align='left'>{field.name}</TableCell> | ||
<TableCell align='left'>{field.type}</TableCell> | ||
<TableCell align='left'>{field.description || 'no description'}</TableCell> | ||
<TableCell> | ||
<ReadMoreIcon | ||
onClick={() => handleOpen(field.name)} | ||
sx={{ align: 'Right' }} | ||
></ReadMoreIcon> | ||
</TableCell> | ||
</TableRow> | ||
) | ||
})} | ||
</TableBody> | ||
</Table> | ||
<Drawer | ||
elevation={0} | ||
anchor='right' | ||
open={open} | ||
onClose={handleClose} | ||
sx={{ zIndex: 1300 }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you reference a variable for this in the theme? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah cool will move this out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool will fix this up. |
||
PaperProps={{ | ||
sx: { | ||
width: 400, | ||
backgroundColor: theme.palette.background.paper, | ||
border: `2px dashed ${theme.palette.secondary.main}`, | ||
p: 1, | ||
}, | ||
}} | ||
> | ||
<Card> | ||
<CardContent sx={{ backgroundColor: theme.palette.background.paper }}> | ||
<MqText heading bottomMargin> | ||
{selectedKey} | ||
</MqText> | ||
</TableCell> | ||
<TableCell align='left'> | ||
<MqText subheading inline> | ||
{i18next.t('dataset_info_columns.tags')} | ||
</CardContent> | ||
</Card> | ||
<Divider /> | ||
<Card> | ||
<CardContent sx={{ backgroundColor: theme.palette.background.paper }}> | ||
<MqText bottomMargin>{selectedFieldDesc}</MqText> | ||
</CardContent> | ||
</Card> | ||
<Accordion elevation={0}> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
sx={{ | ||
backgroundColor: theme.palette.background.paper, | ||
}} | ||
> | ||
<MqText bold bottomMargin> | ||
Tags | ||
</MqText> | ||
</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{datasetFields.map((field) => { | ||
return ( | ||
<TableRow key={field.name}> | ||
<TableCell align='left'>{field.name}</TableCell> | ||
<TableCell align='left'>{field.type}</TableCell> | ||
<TableCell align='left'>{field.description || 'no description'}</TableCell> | ||
<TableCell align='left'>{formatColumnTags(field.tags, tagData)}</TableCell> | ||
</TableRow> | ||
) | ||
})} | ||
</TableBody> | ||
</Table> | ||
</AccordionSummary> | ||
<AccordionDetails | ||
sx={{ | ||
backgroundColor: theme.palette.background.paper, | ||
}} | ||
> | ||
{selectedFieldTags.length > 0 | ||
? formatColumnTags(selectedFieldTags, tagData) | ||
: 'No Tags'} | ||
</AccordionDetails> | ||
</Accordion> | ||
</Drawer> | ||
</> | ||
)} | ||
{facets && ( | ||
<Box mt={2}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used in one place, so you shouldn't need a wrapper function.