Skip to content

Commit

Permalink
Auto-load modules on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbrittain committed Sep 4, 2024
1 parent 5f10cfe commit c7e1c0c
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion electron-app/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Event = unknown;
type Query = Record<string, unknown>;
export type Query = Record<string, unknown>;

export type TerminalAPI = {
sendData: (data: string) => void;
Expand Down
Binary file modified nodemapper/.yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion nodemapper/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Event = unknown;
type Query = Record<string, unknown>;
export type Query = Record<string, unknown>;

export type TerminalAPI = {
sendData: (data: string) => void;
Expand Down
14 changes: 9 additions & 5 deletions nodemapper/src/gui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ import React from 'react';

import { ThemeOptions, ThemeProvider, createTheme } from '@mui/material/styles';
import { ErrorBoundary } from 'react-error-boundary';
import { settingsReadStoreConfig } from 'redux/actions';
import { ReadStoreConfig } from 'redux/middleware/settings';
import { builderGetRemoteModules } from 'redux/actions';
import { useAppDispatch, useAppSelector } from 'redux/store/hooks';
import { errorHandler } from './ErrorHandling/Error';

import Navigation from './Navigation';

// Startup
let started = false;
const startup = () => {
const startup = (dispatch) => {
started = true;
const dispatch = useAppDispatch();
dispatch(settingsReadStoreConfig());
ReadStoreConfig(dispatch).finally(() => {
// Runs irrespective of return status of store read, but must wait for it to complete
dispatch(builderGetRemoteModules());
});
};

const App = () => {
if (!started) startup();
const dispatch = useAppDispatch();
if (!started) startup(dispatch);
const dark_mode = useAppSelector((state) => state.settings.dark_mode);

const themeOptions: ThemeOptions = {
Expand Down
2 changes: 1 addition & 1 deletion nodemapper/src/gui/Builder/components/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Button from '@mui/material/Button';
import 'reactflow/dist/style.css';
import ContextMenu from './ContextMenu';
import './flow.css';
import { Query } from 'api';
import * as styles from './flow.module.css';

import dagre from 'dagre';
Expand Down Expand Up @@ -92,7 +93,6 @@ const getLayoutedElements = (nodes: Node[], edges: Edge[], direction = 'LR') =>
};

const builderAPI = window.builderAPI;
type Query = Record<string, unknown>;

const proOptions = {
hideAttribution: true,
Expand Down
23 changes: 13 additions & 10 deletions nodemapper/src/gui/Builder/components/RepoBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BuilderEngine from './BuilderEngine';

import { faEllipsisVertical } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import RefreshIcon from '@mui/icons-material/Refresh';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import CircularProgress from '@mui/material/CircularProgress';
Expand Down Expand Up @@ -155,17 +156,8 @@ const RepoBrowser = () => {
>
<Stack direction="column" sx={{ height: '100%' }}>
<Paper sx={{ p: 1 }}>
<Button
id="btnBuilderGetModuleList"
className="btn"
onClick={btnGetModuleList}
variant="outlined"
fullWidth
>
LOAD MODULES
</Button>
<Grid container spacing={0}>
<Grid item xs={10}>
<Grid item xs={8}>
<TextField
id="repo-filter-freetext"
name="repo-filter-freetext"
Expand All @@ -187,6 +179,17 @@ const RepoBrowser = () => {
<FontAwesomeIcon icon={faEllipsisVertical} />
</Button>
</Grid>
<Grid item xs={2}>
<Button
id="btnBuilderGetModuleList"
variant="outlined"
sx={{ height: '100%', minWidth: '5px' }}
onClick={btnGetModuleList}
fullWidth
>
<RefreshIcon />
</Button>
</Grid>
</Grid>
{showSearchOptions && (
<Box
Expand Down
3 changes: 1 addition & 2 deletions nodemapper/src/gui/Builder/components/TrayItemWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import styled from '@emotion/styled';
import * as React from 'react';
import { Query } from 'api';
import { IModulesListEntry } from 'redux/reducers/builder';
import { wranglename } from './Flow';

type Query = Record<string, unknown>;

export interface TrayItemWidgetProps {
model: IModulesListEntry;
color?: string;
Expand Down
8 changes: 6 additions & 2 deletions nodemapper/src/redux/middleware/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import {
} from 'gui/Builder/components/Flow';
import { Edge } from 'reactflow';

import { Query } from 'api';
import { IModulesList } from 'redux/reducers/builder';
import { IRepo } from 'redux/reducers/settings';

type Query = Record<string, unknown>;

const builderAPI = window.builderAPI;
const runnerAPI = window.runnerAPI;

Expand Down Expand Up @@ -710,6 +709,11 @@ const GetRemoteModules = async ({
dispatchModulesList,
repo,
}: IGetRemoteModules) => {
// Backend check
if (builderAPI === undefined) {
console.error('builderAPI is undefined');
return;
}
// Get list of remote modules
dispatchString(builderUpdateStatusText('Loading modules...'));
dispatchBool(builderSetModulesLoading(true));
Expand Down
2 changes: 1 addition & 1 deletion nodemapper/src/redux/middleware/newmodule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { newmoduleEnvCondaSearchUpdatePackageList, newmoduleUpdateResult } from 'redux/actions';
import { IState } from 'redux/reducers';
import { Query } from 'api';

type Query = Record<string, unknown>;
const newmoduleAPI = window.newmoduleAPI;

export const newmoduleMiddleware = ({ getState, dispatch }) => {
Expand Down
3 changes: 1 addition & 2 deletions nodemapper/src/redux/middleware/runner.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { displayGetFolderInfo } from 'redux/actions';
import { IState } from 'redux/reducers';
import { Query } from 'api';

import { runnerUpdateStatusText } from 'redux/actions';

type Query = Record<string, unknown>;

const runnerAPI = window.runnerAPI;

export const runnerMiddleware = ({ getState, dispatch }) => {
Expand Down
5 changes: 2 additions & 3 deletions nodemapper/src/redux/middleware/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { settingsUpdateSettings } from 'redux/actions';
import { IState } from 'redux/reducers';
import { Query } from 'api';

const settingsAPI = window.settingsAPI;

Expand All @@ -26,8 +27,6 @@ export const settingsMiddleware = ({ getState, dispatch }) => {
};
};

type Query = Record<string, unknown>;

interface IPayloadRecord {
payload: Query;
type: string;
Expand All @@ -51,7 +50,7 @@ const WriteStoreConfig = async (state) => {
};

// Read persistent state from electron frontend
const ReadStoreConfig = async (dispatch: TPayloadRecord) => {
export const ReadStoreConfig = async (dispatch: TPayloadRecord): Promise<void> => {
if (settingsAPI === undefined) return;
let local_config = {};
try {
Expand Down

0 comments on commit c7e1c0c

Please sign in to comment.