Skip to content

Commit ae0a792

Browse files
authored
Merge pull request #156 from BioAnalyticResource/kobi-NavigatorView
Navigator View Implementation + Additions to tutorial.md(to be changed post-routing) + generalized view/gene switching functionality in Views folder(to be removed post-routing but still needed here)
2 parents 0d651d6 + 9840f70 commit ae0a792

15 files changed

Lines changed: 5264 additions & 1918 deletions

.eslintrc.cjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
'react/react-in-jsx-scope': 'off',
2727
'react/jsx-uses-react': 'off',
2828
'simple-import-sort/imports': 'error',
29-
'simple-import-sort/exports': 'error'
29+
'simple-import-sort/exports': 'error',
3030
},
3131
'overrides': [
3232
{
@@ -55,5 +55,10 @@ module.exports = {
5555
]
5656
}
5757
}
58-
]
58+
],
59+
"settings": {
60+
"react": {
61+
"version": "detect"
62+
}
63+
}
5964
}

Eplant/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ExperimentEFP from './views/ExperimentEFP'
77
import FallbackView from './views/FallbackView'
88
import GeneInfoView from './views/GeneInfoView'
99
import GetStartedView from './views/GetStartedView'
10+
import NavigatorView from './views/NavigatorViewer'
1011
import PlantEFP from './views/PlantEFP'
1112
import PublicationViewer from './views/PublicationViewer'
1213
import WorldEFP from './views/WorldEFP'
@@ -35,6 +36,7 @@ const userViews = [
3536
ExperimentEFP,
3637
WorldEFP,
3738
ChromosomeViewer,
39+
NavigatorView,
3840
]
3941

4042
// List of views that are used to lookup a view by id

