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

[Frontend Refactor II] Separate stories from src #801

Merged
merged 10 commits into from
May 28, 2024
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { StorybookConfig } from '@storybook/web-components-vite';
import ViteYaml from "@modyfi/vite-plugin-yaml";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
framework: {
name: "@storybook/web-components-vite",
Expand Down
8 changes: 5 additions & 3 deletions generateInterfaceSchema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from neuroconv import NWBConverter, converters, datainterfaces

filepath = Path("src") / "supported_interfaces.json"
generatedJSONSchemaPath = Path("schemas", "json", "generated")
generatedJSONSchemaPath = Path("stories") / "inputs" / "interface_schemas"
generatedJSONSchemaPath.mkdir(exist_ok=True, parents=True)

f = filepath.open()
Expand All @@ -29,9 +29,11 @@ class CustomNWBConverter(NWBConverter):
outfile.write(json.dumps(schema, indent=4))


sourceDataStoryPath = Path("src/electron/renderer/src/stories/pages/guided-mode/SourceData.stories.js")
sourceDataStoryPath = Path("stories/pages/SourceData.stories.js")

importCode = "\n".join(map(lambda arr: f"import {arr[0]}Schema from '../../../../../../{arr[1]}'", paths.items()))
importCode = "\n".join(
map(lambda arr: f"import {arr[0]}Schema from '../inputs/interface_schemas/{arr[1]}'", paths.items())
)
storyCode = "\n".join(
map(
lambda arr: f"""export const {arr[0]} = PageTemplate.bind({{}});
Expand Down
8 changes: 4 additions & 4 deletions src/electron/renderer/src/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import { GuidedInspectorPage } from "./stories/pages/guided-mode/options/GuidedI

import logo from "../assets/img/logo-guide-draft-transparent-tight.png";
import { GuidedPathExpansionPage } from "./stories/pages/guided-mode/data/GuidedPathExpansion";
import uploadIcon from "./stories/assets/dandi.svg?raw";
import inspectIcon from "./stories/assets/inspect.svg?raw";
import neurosiftIcon from "./stories/assets/neurosift-logo.svg?raw";
import uploadIcon from "../assets/icons/dandi.svg?raw";
import inspectIcon from "../assets/icons/inspect.svg?raw";
import neurosiftIcon from "../assets/icons/neurosift-logo.svg?raw";

import settingsIcon from "./stories/assets/settings.svg?raw";
import settingsIcon from "../assets/icons/settings.svg?raw";

import { UploadsPage } from "./stories/pages/uploads/UploadsPage";
import { SettingsPage } from "./stories/pages/settings/SettingsPage";
Expand Down
6 changes: 3 additions & 3 deletions src/electron/renderer/src/server/globals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isElectron, app, port } from '../electron/index.js'

import serverSVG from "../stories/assets/server.svg?raw";
import webAssetSVG from "../stories/assets/web_asset.svg?raw";
import wifiSVG from "../stories/assets/wifi.svg?raw";
import serverSVG from "../../assets/icons/server.svg?raw";
import webAssetSVG from "../../assets/icons/web_asset.svg?raw";
import wifiSVG from "../../assets/icons/wifi.svg?raw";

// Base Request URL for Python Server
export const baseUrl = `http://127.0.0.1:${port}`;
Expand Down
2 changes: 1 addition & 1 deletion src/electron/renderer/src/stories/FileSystemSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fs, remote } from "../electron/index";
import { List } from "./List";
const { dialog } = remote;

import restartSVG from "./assets/restart.svg?raw";
import restartSVG from "../../assets/icons/restart.svg?raw";
import { unsafeSVG } from "lit/directives/unsafe-svg.js";

function getObjectTypeReferenceString(type, multiple, { nested, native } = {}) {
Expand Down
4 changes: 2 additions & 2 deletions src/electron/renderer/src/stories/FullScreenToggle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LitElement, css, html } from "lit";

import fullScreenIcon from './assets/fullscreen.svg?raw'
import fullScreenExitIcon from './assets/fullscreen_exit.svg?raw'
import fullScreenIcon from '../../assets/icons/fullscreen.svg?raw'
import fullScreenExitIcon from '../../assets/icons/fullscreen_exit.svg?raw'

import { unsafeHTML } from "lit/directives/unsafe-html.js";

Expand Down
2 changes: 1 addition & 1 deletion src/electron/renderer/src/stories/Search.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LitElement, html, css } from "lit";
import { styleMap } from "lit/directives/style-map.js";

import searchSVG from "./assets/search.svg?raw";
import searchSVG from "../../assets/icons/search.svg?raw";

import tippy from "tippy.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { header, tempPropertyKey } from "../../../forms/utils";
import { createGlobalFormModal } from "../../../forms/GlobalFormModal";
import { Button } from "../../../Button.js";

import globalIcon from "../../../assets/global.svg?raw";
import globalIcon from "../../../../../assets/icons/global.svg?raw";

const parentTableRenderConfig = {
Electrodes: (metadata) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Button } from "../../../Button.js";
import { Modal } from "../../../Modal";
import { header } from "../../../forms/utils";

import autocompleteIcon from "../../../assets/inspect.svg?raw";
import autocompleteIcon from "../../../../../assets/icons/inspect.svg?raw";

const propOrder = ["path", "subject_id", "session_id"];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createGlobalFormModal } from "../../../forms/GlobalFormModal";
import { header } from "../../../forms/utils";
import { Button } from "../../../Button.js";

import globalIcon from "../../../assets/global.svg?raw";
import globalIcon from "../../../../../assets/icons/global.svg?raw";

import { baseUrl } from "../../../../server/globals";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html } from "lit";
import { Page } from "../../Page.js";

import { unsafeSVG } from "lit/directives/unsafe-svg.js";
import folderOpenSVG from "../../../assets/folder_open.svg?raw";
import folderOpenSVG from "../../../../../assets/icons/folder_open.svg?raw";

import { electron } from "../../../../electron/index.js";
import { getSharedPath, removeFilePaths, truncateFilePaths } from "../../../preview/NWBFilePreview.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html } from "lit";
import { Page } from "../../Page.js";

import { unsafeSVG } from "lit/directives/unsafe-svg.js";
import folderOpenSVG from "../../../assets/folder_open.svg?raw";
import folderOpenSVG from "../../../../../assets/icons/folder_open.svg?raw";

import { electron } from "../../../../electron/index.js";
import { NWBFilePreview, getSharedPath } from "../../../preview/NWBFilePreview.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { until } from "lit/directives/until.js";

import { Button } from "../../../Button.js";

import keyIcon from "../../../assets/key.svg?raw";
import keyIcon from "../../../../../assets/icons/key.svg?raw";

import { validate } from "../../uploads/utils";
import { global } from "../../../../progress/index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html } from "lit";
import { unsafeSVG } from "lit/directives/unsafe-svg.js";
import folderOpenSVG from "../../../assets/folder_open.svg?raw";
import folderOpenSVG from "../../../../../assets/icons/folder_open.svg?raw";

import { Page } from "../../Page.js";
import { getStubArray } from "../options/GuidedStubPreview.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Button } from "../../../Button.js";
import { createGlobalFormModal } from "../../../forms/GlobalFormModal";
import { header } from "../../../forms/utils";

import globalIcon from "../../../assets/global.svg?raw";
import globalIcon from "../../../../../assets/icons/global.svg?raw";

export class GuidedSubjectsPage extends Page {
constructor(...args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { merge, setUndefinedIfNotDeclared } from "../utils";
import { homeDirectory, notyf, testDataFolderPath } from "../../../dependencies/globals";
import { SERVER_FILE_PATH, electron, path, port, fs } from "../../../electron/index.js";

import saveSVG from "../../assets/save.svg?raw";
import folderSVG from "../../assets/folder_open.svg?raw";
import deleteSVG from "../../assets/delete.svg?raw";
import generateSVG from "../../assets/restart.svg?raw";
import saveSVG from "../../../../assets/icons/save.svg?raw";
import folderSVG from "../../../../assets/icons/folder_open.svg?raw";
import deleteSVG from "../../../../assets/icons/delete.svg?raw";
import generateSVG from "../../../../assets/icons/restart.svg?raw";

import { header } from "../../forms/utils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { validateDANDIApiKey } from "../../../validation/dandi";

import * as dandi from "dandi";

import keyIcon from "../../assets/key.svg?raw";
import keyIcon from "../../../../assets/icons/key.svg?raw";

import { AWARD_VALIDATION_FAIL_MESSAGE, awardNumberValidator, isStaging, validate } from "./utils";
import { createFormModal } from "../../forms/GlobalFormModal";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dashboard } from "../../pages.js";
import { dashboard } from "../src/electron/renderer/src/pages.js";

// const options = Object.keys(dashboard.pagesById)

Expand Down
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Accordion } from "./Accordion";
import { Accordion } from "../../src/electron/renderer/src/stories/Accordion";

export default {
title: "Components/Accordion",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from "./Button";
import { Button } from "../../src/electron/renderer/src/stories/Button";

// More on how to set up stories at: https://storybook.js.org/docs/7.0/web-components/writing-stories/introduction
export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FilesystemSelector } from "./FileSystemSelector";
import { FilesystemSelector } from "../../src/electron/renderer/src/stories/FileSystemSelector";

export default {
title: "Components/Filesystem Selector",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InspectorList } from "./InspectorList";
import testInspectorList from "./test.json";
import { InspectorList } from "../../src/electron/renderer/src/stories/preview/inspector/InspectorList";
import testInspectorList from "../inputs/inspector_output.json";

export default {
title: "Components/Inspector List",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InstanceManager } from "./InstanceManager";
import { Modal } from "./Modal";
import { InstanceManager } from "../../src/electron/renderer/src/stories/InstanceManager";
import { Modal } from "../../src/electron/renderer/src/stories/Modal";

// More on how to set up stories at: https://storybook.js.org/docs/7.0/web-components/writing-stories/introduction
export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JSONSchemaForm } from "./JSONSchemaForm";
import { JSONSchemaForm } from "../../src/electron/renderer/src/stories/JSONSchemaForm";

export default {
title: "Components/JSON Schema Form",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { List } from "./List";
import { List } from "../../src/electron/renderer/src/stories/List";

export default {
title: "Components/List",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { globalState, PageTemplate } from "./storyStates";
import { globalState, PageTemplate } from "../pages/storyStates";

export default {
title: "Pages/Guided Mode/Locate",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MultiSelectForm } from "./MultiSelectForm.js";
import { MultiSelectForm } from "../../src/electron/renderer/src/stories/multiselect/MultiSelectForm.js";

export default {
title: "Components/Multiselect Form",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OptionalSection } from "./OptionalSection";
import { OptionalSection } from "../../src/electron/renderer/src/stories/OptionalSection";

export default {
title: "Components/Optional Section",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProgressBar } from "./ProgressBar";
import { ProgressBar } from "../../src/electron/renderer/src/stories/ProgressBar";

export default {
title: "Components/Progress Bar",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Search } from "./Search";
import { Search } from "../../src/electron/renderer/src/stories/Search";

// More on how to set up stories at: https://storybook.js.org/docs/7.0/web-components/writing-stories/introduction
export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StatusBar } from "./StatusBar";
import { StatusBar } from "../../src/electron/renderer/src/stories/status/StatusBar";
import { unsafeSVG } from "lit/directives/unsafe-svg.js";
import pythonSVG from "../assets/python.svg?raw";
import webAssetSVG from "../assets/web_asset.svg?raw";
import wifiSVG from "../assets/wifi.svg?raw";
import pythonSVG from "../../src/electron/renderer/assets/icons/python.svg?raw";
import webAssetSVG from "../../src/electron/renderer/assets/icons/web_asset.svg?raw";
import wifiSVG from "../../src/electron/renderer/assets/icons/wifi.svg?raw";

export default {
title: "Components/Status Bar",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Table } from "./Table.js";
import { Table } from "../../src/electron/renderer/src/stories/Table.js";

import getSubjectSchema from "../../../../schemas/subject.schema";
import { SimpleTable } from "./SimpleTable.js";
import { BasicTable } from "./BasicTable.js";
import getSubjectSchema from "../../src/schemas/subject.schema";
import { SimpleTable } from "../../src/electron/renderer/src/stories/SimpleTable.js";
import { BasicTable } from "../../src/electron/renderer/src/stories/BasicTable.js";

export default {
title: "Components/Table",
Expand Down
Loading
Loading