From: Daniel Kutyła Date: Tue, 18 Jan 2022 15:38:09 +0000 (+0100) Subject: 18207: Added common icon and removed code duplication X-Git-Tag: 2.4.0~17^2~1 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/89a4eb90454f12be703f711279d0867781013631 18207: Added common icon and removed code duplication Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx index de694e08..3646fc8f 100644 --- a/src/components/data-table/data-table.tsx +++ b/src/components/data-table/data-table.tsx @@ -10,6 +10,7 @@ import { DataTableDefaultView } from '../data-table-default-view/data-table-defa import { DataTableFilters } from '../data-table-filters/data-table-filters-tree'; import { DataTableFiltersPopover } from '../data-table-filters/data-table-filters-popover'; import { countNodes } from 'models/tree'; +import { ProjectIcon } from 'components/icon/icon'; import { SvgIconProps } from '@material-ui/core/SvgIcon'; import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward'; @@ -49,10 +50,8 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ background: theme.palette.background.paper }, loader: { - top: '50%', left: '50%', - marginTop: '-15px', - marginLeft: '-15px', + marginLeft: '-84px', position: 'absolute' }, noItemsInfo: { @@ -98,9 +97,12 @@ export const DataTable = withStyles(styles)( { - this.props.working ? - null : - items.map(this.renderBodyRow) + this.props.working ? +
+ +
: items.map(this.renderBodyRow) }
diff --git a/src/views-components/data-explorer/data-explorer.tsx b/src/views-components/data-explorer/data-explorer.tsx index 7d804a1c..900ab94e 100644 --- a/src/views-components/data-explorer/data-explorer.tsx +++ b/src/views-components/data-explorer/data-explorer.tsx @@ -21,12 +21,27 @@ interface Props { working?: boolean; } -const mapStateToProps = (state: RootState, { id, working: parentWorking }: Props) => { +let data: any[] = []; +let href: string = ''; + +const mapStateToProps = (state: RootState, { id }: Props) => { const progress = state.progressIndicator.find(p => p.id === id); - const working = (progress && progress.working) || parentWorking; + const dataExplorerState = getDataExplorer(state.dataExplorer, id); const currentRoute = state.router.location ? state.router.location.pathname : ''; const currentItemUuid = currentRoute === '/workflows' ? state.properties.workflowPanelDetailsUuid : state.detailsPanel.resourceUuid; - return { ...getDataExplorer(state.dataExplorer, id), working, paperKey: currentRoute, currentItemUuid }; + + let loading = false; + + if (dataExplorerState.items.length > 0 && data === dataExplorerState.items && href !== window.location.href) { + loading = true + } else { + href = window.location.href; + data = dataExplorerState.items; + } + + const working = (progress && progress.working) || loading; + + return { ...dataExplorerState, working, paperKey: currentRoute, currentItemUuid }; }; const mapDispatchToProps = () => { diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index 892d2819..178a96aa 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -137,31 +137,19 @@ interface ProjectPanelDataProps { type ProjectPanelProps = ProjectPanelDataProps & DispatchProp & WithStyles & RouteComponentProps<{ id: string }>; -let data: any[] = []; -let href: string = ''; export const ProjectPanel = withStyles(styles)( connect((state: RootState) => ({ currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties), resources: state.resources, - userUuid: state.auth.user!.uuid, - dataExplorerItems: state.dataExplorer?.projectPanel.items, + userUuid: state.auth.user!.uuid }))( class extends React.Component { render() { - const { classes, dataExplorerItems } = this.props; - let loading = false; - - if (dataExplorerItems.length > 0 && data === dataExplorerItems && href !== window.location.href) { - loading = true - } else { - href = window.location.href; - data = dataExplorerItems; - } + const { classes } = this.props; return