Eplant/state/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function atomWithStorage<T>(
9595

9696
// TODO: This should probably be removed
9797
// Atom with storage that doesn't persist when persistAtom is set to false
98-
function atomWithOptionalStorage<T>(
98+
export function atomWithOptionalStorage<T>(
9999
key: string,
100100
initialValue: T,
101101
serialize: (value: T) => string = JSON.stringify,

Eplant/tutorial.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
- [How to create a new `View`](#how-to-create-a-new-view)
3333
- [Steps to Update `config.ts`](#steps-to-update-configts)
3434
- [Example](#example)
35+
- [View Switching Functionality](#view-switching-functionality)
36+
- [Documentation and Commenting Style](#documentation-and-commenting-style)
37+
- [Eslint Code Standards](#eslint-code-standards)
38+
- [Local Testing Requirements](#local-testing-requirements)
3539
- [Eplant2](#eplant2)
3640
- [API](#api)
3741

@@ -366,6 +370,72 @@ const genericViews = [GetStartedView, FallbackView, NewView]
366370
const views = [...genericViews, ...userViews]
367371
```
368372

373+
#### View Switching Functionality
374+
375+
If your new view has function to swap to a different view and/or gene available on ePlant, you may benefit from the generalized view switching component file (name tbd).
376+
377+
To utilize the component:
378+
379+
1. Import createViewSwitchProvider into your index file and export it:
380+
381+
```
382+
export const ViewSwitchProvider = createViewSwitchProvider();
383+
```
384+
385+
2. Import your exported provider into your view's main component and wrap your component in the view's return statement:
386+
387+
```
388+
const App = () => {
389+
return (
390+
<ViewSwitchProvider>
391+
<YourComponent />
392+
</ViewSwitchProvider>
393+
);
394+
};
395+
```
396+
397+
3. Import and use useViewSwitch in your main component whenever you want to invoke the switching functionality. For example: `switchViewAndGene('Cell eFP', geneName);`
398+
399+
There are 3 main swithing functions you can invoke based on needs.
400+
401+
```
402+
/** Function to switch view only */
403+
switchViewOnly: (viewId: string) => Promise<void>;
404+
405+
/** Function to switch gene only */
406+
switchGeneOnly: (geneName: string, speciesUrl?: string) => Promise<void>;
407+
408+
/** Function to switch both view and gene */
409+
switchViewAndGene: (viewId: string, geneName: string, speciesUrl?: string) => Promise<void>;
410+
```
411+
412+
## Documentation and Commenting Style
413+
414+
It is important to maintain a common standard for commenting code and documentation. If you want to make contributions to the project, we ask that you follow the TSdoc(typescript) commenting style. As an example this includes adding function/class headers and comments as seen below:
415+
416+
```
417+
/**
418+
* Extracts the primary gene identifier from the API URL
419+
*
420+
* @param url - The complete API URL containing query parameters
421+
* @returns The primary gene identifier, or an empty string not found
422+
*
423+
* Uses regex to find the primaryGene parameter in the URL
424+
*/
425+
function extractPrimaryGene(url: string): string {
426+
const match = url.match(/primaryGene=([^&]+)/);
427+
return match ? match[1] : "";
428+
}
429+
```
430+
431+
## ESlint Code Standards
432+
433+
The codebase relies on ESlint to handle automatic checking for issues with the code. With ESlint, you will not need to manually parse all of your code for accurate documentation, imports order, etc. When running ePlant locally in a browser, if there are any outstanding issues, it will be made known to you automatically. A common way to fix any issues without much thought is to run `npx eslint . --fix`. The `.` can be replaced if you do not want to check and fix every file in your current working directory. Documentation issues are not as big of a concern as others and your local site may work as normal, but to keep in line with our standards, please resolve any issues and warnings before making a pull request.
434+
435+
## Local Testing Requirements
436+
437+
To allow ESlint to work, and to run the site locally you are required to install Node.js and NPM on your system. Once installed, you can activate a local connection to the site using `npm run dev` and connecting to the generated web access point.
438+
369439
## Eplant2
370440

371441
https://bar.utoronto.ca/eplant/

Eplant/util/ErrorBoundary/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export default class ErrorBoundary extends Component<
88
this.state = { hasError: false }
99
}
1010
componentDidCatch(error: Error, info: ErrorInfo) {
11+
console.log(
12+
'Error caught by ErrorBoundary:',
13+
error.message,
14+
info.componentStack
15+
)
1116
this.setState({ hasError: true })
1217
}
1318
render() {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { styled } from '@mui/material'
2+
3+
export default styled((props) => {
4+
return (
5+
<svg
6+
xmlns='http://www.w3.org/2000/svg'
7+
width='20'
8+
height='20'
9+
viewBox='0 0 100 100'
10+
{...props}
11+
>
12+
<path d='M39.4 20.5C20.9 24.5 7 38 7 52c0 14.1 14 27.6 32.8 31.6C68.5 89.6 98 73.6 98 52c0-14.1-14-27.6-32.8-31.6-8.2-1.7-17.7-1.7-25.8.1zm9.5 17.1c4.4.9 9.1 5.5 9.1 8.9 0 8.8-17.3 12.7-25 5.5-4-3.7-4-7.3 0-11 3.9-3.7 9.1-4.7 15.9-3.4z' />
13+
</svg>
14+
)
15+
})(({ theme }) => ({
16+
fill: theme.palette.text.primary,
17+
}))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { styled } from '@mui/material'
2+
3+
export default styled((props) => (
4+
<svg
5+
width='16'
6+
height='16'
7+
viewBox='0 0 24 24'
8+
xmlns='http://www.w3.org/2000/svg'
9+
{...props}
10+
>
11+
<path d='M12 8.46143C11.6951 8.46143 11.4026 8.58272 11.1868 8.79834C10.9712 9.01397 10.8501 9.30658 10.8501 9.61157V17.1751C10.8501 17.5859 11.0692 17.9656 11.425 18.171C11.781 18.3764 12.2193 18.3764 12.5751 18.171C12.9309 17.9656 13.15 17.5859 13.15 17.1751V9.61157C13.15 9.30661 13.0289 9.01397 12.8133 8.79834C12.5976 8.58272 12.305 8.46143 12 8.46143Z' />
12+
<path d='M13.1557 6.25229C13.1557 5.83875 12.9351 5.45656 12.577 5.24981C12.2189 5.04303 11.7776 5.04303 11.4195 5.24981C11.0614 5.45658 10.8408 5.83873 10.8408 6.25229C10.8408 6.66585 11.0615 7.04802 11.4195 7.25478C11.7776 7.46155 12.2189 7.46155 12.577 7.25478C12.9351 7.04801 13.1557 6.66585 13.1557 6.25229Z' />
13+
<path d='M12 0.5C8.95001 0.5 6.02501 1.71156 3.86823 3.86823C1.71156 6.02491 0.5 8.95016 0.5 12C0.5 15.0498 1.71156 17.975 3.86823 20.1318C6.02491 22.2884 8.95016 23.5 12 23.5C15.05 23.5 17.975 22.2884 20.1318 20.1318C22.2884 17.9751 23.5 15.0498 23.5 12C23.4967 8.95099 22.284 6.02796 20.1281 3.87218C17.972 1.71609 15.0492 0.503351 11.9998 0.500099L12 0.5ZM12 21.2003C9.55993 21.2003 7.22001 20.2309 5.49469 18.5055C3.76927 16.7803 2.7999 14.4402 2.7999 12.0002C2.7999 9.56022 3.76927 7.22001 5.49469 5.49488C7.2201 3.76946 9.56003 2.8001 12 2.8001C14.4401 2.8001 16.7802 3.76946 18.5053 5.49488C20.2307 7.2201 21.2001 9.56022 21.2001 12.0002C21.1972 14.4393 20.2271 16.7779 18.5023 18.5026C16.7776 20.2274 14.4392 21.1975 11.9999 21.2004L12 21.2003Z' />
14+
</svg>
15+
))(({ theme }) => ({
16+
fill: theme.palette.text.primary,
17+
}))
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { styled } from '@mui/material'
2+
export default styled((props) => {
3+
return (
4+
<svg
5+
width='16'
6+
height='16'
7+
viewBox='0 0 24 24'
8+
xmlns='http://www.w3.org/2000/svg'
9+
{...props}
10+
>
11+
<path d='M20.2573 0.500008C18.0687 0.496985 15.941 1.37872 14.4035 2.99125C14.4034 2.99125 14.4034 2.99144 14.4034 2.99144C12.5067 4.98218 11.7899 7.80009 12.4965 10.4301C11.7218 11.733 11.1167 13.1451 10.767 14.7081C10.6077 14.3831 10.4356 14.0661 10.2527 13.756C10.8507 11.4709 10.2219 9.02883 8.57598 7.30109V7.30128C8.57598 7.30109 8.57579 7.30109 8.57579 7.30109C7.23324 5.89301 5.37531 5.12312 3.46446 5.12593C2.92944 5.12668 2.3904 5.18789 1.85726 5.31278L1.87294 5.31108V5.31089C1.74125 5.33866 1.61939 5.40101 1.51983 5.49151C1.42026 5.58201 1.34658 5.69744 1.30634 5.82592C0.571027 8.19455 1.18164 10.7752 2.89956 12.5778C2.89956 12.5778 2.89975 12.5778 2.89975 12.578C4.48277 14.2383 6.78243 15.0109 9.03982 14.6765C9.81668 16.0351 10.3368 17.5229 10.4706 19.2325V22.7645L10.4708 22.7643C10.4708 22.9654 10.5505 23.1581 10.6928 23.3003C10.8348 23.4424 11.0276 23.5223 11.2286 23.5223C11.4298 23.5223 11.6225 23.4424 11.7646 23.3003C11.9068 23.1581 11.9867 22.9654 11.9867 22.7643V16.7747C12.1458 14.7333 12.7744 12.9617 13.71 11.347C16.3223 11.7616 18.9925 10.8781 20.8251 8.9567L20.8249 8.95689V8.9567C22.7923 6.89263 23.4911 3.93872 22.6492 1.22732V1.22751C22.609 1.09904 22.5353 0.983598 22.4357 0.893101C22.3362 0.802603 22.2143 0.740254 22.0826 0.712294L22.0983 0.714183C21.4877 0.571164 20.8701 0.501073 20.2574 0.500125L20.2573 0.500008ZM20.2548 2.01599C20.6083 2.01637 20.9637 2.04547 21.3179 2.10366C21.8042 4.16942 21.2185 6.34681 19.7279 7.91097C18.4043 9.29903 16.5353 10.0211 14.6388 9.92213C15.7714 8.35589 17.1743 6.91869 18.6728 5.48981L18.6726 5.49C18.8181 5.35133 18.9026 5.16032 18.9073 4.95947C18.9122 4.75846 18.8368 4.56385 18.6982 4.41836C18.5436 4.25606 18.3252 4.17067 18.1015 4.18484C17.9237 4.19618 17.7556 4.26986 17.6265 4.39266C16.2473 5.70764 14.8984 7.07848 13.7478 8.58731C13.6991 6.92584 14.3112 5.28632 15.5009 4.03751C16.7465 2.73105 18.475 2.01388 20.2549 2.01615L20.2548 2.01599ZM3.46746 6.64177C4.96966 6.63969 6.428 7.24504 7.47885 8.34706C8.40931 9.32381 8.92074 10.5829 8.9574 11.8774C8.00575 10.669 6.91316 9.56318 5.80074 8.50256V8.50275C5.6717 8.37975 5.50355 8.30607 5.32577 8.29473C5.10208 8.28056 4.88367 8.36615 4.72912 8.52825C4.59045 8.67373 4.51507 8.86832 4.51998 9.06937C4.5247 9.27039 4.60916 9.46121 4.75463 9.5999C5.99005 10.7779 7.14609 11.9587 8.09286 13.2349C6.5612 13.2602 5.06771 12.6545 3.99741 11.5319C2.75673 10.2302 2.2604 8.42625 2.64128 6.70548C2.91674 6.66373 3.19294 6.64238 3.46766 6.642L3.46746 6.64177Z' />
12+
</svg>
13+
)
14+
})(({ theme }) => ({
15+
fill: theme.palette.text.primary,
16+
}))
17+
18+
// This icon is used in the dropdown view selection menu
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { styled } from '@mui/material'
2+
3+
export default styled((props) => (
4+
<svg
5+
xmlns='http://www.w3.org/2000/svg'
6+
width='24'
7+
height='24'
8+
viewBox='0 0 512 512'
9+
{...props}
10+
>
11+
<path d='M161.43 214h-79.04v86.76h86.69v-29.44h56.92v5.74c0 41-0.14 82-0.13 123-0.05 7.33 5.71 13.17 13.14 13.09 30.49-0.33 61-0.14 91.49-0.14h5.75v29.78h86.5v-86.49h-86.91v30.35h-83.45V128.24h83.69v29.45h86.58V71.38h-86.83v30.62h-5.67c-30.33 0-60.66 0.2-91-0.14-7.52-0.09-13.37 5.63-13.31 13.44 0.32 41-0.15 82-0.15 123v5.42h-57.17v-29.72h-7.4z' />
12+
</svg>
13+
))(({ theme }) => ({
14+
fill: theme.palette.text.primary,
15+
}))

0 commit comments

Comments
 (0)