Skip to content
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

Remote Sidebar Import + Fixes #571

Merged
merged 22 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@codemirror/lang-markdown": "^6.1.1",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.12.3",
"@mui/styles": "^5.12.3",
"@mui/x-data-grid": "5.17.26",
Expand All @@ -61,6 +60,7 @@
"@sentry/webpack-plugin": "^2.5.0",
"babel-runtime": "^6.26.0",
"chroma-js": "^2.4.2",
"circular-dependency-plugin": "^5.2.2",
BennuFire marked this conversation as resolved.
Show resolved Hide resolved
"classnames": "^2.3.1",
"d3-scale-chromatic": "^3.0.0",
"dayjs": "^1.11.7",
Expand Down
66 changes: 40 additions & 26 deletions src/application/Application.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useEffect } from 'react';
import NeoNotificationModal from '../modal/NotificationModal';
import React, { Suspense, useEffect } from 'react';
import NeoWelcomeScreenModal from '../modal/WelcomeScreenModal';
import { connect } from 'react-redux';
import {
Expand Down Expand Up @@ -39,17 +38,20 @@ import {
import { resetDashboardState } from '../dashboard/DashboardActions';
import { NeoDashboardPlaceholder } from '../dashboard/placeholder/DashboardPlaceholder';
import NeoConnectionModal from '../modal/ConnectionModal';
import Dashboard from '../dashboard/Dashboard';
import NeoAboutModal from '../modal/AboutModal';
import { NeoUpgradeOldDashboardModal } from '../modal/UpgradeOldDashboardModal';

import { loadDashboardThunk } from '../dashboard/DashboardThunks';
import { NeoLoadSharedDashboardModal } from '../modal/LoadSharedDashboardModal';
import { downloadComponentAsImage } from '../chart/ChartUtils';
import NeoReportHelpModal from '../modal/ReportHelpModal';
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
import { resetSessionStorage } from '../sessionStorage/SessionStorageActions';
import { getDashboardTheme } from '../dashboard/DashboardSelectors';

const NeoUpgradeOldDashboardModal = React.lazy(() => import('../modal/UpgradeOldDashboardModal'));
const NeoLoadSharedDashboardModal = React.lazy(() => import('../modal/LoadSharedDashboardModal'));
const NeoReportHelpModal = React.lazy(() => import('../modal/ReportHelpModal'));
const NeoNotificationModal = React.lazy(() => import('../modal/NotificationModal'));
const NeoAboutModal = React.lazy(() => import('../modal/AboutModal'));
const Dashboard = React.lazy(() => import('../dashboard/Dashboard'));

/**
* This is the main application component for NeoDash.
* It contains:
Expand Down Expand Up @@ -122,16 +124,20 @@ const Application = ({
className={`n-bg-palette-neutral-bg-default n-h-screen n-w-screen n-flex n-flex-col n-overflow-hidden`}
>
{connected ? (
<Dashboard
onDownloadDashboardAsImage={(_) => downloadComponentAsImage(ref)}
onAboutModalOpen={onAboutModalOpen}
resetApplication={resetApplication}
></Dashboard>
<Suspense fallback=''>
<Dashboard
onDownloadDashboardAsImage={(_) => downloadComponentAsImage(ref)}
onAboutModalOpen={onAboutModalOpen}
resetApplication={resetApplication}
></Dashboard>
</Suspense>
) : (
<NeoDashboardPlaceholder></NeoDashboardPlaceholder>
)}
{/* TODO - move all models into a pop-ups (or modals) component. */}
<NeoAboutModal open={aboutModalOpen} handleClose={onAboutModalClose} getDebugState={getDebugState} />
<Suspense fallback=''>
<NeoAboutModal open={aboutModalOpen} handleClose={onAboutModalClose} getDebugState={getDebugState} />
</Suspense>
<NeoConnectionModal
open={connectionModalOpen}
dismissable={connected}
Expand All @@ -154,19 +160,27 @@ const Application = ({
onAboutModalOpen={onAboutModalOpen}
resetDashboard={resetDashboard}
></NeoWelcomeScreenModal>
<NeoUpgradeOldDashboardModal
open={oldDashboard}
text={oldDashboard}
loadDashboard={loadDashboard}
clearOldDashboard={clearOldDashboard}
/>
<NeoLoadSharedDashboardModal
shareDetails={shareDetails}
onResetShareDetails={onResetShareDetails}
onConfirmLoadSharedDashboard={onConfirmLoadSharedDashboard}
/>
<NeoReportHelpModal open={reportHelpModalOpen} handleClose={onReportHelpModalClose} />
<NeoNotificationModal></NeoNotificationModal>
<Suspense fallback=''>
<NeoUpgradeOldDashboardModal
open={oldDashboard}
text={oldDashboard}
loadDashboard={loadDashboard}
clearOldDashboard={clearOldDashboard}
/>
</Suspense>
<Suspense fallback=''>
<NeoLoadSharedDashboardModal
shareDetails={shareDetails}
onResetShareDetails={onResetShareDetails}
onConfirmLoadSharedDashboard={onConfirmLoadSharedDashboard}
/>
</Suspense>
<Suspense fallback=''>
<NeoReportHelpModal open={reportHelpModalOpen} handleClose={onReportHelpModalClose} />
</Suspense>
<Suspense fallback=''>
<NeoNotificationModal></NeoNotificationModal>
</Suspense>
</div>
);
};
Expand Down
3 changes: 0 additions & 3 deletions src/application/ApplicationThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
loadDashboardThunk,
upgradeDashboardVersion,
} from '../dashboard/DashboardThunks';
import { setExtensionSidebarOpen } from '../extensions/sidebar/state/SidebarActions';
import { createNotificationThunk } from '../page/PageThunks';
import { runCypherQuery } from '../report/ReportQueryRunner';
import {
Expand Down Expand Up @@ -394,8 +393,6 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
)
);
dispatch(setConnectionModalOpen(false));
// TODO - generalize this, close all drawer-based extensions on app startup.
dispatch(setExtensionSidebarOpen(false));

