From 826e0e00bb911dcf285d60cef2004561785f9f03 Mon Sep 17 00:00:00 2001 From: alfredorubin96 <103421036+alfredorubin96@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:09:08 +0100 Subject: [PATCH] Fix hiding column prefix (#695) * fixing missing feature that was hiding columns starting with __ * removing test console log * removing code smell * removing code smell * fixing test * Bumped outdated version numbers --------- Co-authored-by: Alfred Rubin Co-authored-by: Niels de Jong --- .github/workflows/master-deployment.yml | 4 ++-- Dockerfile | 2 +- cypress/e2e/start_page.cy.js | 2 +- package.json | 2 +- src/chart/table/TableChart.tsx | 18 +++++++++++++----- src/extensions/forms/chart/NeoForm.tsx | 2 -- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/master-deployment.yml b/.github/workflows/master-deployment.yml index 06c1d1087..46e256031 100644 --- a/.github/workflows/master-deployment.yml +++ b/.github/workflows/master-deployment.yml @@ -79,7 +79,7 @@ jobs: context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKER_HUB_LABS_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_LABS_USERNAME }}/neodash:2.3.5 + tags: ${{ secrets.DOCKER_HUB_LABS_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_LABS_USERNAME }}/neodash:2.4.0 build-docker-legacy: needs: build-test runs-on: neodash-runners @@ -103,7 +103,7 @@ jobs: context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_USERNAME }}/neodash:2.3.5 + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_USERNAME }}/neodash:2.4.0 deploy-gallery: runs-on: neodash-runners strategy: diff --git a/Dockerfile b/Dockerfile index c31f51ae8..ebe0f16ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,4 +43,4 @@ USER nginx EXPOSE $NGINX_PORT HEALTHCHECK cmd curl --fail "http://localhost:$NGINX_PORT" || exit 1 -LABEL version="2.3.5" +LABEL version="2.4.0" diff --git a/cypress/e2e/start_page.cy.js b/cypress/e2e/start_page.cy.js index 9a35f11bf..c1d2b5694 100644 --- a/cypress/e2e/start_page.cy.js +++ b/cypress/e2e/start_page.cy.js @@ -87,7 +87,7 @@ describe('NeoDash E2E Tests', () => { cy.get('main .react-grid-item:eq(2) .MuiDataGrid-columnHeaders', { timeout: WAITING_TIME }) .should('contain', 'title') .and('contain', 'released') - .and('contain', '__id'); + .and('not.contain', '__id'); cy.get('main .react-grid-item:eq(2) .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('have.length', 5); cy.get('main .react-grid-item:eq(2) .MuiDataGrid-footerContainer').should('contain', '1–5 of 8'); cy.get('main .react-grid-item:eq(2) .MuiDataGrid-footerContainer button[aria-label="Go to next page"]').click(); diff --git a/package.json b/package.json index 197cb446b..fe9b6b4b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neodash", - "version": "2.3.5", + "version": "2.4.0", "description": "NeoDash - Neo4j Dashboard Builder", "neo4jDesktop": { "apiVersion": "^1.2.0" diff --git a/src/chart/table/TableChart.tsx b/src/chart/table/TableChart.tsx index 6553bac8f..b0cd07242 100644 --- a/src/chart/table/TableChart.tsx +++ b/src/chart/table/TableChart.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { DataGrid, GridColumnVisibilityModel } from '@mui/x-data-grid'; import { ChartProps } from '../Chart'; import { @@ -27,6 +27,7 @@ import { getCheckboxes, hasCheckboxes, updateCheckBoxes } from './TableActionsHe const TABLE_HEADER_HEIGHT = 32; const TABLE_FOOTER_HEIGHT = 62; const TABLE_ROW_HEIGHT = 52; +const HIDDEN_COLUMN_PREFIX = '__'; const theme = createTheme({ typography: { @@ -87,10 +88,6 @@ export const NeoTableChart = (props: ChartProps) => { const useStyles = generateClassDefinitionsBasedOnRules(styleRules); const classes = useStyles(); - if (props.records == null || props.records.length == 0 || props.records[0].keys == null) { - return <>No data, re-run the report.; - } - const tableRowHeight = compact ? TABLE_ROW_HEIGHT / 2 : TABLE_ROW_HEIGHT; const pageSizeReducer = compact ? 3 : 1; @@ -162,6 +159,17 @@ export const NeoTableChart = (props: ChartProps) => { ); }); + useEffect(() => { + const hiddenColumns = Object.assign( + {}, + ...columns.filter((x) => x.field.startsWith(HIDDEN_COLUMN_PREFIX)).map((x) => ({ [x.field]: false })) + ); + setColumnVisibilityModel(hiddenColumns); + }, [records]); + + if (props.records == null || props.records.length == 0 || props.records[0].keys == null) { + return <>No data, re-run the report.; + } const getTransposedRows = (records) => { // Skip first key const rowKeys = [...records[0].keys]; diff --git a/src/extensions/forms/chart/NeoForm.tsx b/src/extensions/forms/chart/NeoForm.tsx index 9919cd795..cb5662a77 100644 --- a/src/extensions/forms/chart/NeoForm.tsx +++ b/src/extensions/forms/chart/NeoForm.tsx @@ -31,8 +31,6 @@ const NeoForm = (props: ChartProps) => { const [status, setStatus] = React.useState(FormStatus.DATA_ENTRY); const [formResults, setFormResults] = React.useState([]); const debouncedRunCypherQuery = useCallback(debounce(props.queryCallback, RUN_QUERY_DELAY_MS), []); - console.log(settings.hasSubmitButton); - console.log(hasSubmitButton); // Helper function to force a refresh on all reports that depend on the form. // All reports that use one or more parameters used in the form will be refreshed.