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

Reorganize frontend folder structure, nomeclature #266

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

WardBrian
Copy link
Collaborator

This closes #113. This just moves code around and renames some things, no behavioral changes

The organizing principles are defined in a new ARCHITECTURE.md document: link

src/app now has the following top-level folders:

pages -- just HomePage
areas -- sub-views of HomePage. The majority of the UI is here and its sub-folders
windows -- modal boxes that show up above HomePage, like the settings
components -- reusable components
core -- contexts and workers, non-UI code
util -- utility functions

For easier viewing, here's the folder layout in full:

Details

$ tree src/
src/
├── app
│   ├── App.tsx
│   ├── areas
│   │   ├── ControlArea
│   │   │   ├── DataGenerationArea
│   │   │   │   ├── code_templates
│   │   │   │   │   ├── data.py
│   │   │   │   │   └── data.R
│   │   │   │   ├── DataPyPanel.tsx
│   │   │   │   ├── DataRPanel.tsx
│   │   │   │   └── useDataGenState.ts
│   │   │   ├── DataGenerationArea.tsx
│   │   │   ├── SamplingArea
│   │   │   │   ├── ResultsArea
│   │   │   │   │   ├── AnalysisArea
│   │   │   │   │   │   ├── AnalysisPyPanel.tsx
│   │   │   │   │   │   ├── AnalysisRPanel.tsx
│   │   │   │   │   │   ├── code_templates
│   │   │   │   │   │   │   ├── analysis.py
│   │   │   │   │   │   │   └── analysis.R
│   │   │   │   │   │   └── useAnalysisState.ts
│   │   │   │   │   ├── AnalysisArea.tsx
│   │   │   │   │   ├── SamplerOutputArea
│   │   │   │   │   │   ├── ConsolePanel.tsx
│   │   │   │   │   │   ├── DrawsTablePanel.tsx
│   │   │   │   │   │   ├── HistogramsPanel.tsx
│   │   │   │   │   │   ├── Histogram.tsx
│   │   │   │   │   │   ├── SummaryPanel.tsx
│   │   │   │   │   │   ├── TracePlotsPanel.tsx
│   │   │   │   │   │   └── TracePlot.tsx
│   │   │   │   │   └── SamplerOutputArea.tsx
│   │   │   │   ├── ResultsArea.tsx
│   │   │   │   ├── RunArea
│   │   │   │   │   ├── RunOrCompilePanel.tsx
│   │   │   │   │   ├── RunWithProgressPanel.tsx
│   │   │   │   │   ├── SamplerProgress.tsx
│   │   │   │   │   └── SamplingOptsPanel.tsx
│   │   │   │   └── RunArea.tsx
│   │   │   └── SamplingArea.tsx
│   │   ├── ControlArea.tsx
│   │   ├── ModelDataArea
│   │   │   ├── DataEditorPanel.tsx
│   │   │   ├── ModelEditorPanel.tsx
│   │   │   └── StanCompileResultPanel.tsx
│   │   └── ModelDataArea.tsx
│   ├── components
│   │   ├── CloseableDialog.tsx
│   │   ├── Collapsable.tsx
│   │   ├── FileEditor
│   │   │   ├── monacoStanLanguage.ts
│   │   │   ├── PlottingScriptEditor.tsx
│   │   │   ├── ScriptEditor.tsx
│   │   │   ├── TextEditor.tsx
│   │   │   ├── ToolBar.tsx
│   │   │   └── useTemplatedFillerText.ts
│   │   ├── LazyPlotlyPlot.tsx
│   │   ├── LinearProgressWithLabel.tsx
│   │   ├── ResponsiveGrid.tsx
│   │   ├── StyledTables.tsx
│   │   └── TabWidget.tsx
│   ├── core
│   │   ├── Compilation
│   │   │   ├── CompileContextProvider.tsx
│   │   │   └── compileStanProgram.ts
│   │   ├── Project
│   │   │   ├── FileMapping.ts
│   │   │   ├── ProjectContextProvider.tsx
│   │   │   ├── ProjectDataModel.ts
│   │   │   ├── ProjectQueryLoading.ts
│   │   │   ├── ProjectReducer.ts
│   │   │   └── ProjectSerialization.ts
│   │   ├── Scripting
│   │   │   ├── InterpreterTypes.ts
│   │   │   ├── OutputDivUtils.ts
│   │   │   ├── pyodide
│   │   │   │   ├── pyodideWorker.ts
│   │   │   │   ├── pyodideWorkerTypes.ts
│   │   │   │   ├── sp_load_draws.py
│   │   │   │   ├── sp_patch_matplotlib.py
│   │   │   │   └── usePyodideWorker.ts
│   │   │   └── webR
│   │   │       ├── data_postamble.R
│   │   │       ├── sp_load_draws.R
│   │   │       ├── useWebR.ts
│   │   │       └── webR_preamble.R
│   │   ├── Settings
│   │   │   ├── UserSettingsProvider.tsx
│   │   │   └── UserSettings.ts
│   │   ├── Stanc
│   │   │   ├── Linting.ts
│   │   │   ├── stanc.js
│   │   │   ├── stancWorker.ts
│   │   │   ├── Types.ts
│   │   │   └── useStanc.ts
│   │   └── StanSampler
│   │       ├── StanModelWorker.ts
│   │       ├── StanSampler.ts
│   │       └── useStanSampler.ts
│   ├── pages
│   │   ├── CustomTheming.tsx
│   │   ├── HomePage.tsx
│   │   ├── Sidebar.tsx
│   │   └── TopBar.tsx
│   ├── util
│   │   ├── baseObjectCheck.ts
│   │   ├── gists
│   │   │   ├── loadFilesFromGist.ts
│   │   │   └── saveAsGitHubGist.ts
│   │   ├── isMonacoWorkerNoise.ts
│   │   ├── normalizeLineEndings.ts
│   │   ├── replaceSpaces.ts
│   │   ├── stan_stats
│   │   │   ├── fft.ts
│   │   │   ├── stan_stats.ts
│   │   │   └── summaryStats.ts
│   │   ├── triggerDownload.ts
│   │   ├── tryFetch.ts
│   │   ├── types
│   │   │   └── plotly-cartesian.d.ts
│   │   └── unreachable.ts
│   └── windows
│       ├── ExportProjectWindow
│       │   ├── ExportProjectPanel.tsx
│       │   ├── GistExportPanel.tsx
│       │   ├── GistUpdatePanel.tsx
│       │   ├── InputPersonalAccessToken.tsx
│       │   └── makeShareableLink.ts
│       ├── ExportProjectWindow.tsx
│       ├── LoadProjectWindow
│       │   ├── LoadProjectPanel.tsx
│       │   └── UploadFiles.tsx
│       ├── LoadProjectWindow.tsx
│       ├── SettingsWindow
│       │   ├── CompilationServerArea.tsx
│       │   └── PersonalSettingsArea.tsx
│       └── SettingsWindow.tsx
├── index.css
├── localStyles.css
└── main.tsx

