Skip to content

Commit

Permalink
Merge branch 'develop' into feat/pxp-11315-explorer-page-redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
craigrbarnes committed Jan 23, 2025
2 parents 36083c0 + f3461f3 commit b67ce4c
Show file tree
Hide file tree
Showing 65 changed files with 8,060 additions and 2,787 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
node_modules
packages/core/node_modules
packages/core/dist
packages/frontend/node_modules
packages/frontend/dist
packages/tools/node_modules
packages/tools/dist
packages/sampleCommons/node_modules
packages/sampleCommons/.next
packages/sampleCommons/.swc
.git
.nx
docs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ RUN addgroup --system --gid 1001 nextjs && \

# Copy built artifacts from builder
COPY --from=builder --chown=nextjs:nextjs /gen3 .

RUN apk add --no-cache bash
# Set environment variables
ENV PORT=3000
ENV NODE_ENV=production
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"packages": ["packages/*"],
"version": "0.10.68"
"version": "0.10.74"
}
9,438 changes: 7,061 additions & 2,377 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
"lint": "lerna run lint",
"lint-fix": "eslint . --fix",
"oxlint": "oxlint .",
"build": "lerna run build --include-dependencies",
"build": "lerna run build --include-dependencies --stream",
"build:pkg": "lerna run build --include-dependencies --stream --ignore=@gen3/samplecommons",
"build:clean": "lerna run build:clean",
"compile": "lerna run compile",
"dev": "lerna run dev",
"dev:watch": " lerna watch -- lerna run dev --scope=\\$LERNA_PACKAGE_NAME",
"start": "lerna run start",
"start": "lerna run start",
"build:start": "npm run build && npm run start",
"setProxy" : "(cd ./packages/tools/localDev/nginx/; ./configureNginx.sh -d $npm_config_domain)",
"test": "npm run test --workspaces",
"test:int": "npm run test:int --workspaces",
"test:all": "npm run test:all --workspaces"
Expand All @@ -35,21 +37,21 @@
"@grafana/faro-react": "^1.9.1",
"@grafana/faro-web-sdk": "^1.9.1",
"@grafana/faro-web-tracing": "^1.9.1",
"@mantine/core": "^7.14.3",
"@mantine/form": "^7.14.3",
"@mantine/hooks": "^7.14.3",
"@mantine/modals": "^7.14.3",
"@mantine/dates": "^7.14.3",
"@mantine/notifications": "^7.14.3",
"jsonpath-plus": "^10.2.0",
"@mantine/core": "^7.16.0",
"@mantine/dates": "^7.16.0",
"@mantine/form": "^7.16.0",
"@mantine/hooks": "^7.16.0",
"@mantine/modals": "^7.16.0",
"@mantine/notifications": "^7.16.0",
"classnames": "^2.3.1",
"colorette": "^2.0.20",
"cookies-next": "4.3.0",
"isomorphic-fetch": "^3.0.0",
"jsonpath-plus": "^10.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-responsive-carousel": "^3.2.23",
"url-join": "^5.0.0",
"cookies-next": "4.3.0"
"url-join": "^5.0.0"
},
"devDependencies": {
"@axe-core/react": "^4.10.0",
Expand Down Expand Up @@ -93,8 +95,8 @@
"rollup-plugin-swc3": "^0.11.2",
"rollup-swc-preserve-directives": "^0.7.0",
"terser-webpack-plugin": "^5.3.10",
"ts-json-schema-generator": "^2.3.0",
"ts-jest": "^29.2.5",
"ts-json-schema-generator": "^2.3.0",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.6.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@gen3/core",
"version": "0.10.68",
"version": "0.10.74",
"author": "CTDS",
"description": "Core module for gen3 frontend. Provides an interface for interacting with the gen3 API and a redux store for managing state.",
"description": "Core module for Gen3.2. Packages provides an interface for interacting with the gen3 API and a redux store for managing state.",
"license": "Apache-2.0",
"engines": {
"npm": ">=10.8.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import terser from '@rollup/plugin-terser';
import dts from 'rollup-plugin-dts';
import json from '@rollup/plugin-json';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
Expand All @@ -22,6 +21,9 @@ const globals = {
flat: 'flat',
papaparse: 'papaparse',
'redux-persist': 'reduxPersist',
'redux-persist/integration/react': 'redux-persist-integration-react',
'redux-persist/lib/storage/createWebStorage':
'redux-persist-createWebStorage',
'cookies-next': 'cookies-next',
queue: 'queue',
idb: 'idb',
Expand Down
32 changes: 26 additions & 6 deletions packages/core/src/features/cohort/cohortSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export interface CohortState {
cohort: Cohort;
}

export const EmptyCohort: Cohort = {
id: 'default',
name: 'Filters',
filters: {},
modified_datetime: new Date().toISOString(),
};

const initialCohortState: CohortState = {
cohort: {
id: 'default',
name: 'Filters',
filters: {},
modified_datetime: new Date().toISOString(),
},
cohort: { ...EmptyCohort },
};

interface UpdateFilterParams {
Expand All @@ -34,6 +36,10 @@ interface SetFilterParams {
filters: FilterSet;
}

interface SetAllIndexFiltersParams {
filters: IndexedFilterSet;
}

interface RemoveFilterParams {
index: string;
field: string;
Expand Down Expand Up @@ -98,6 +104,18 @@ export const cohortSlice = createSlice({
},
};
},
setCohortIndexFilters: (
state: Draft<CohortState>,
action: PayloadAction<SetAllIndexFiltersParams>,
) => {
return {
cohort: {
...state.cohort,
filters: { ...action.payload.filters },
},
};
},

// removes a filter to the cohort filter set at the given index
removeCohortFilter: (
state: Draft<CohortState>,
Expand Down Expand Up @@ -149,6 +167,7 @@ export const cohortSlice = createSlice({
export const {
updateCohortFilter,
setCohortFilter,
setCohortIndexFilters,
removeCohortFilter,
clearCohortFilters,
} = cohortSlice.actions;
Expand Down Expand Up @@ -181,6 +200,7 @@ export const selectIndexedFilterByName = (
};

const EmptyFilterSet: FilterSet = { mode: 'and', root: {} };

/**
* Select a filter from the index.
* returns undefined.
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/features/cohort/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
selectCurrentCohort,
updateCohortFilter,
setCohortFilter,
setCohortIndexFilters,
removeCohortFilter,
clearCohortFilters,
} from './cohortSlice';
Expand All @@ -23,6 +24,7 @@ export {
cohortReducer,
updateCohortFilter,
setCohortFilter,
setCohortIndexFilters,
removeCohortFilter,
clearCohortFilters,
};
4 changes: 4 additions & 0 deletions packages/core/src/features/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EmptyWorkspaceStatusResponse,
selectWorkspaceStatusFromService,
selectWorkspaceStatus,
selectPaymodelStatus,
} from './workspaceApi';
import {
setActiveWorkspaceId,
Expand All @@ -19,6 +20,7 @@ import {
selectActiveWorkspaceId,
selectActiveWorkspaceStatus,
selectRequestedWorkspaceStatus,
selectRequestedWorkspaceStatusTimestamp,
} from './workspaceSlice';

export * from './types';
Expand All @@ -43,4 +45,6 @@ export {
selectWorkspaceStatusFromService,
selectRequestedWorkspaceStatus,
selectWorkspaceStatus,
selectRequestedWorkspaceStatusTimestamp,
selectPaymodelStatus,
};
12 changes: 12 additions & 0 deletions packages/core/src/features/workspace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export interface WorkspacePayModelResponse {
noPayModel: boolean;
}

/**
* Workspace Pod status
*/
export enum WorkspaceStatus {
Launching = 'Launching',
Running = 'Running',
Expand All @@ -52,6 +55,15 @@ export enum WorkspaceStatus {
StatusError = 'Status Error',
}

/**
* requested state of pod, either by user or workspace monitor
*/
export enum RequestedWorkspaceStatus {
Launch = 'Launch',
Terminate = 'Terminate',
Unset = 'Unset', // same
}

export enum PodConditionType {
PodScheduled = 'PodScheduled',
Initialized = 'Initialized',
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/features/workspace/workspaceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const workspacesApi = WorkspaceWithTags.injectEndpoints({
return workspaceStatus;
}

// TODO: try to find out IF this is code is required
// TODO: Find out IF this is code is required
const workspaceStatusData =
workspaceStatus.data as unknown as WorkspaceStatusResponse;

Expand Down Expand Up @@ -176,3 +176,11 @@ export const selectWorkspaceStatus = createSelector(
workspaceStatusSelector,
(status) => status?.data?.status ?? WorkspaceStatus.NotFound,
);

export const paymodelStatusSelector =
workspacesApi.endpoints.getWorkspacePayModels.select();

export const selectPaymodelStatus = createSelector(
paymodelStatusSelector,
(status) => status,
);
27 changes: 21 additions & 6 deletions packages/core/src/features/workspace/workspaceSlice.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { CoreState } from '../../reducers';
import { type WorkspaceId, WorkspaceStatus } from './types';
import {
RequestedWorkspaceStatus,
type WorkspaceId,
WorkspaceStatus,
} from './types';
import { getCurrentTimestamp } from '../../utils/time';

export const NO_WORKSPACE_ID = 'none';

export type RequestedWorkspaceStatus = 'Launching' | 'Terminating' | 'NotSet';
// the requested state for a workspace
export interface WorkspaceState {
id: string;
status: WorkspaceStatus;
requestedStatus: RequestedWorkspaceStatus;
status: WorkspaceStatus; // current status of the workspace
requestedStatus: RequestedWorkspaceStatus; // the goal state for the workspace
requestedStatusTimestamp: number;
}

const initialState: WorkspaceState = {
id: NO_WORKSPACE_ID,
status: WorkspaceStatus.NotFound,
requestedStatus: 'NotSet',
requestedStatus: RequestedWorkspaceStatus.Unset,
requestedStatusTimestamp: getCurrentTimestamp(),
};

const slice = createSlice({
Expand All @@ -38,7 +45,11 @@ const slice = createSlice({
state,
action: PayloadAction<RequestedWorkspaceStatus>,
) => {
return { ...state, requestedStatus: action.payload };
return {
...state,
requestedStatus: action.payload,
requestedStatusTimestamp: getCurrentTimestamp(),
};
},
setActiveWorkspace: (_state, action: PayloadAction<WorkspaceState>) => {
return { ...action.payload };
Expand All @@ -65,3 +76,7 @@ export const selectActiveWorkspaceStatus = (
export const selectRequestedWorkspaceStatus = (
state: CoreState,
): RequestedWorkspaceStatus => state.activeWorkspace.requestedStatus;

export const selectRequestedWorkspaceStatusTimestamp = (
state: CoreState,
): number => state.activeWorkspace.requestedStatusTimestamp;
12 changes: 11 additions & 1 deletion packages/core/src/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import React, { PropsWithChildren } from 'react';
import { Provider } from 'react-redux';
import { coreStore } from './store';
import { persistStore } from 'redux-persist';
import { PersistGate } from 'redux-persist/integration/react';

const persistor = persistStore(coreStore);

export const CoreProvider: React.FC<Record<string, unknown>> = ({
children,
}: PropsWithChildren) => {
return <Provider store={coreStore}>{children}</Provider>;
return (
<Provider store={coreStore}>
<PersistGate loading={null} persistor={persistor}>
{children}
</PersistGate>
</Provider>
);
};
4 changes: 1 addition & 3 deletions packages/core/src/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import { modalReducer } from './features/modals/modalsSlice';
import { cohortReducer } from './features/cohort';
import { dataLibrarySelectionReducer } from './features/dataLibrary';
import { activeWorkspaceReducer } from './features/workspace/workspaceSlice';

import { guppyApiReducer, guppyApiSliceReducerPath } from './features/guppy';
import {
userAuthApiReducerPath,
userAuthApiReducer,
} from './features/user/userSliceRTK';

import { guppyApiReducer, guppyApiSliceReducerPath } from './features/guppy';

export const rootReducer = combineReducers({
gen3Services: gen3ServicesReducer,
user: userReducer,
Expand Down
29 changes: 29 additions & 0 deletions packages/core/src/storage-persist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint @typescript-eslint/no-unused-vars: 0 */
// Credit to: https://github.com/vercel/next.js/discussions/15687
import createWebStorage from 'redux-persist/lib/storage/createWebStorage';

const createNoopStorage = () => {
return {
getItem(_key: string) {
return Promise.resolve(null);
},
setItem(_key: string, value: string) {
return Promise.resolve(value);
},
removeItem(_key: string) {
return Promise.resolve();
},
};
};

const storage =
typeof window !== 'undefined'
? createWebStorage('local')
: createNoopStorage();

export const sessionStorage =
typeof window !== 'undefined'
? createWebStorage('session')
: createNoopStorage();

export default storage;
Loading

0 comments on commit b67ce4c

Please sign in to comment.