Skip to content

Commit

Permalink
Merge pull request #20 from neo4j-labs/feature/needle2.3.0
Browse files Browse the repository at this point in the history
Eslint formatting and fixes
  • Loading branch information
msenechal authored Jan 16, 2024
2 parents c9abe4e + c2aa93e commit 6fb99ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/components/ConnectionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import { Button, Dialog, TextInput, Dropdown } from '@neo4j-ndl/react';
import { useState } from 'react';
import { setDriver } from '../utils/Driver';

export default function ConnectionModal({ open, setOpenConnection, setConnectionStatus }) {
export default function ConnectionModal({
open,
setOpenConnection,
setConnectionStatus,
}: {
open: boolean;
setOpenConnection: (arg: boolean) => void;
setConnectionStatus: (status: boolean) => void;
}) {
const protocols = ['neo4j', 'neo4j+s', 'neo4j+ssc', 'bolt', 'bolt+s', 'bolt+ssc'];
const [selectedProtocol, setSelectedProtocol] = useState<string>('neo4j');
const [hostname, setHostname] = useState<string>('localhost');
Expand Down
11 changes: 7 additions & 4 deletions src/context/ThemeWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { createContext, useMemo, useState } from 'react';
import { createContext, useMemo, useState, ReactNode } from 'react';
import { NeedleThemeProvider, useMediaQuery } from '@neo4j-ndl/react';
import QuickStarter from '../components/QuickStarter';

export const ThemeWrapperContext = createContext({
toggleColorMode: () => {},
colorMode: 'light' as string,
});

export default function ThemeWrapper() {
interface ThemeWrapperProps {
children: ReactNode; // Accept children as a prop
}

export default function ThemeWrapper({ children }: ThemeWrapperProps) {
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
const [mode, setMode] = useState<string>(prefersDarkMode ? 'dark' : 'light');
const [usingPreferredMode, setUsingPreferredMode] = useState<boolean>(true);
Expand Down Expand Up @@ -39,7 +42,7 @@ export default function ThemeWrapper() {
return (
<ThemeWrapperContext.Provider value={themeWrapperUtils}>
<NeedleThemeProvider theme={mode as 'light' | 'dark' | undefined} wrapperProps={{ isWrappingChildren: true }}>
<QuickStarter />
{children}
</NeedleThemeProvider>
</ThemeWrapperContext.Provider>
);
Expand Down
8 changes: 4 additions & 4 deletions src/utils/Driver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import neo4j, { Driver } from 'neo4j-driver';

let driver: Driver;

export async function setDriver(connectionURI, username, password) {
export async function setDriver(connectionURI: string, username: string, password: string) {
try {
driver = neo4j.driver(connectionURI, neo4j.auth.basic(username, password));
const serverInfo = await driver.getServerInfo();
await driver.getServerInfo();
localStorage.setItem(
'neo4j.connection',
JSON.stringify({ uri: connectionURI, user: username, password: password })
);
return true;
} catch (err) {
console.error(`Connection error\n${err}\nCause: ${err.cause}`);
console.error(`Connection error\n${err}\nCause: ${(err as Error)}`);
return false;
}
}
Expand All @@ -23,7 +23,7 @@ export async function disconnect() {
await driver.close();
return true;
} catch (err) {
console.error(`Disconnection error\n${err}\nCause: ${err.cause}`);
console.error(`Disconnection error\n${err}\nCause: ${(err as Error)}`);
return false;
}
}

0 comments on commit 6fb99ed

Please sign in to comment.