33 directories, 107 files

Copy link
Collaborator

@jsoules jsoules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few recommended changes, a few relevant comments, and some less relevant ones...

Overall looks good. I've pulled and run locally and everything still seemed to be present & loaded fine, as far as I could tell.

Comment on lines +11 to +13
- **Areas** (`gui/src/app/areas`) are subdivisions of a page _with a_ unique
_purpose_. An area can contain other areas which serve distinct sub-purposes,
or one or more Panels.
Copy link
Collaborator

@jsoules jsoules Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Areas** (`gui/src/app/areas`) are subdivisions of a page _with a_ unique
_purpose_. An area can contain other areas which serve distinct sub-purposes,
or one or more Panels.
- **Areas** (`gui/src/app/areas`) are subdivisions of a page with a _unique
purpose_. An Area can contain other Areas which serve distinct sub-purposes,
or one or more Panels.

- **Windows** (`gui/src/app/windows`) are Areas that use `CloseableDialogue`
to pop in and out rather than occupying real estate of the Page.

- **Panels** are subdivisions of an area. Sibling panels should all be pushing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Panels** are subdivisions of an area. Sibling panels should all be pushing
- **Panels** are subdivisions of an area. Sibling Panels should all be pushing

to pop in and out rather than occupying real estate of the Page.

- **Panels** are subdivisions of an area. Sibling panels should all be pushing
"in the same direction".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand "pushing in the same direction." Do you mean serving the same broader purpose? I originally understood it to mean something about the orientation of the sliders.

Comment on lines +26 to +28
For example, the `SamplerOutputArea` area contains tabs for different views of the output.
Each of these tabs is one Panel -- while the draws as a table and the draws as
histograms are quite different from each other, they serve the same greater purpose
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, the `SamplerOutputArea` area contains tabs for different views of the output.
Each of these tabs is one Panel -- while the draws as a table and the draws as
histograms are quite different from each other, they serve the same greater purpose
For example, the `SamplerOutputArea` Area contains tabs for different views of the output.
Each of these tabs is one Panel -- while the Panel that displays the draws as a table is
quite different from the Panel that displays the draws as histograms,
they serve the same greater purpose

For example, the `SamplerOutputArea` area contains tabs for different views of the output.
Each of these tabs is one Panel -- while the draws as a table and the draws as
histograms are quite different from each other, they serve the same greater purpose
of allowing the user to explore the result of the Stan run, which is their parent Areas
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
of allowing the user to explore the result of the Stan run, which is their parent Areas
of allowing the user to explore the result of the Stan run, which is their parent Area's

@@ -53,7 +59,7 @@ const StanFileEditor: FunctionComponent<Props> = ({
});

// invalid syntax
if (!validSyntax && !!editedFileContent) {
if (!validSyntax && !!data.ephemera.stanFileContent) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly germane to this PR, but my fingers are itching to move the button stuff to its own file, or at least find a way to make it less repetitive.

import { ToolBar, ToolbarItem } from "@SpComponents/ToolBar";
import { UserSettingsContext } from "@SpSettings/UserSettings";
import { CodeMarker } from "@SpStanc/Linting";
import { UserSettingsContext } from "@SpCore/Settings/UserSettings";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you say in the architecture doc that components shouldn't interact with contexts? (It is probably the right thing to do here, just noting it)

@@ -1,5 +1,5 @@
import { createContext } from "react";
import { SettingsTab } from "./SettingsWindow";
import { SettingsTab } from "@SpWindows/SettingsWindow";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { SettingsTab } from "@SpWindows/SettingsWindow";
import { type SettingsTab } from "@SpWindows/SettingsWindow";

@@ -11,7 +11,7 @@ import {

import { useDialogControls } from "@SpComponents/CloseableDialog";

import { SettingsTab } from "./SettingsWindow";
import { SettingsTab } from "@SpWindows/SettingsWindow";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { SettingsTab } from "@SpWindows/SettingsWindow";
import { type SettingsTab } from "@SpWindows/SettingsWindow";

@@ -59,7 +69,22 @@ const TopBar: FunctionComponent<TopBarProps> = ({ title, onSetCollapsed }) => {
<Brightness7 fontSize="inherit" />
)}
</IconButton>
<CompilationServerConnectionControl />
<IconButton
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlining this component (from CompilationServerConnectionControl) is not unreasonable, it isn't super big, but it's somewhat less semantic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reorganize/tidy source folder structure throughout frontend
2 participants