// Auto-upgrade the dashboard version if an old version is cached.
if (state.dashboard && state.dashboard.version !== NEODASH_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion src/card/CardReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
UPDATE_REPORT_DATABASE,
} from './CardActions';
import { TOGGLE_CARD_SETTINGS } from './CardActions';
import { createUUID } from '../dashboard/DashboardThunks';
import { createUUID } from '../utils/uuid';

const update = (state, mutations) => Object.assign({}, state, mutations);

Expand Down
23 changes: 12 additions & 11 deletions src/card/settings/CardSettingsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EXTENSIONS_CARD_SETTINGS_COMPONENT,
getExtensionCardSettingsComponents,
} from '../../extensions/ExtensionConfig';
import { update } from '../../utils/ObjectManipulation';

const NeoCardSettingsContent = ({
pagenumber,
Expand Down Expand Up @@ -42,7 +43,8 @@ const NeoCardSettingsContent = ({
}, [query]);

const reportTypes = getReportTypes(extensions);
const SettingsComponent = reportTypes[type] && reportTypes[type].settingsComponent;
const report = reportTypes[type];
const SettingsComponent = report && report.settingsComponent;

function hasExtensionComponents() {
return (
Expand Down Expand Up @@ -85,13 +87,13 @@ const NeoCardSettingsContent = ({
<NeoCodeEditorComponent
value={queryText}
editable={true}
language={reportTypes[type] && reportTypes[type].inputMode ? reportTypes[type].inputMode : 'cypher'}
language={report?.inputMode || 'cypher'}
onChange={(value) => {
updateCypherQuery(value);
}}
placeholder={`Enter Cypher here...`}
/>
<div style={DEFAULT_CARD_SETTINGS_HELPER_TEXT_STYLE}>{reportTypes[type] && reportTypes[type].helperText}</div>
<div style={DEFAULT_CARD_SETTINGS_HELPER_TEXT_STYLE}>{report?.helperText || ''}</div>
</>
);

Expand All @@ -105,20 +107,20 @@ const NeoCardSettingsContent = ({
onChange: (newValue) =>
newValue && onTypeUpdate(Object.keys(reportTypes).find((key) => reportTypes[key].label === newValue.value)),
options: Object.keys(reportTypes).map((option) => ({
label: reportTypes[type] && reportTypes[option].label,
value: reportTypes[type] && reportTypes[option].label,
label: report && reportTypes[option].label,
value: report && reportTypes[option].label,
})),
value: {
label: reportTypes[type] && reportTypes[type].label,
value: reportTypes[type] && reportTypes[type].label,
label: report && report.label,
value: report && report.label,
},
menuPortalTarget: document.querySelector('body'),
}}
fluid
style={{ marginLeft: '0px', marginRight: '10px', width: '47%', maxWidth: '200px', display: 'inline-block' }}
/>

{reportTypes[type] && reportTypes[type].disableDatabaseSelector == undefined ? (
{report?.disableDatabaseSelector == undefined ? (
<Dropdown
id='databaseSelector'
label='Database'
Expand Down Expand Up @@ -146,11 +148,10 @@ const NeoCardSettingsContent = ({
<br />
<br />
{/* Allow for overriding the code box with a custom component */}
{reportTypes[type] && reportTypes[type].settingsComponent ? (
{report && report.settingsComponent ? (
<SettingsComponent
type={type}
onReportSettingUpdate={onReportSettingUpdate}
settings={reportSettings}
settings={update({ helperText: report.helperText, inputMode: report.inputMode }, reportSettings)}
nielsdejong marked this conversation as resolved.
Show resolved Hide resolved
database={database}
query={query}
onQueryUpdate={onQueryUpdate}
Expand Down
1 change: 0 additions & 1 deletion src/card/settings/CardSettingsFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { getReportTypes } from '../../extensions/ExtensionUtils';
import { RULE_BASED_REPORT_ACTIONS_CUSTOMIZATIONS } from '../../extensions/actions/ActionsRuleCreationModal';
import NeoCustomReportActionsModal from '../../extensions/actions/ActionsRuleCreationModal';
import PlayCircleOutlineIcon from '@mui/icons-material/PlayCircleOutline';
import { AdjustmentsHorizontalIconOutline, SparklesIconOutline } from '@neo4j-ndl/react/icons';
import { IconButton, Switch } from '@neo4j-ndl/react';

Expand Down
18 changes: 5 additions & 13 deletions src/card/settings/custom/CardSettingsContentPropertySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@ import { QueryStatus, runCypherQuery } from '../../../report/ReportQueryRunner';
import { Neo4jContext, Neo4jContextState } from 'use-neo4j/dist/neo4j.context';
import { Autocomplete, debounce, TextField } from '@mui/material';
import NeoField from '../../../component/field/Field';
import { getReportTypes } from '../../../extensions/ExtensionUtils';
import { Dropdown } from '@neo4j-ndl/react';
import NeoCodeEditorComponent from '../../../component/editor/CodeEditorComponent';

const NeoCardSettingsContentPropertySelect = ({
query,
type,
database,
settings,
extensions,
onReportSettingUpdate,
onQueryUpdate,
}) => {
const NeoCardSettingsContentPropertySelect = ({ query, database, settings, onReportSettingUpdate, onQueryUpdate }) => {
const { driver } = useContext<Neo4jContextState>(Neo4jContext);
if (!driver) {
throw new Error(
Expand Down Expand Up @@ -199,7 +190,8 @@ const NeoCardSettingsContentPropertySelect = ({
// TODO: since this component is only rendered for parameter select, this is technically not needed
const parameterSelectTypes = ['Node Property', 'Relationship Property', 'Free Text', 'Custom Query', 'Date Picker'];
const selectedType = settings.type ? settings.type : 'Node Property';
const reportTypes = getReportTypes(extensions);
const helperText = settings && settings.helperText ? settings.helperText : '';
const inputMode = settings && settings.inputMode ? settings.inputMode : 'cypher';
const overridePropertyDisplayName =
settings.overridePropertyDisplayName !== undefined ? settings.overridePropertyDisplayName : false;

Expand All @@ -213,7 +205,7 @@ const NeoCardSettingsContentPropertySelect = ({
return (
<div>
<p style={{ color: 'grey', fontSize: 12, paddingLeft: '5px', border: '1px solid lightgrey', marginTop: '0px' }}>
{reportTypes[type].helperText}
{helperText}
</p>
<Dropdown
id='type'
Expand Down Expand Up @@ -265,7 +257,7 @@ const NeoCardSettingsContentPropertySelect = ({
<NeoCodeEditorComponent
value={queryText}
editable={true}
language={reportTypes[type] && reportTypes[type].inputMode ? reportTypes[type].inputMode : 'cypher'}
language={inputMode}
onChange={(value) => {
debouncedQueryUpdate(value);
setQueryText(value);
Expand Down
3 changes: 2 additions & 1 deletion src/card/view/CardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { CardContent } from '@mui/material';
import NeoCodeEditorComponent from '../../component/editor/CodeEditorComponent';

import { CARD_FOOTER_HEIGHT, CARD_HEADER_HEIGHT } from '../../config/CardConfig';
import { extensionEnabled, getReportTypes } from '../../extensions/ExtensionUtils';
import { getReportTypes } from '../../extensions/ExtensionUtils';
import NeoCodeViewerComponent from '../../component/editor/CodeViewerComponent';
import { NeoReportWrapper } from '../../report/ReportWrapper';
import { identifyStyleRuleParameters } from '../../extensions/styling/StyleRuleEvaluator';
import { ThemeProvider } from '@mui/material/styles';
import { lightTheme, darkHeaderTheme, luma } from '../../component/theme/Themes';
import { IconButton } from '@neo4j-ndl/react';
import { PlayCircleIconSolid } from '@neo4j-ndl/react/icons';
import { extensionEnabled } from '../../utils/ReportUtils';

const NeoCardView = ({
id,
Expand Down
17 changes: 11 additions & 6 deletions src/card/view/CardViewHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect } from 'react';
import { Badge, CardHeader, Dialog, DialogContent, DialogTitle, TextField, Tooltip } from '@mui/material';
import debounce from 'lodash/debounce';
import { useCallback } from 'react';
import { Close, ThirteenMp } from '@mui/icons-material';
import ReactMarkdown from 'react-markdown';
import gfm from 'remark-gfm';
import { replaceDashboardParameters } from '../../chart/ChartUtils';
Expand All @@ -16,6 +15,7 @@ import {
ShrinkIcon,
CameraIconSolid,
InformationCircleIconOutline,
XMarkIconOutline,
} from '@neo4j-ndl/react/icons';
import { createTheme, ThemeProvider } from '@mui/material/styles';

Expand Down Expand Up @@ -81,7 +81,13 @@ const NeoCardViewHeader = ({
<tr>
{editable ? (
<td>
<IconButton className='n-mb-3 n-relative -n-left-3 drag-handle' clean size='medium' aria-label={'drag'}>
<IconButton
className='n-mb-3 n-relative -n-left-3 drag-handle'
clean
size='medium'
aria-label={'drag'}
onClick={() => {}}
>
<DragIcon />
</IconButton>
</td>
Expand Down Expand Up @@ -172,7 +178,7 @@ const NeoCardViewHeader = ({
<>
<Dialog
maxWidth={'lg'}
open={descriptionModalOpen == true}
open={descriptionModalOpen}
onClose={() => setDescriptionModalOpen(false)}
aria-labelledby='form-dialog-title'
>
Expand All @@ -182,10 +188,9 @@ const NeoCardViewHeader = ({
onClick={() => setDescriptionModalOpen(false)}
style={{ padding: '3px', float: 'right' }}
aria-label={'rect badge'}
clean
>
<Badge overlap='rectangular' badgeContent={''}>
<Close />
</Badge>
<XMarkIconOutline />
</IconButton>
</DialogTitle>
<DialogContent style={{ minWidth: '400px' }}>
Expand Down
3 changes: 2 additions & 1 deletion src/chart/ChartUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ export const downloadComponentAsImage = (ref) => {

import { QueryResult, Record as Neo4jRecord } from 'neo4j-driver';
import { RenderSubValue } from '../report/ReportRecordProcessing';
import { DEFAULT_NODE_LABELS } from '../config/ReportConfig';

/**
* Function to cast a value received from the Neo4j Driver to its TS native type
Expand Down Expand Up @@ -442,3 +441,5 @@ export function getSelectionBasedOnFields(fields, oldSelection = {}, autoAssignS
});
return selection;
}

export const DEFAULT_NODE_LABELS = ['name', 'title', 'label', 'id', 'uid', '(label)'];
3 changes: 2 additions & 1 deletion src/chart/SettingsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { extensionEnabled, getReportTypes } from '../extensions/ExtensionUtils';
import { getReportTypes } from '../extensions/ExtensionUtils';
import { useStyleRules } from '../extensions/styling/StyleRuleEvaluator';
import { extensionEnabled } from '../utils/ReportUtils';

/**
* Gets the user specified settings and merges it with the defaults from ReportConfig.tsx.
Expand Down
2 changes: 1 addition & 1 deletion src/chart/bar/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { ResponsiveBar, ResponsiveBarCanvas } from '@nivo/bar';
import React, { useEffect } from 'react';
import { NoDrawableDataErrorMessage } from '../../component/editor/CodeViewerComponent';
import { getD3ColorsByScheme } from '../../config/ColorConfig';
import { extensionEnabled } from '../../extensions/ExtensionUtils';
import { evaluateRulesOnDict, useStyleRules } from '../../extensions/styling/StyleRuleEvaluator';
import { ChartProps } from '../Chart';
import { convertRecordObjectToString, recordToNative } from '../ChartUtils';
import { themeNivo } from '../Utils';
import { extensionEnabled } from '../../utils/ReportUtils';

/**
* Embeds a BarReport (from Nivo) into NeoDash.
Expand Down
Loading