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

Hide live preview button in storm #348

Merged
merged 37 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
51e3a28
add isWithinCBD to studio store
alextaing Aug 23, 2023
9fc7254
whitespace tabbing
alextaing Aug 23, 2023
b13e938
only start dev server if in cbd;
alextaing Aug 23, 2023
2049735
fix typo
alextaing Aug 23, 2023
b547697
Automated linting update and features.json sync
github-actions[bot] Aug 23, 2023
c5e2fae
resize viewport and icon to fit action bar
alextaing Aug 23, 2023
a359008
Automated linting update and features.json sync
github-actions[bot] Aug 23, 2023
f5f8750
add virtual git data mock
alextaing Aug 23, 2023
c78427f
Automated linting update and features.json sync
github-actions[bot] Aug 23, 2023
5647194
change info icon size
alextaing Aug 23, 2023
748a7f2
revert features;
alextaing Aug 23, 2023
747dfc2
whitespace
alextaing Aug 23, 2023
fa05801
info button again
alextaing Aug 23, 2023
8f27963
height
alextaing Aug 23, 2023
f8de9d7
revert features
alextaing Aug 23, 2023
15ae49d
retake screenshots
alextaing Aug 23, 2023
9a5320e
New snapshots for windows-latest 2 of 4
github-actions[bot] Aug 23, 2023
41bead2
New snapshots for macos-latest 2 of 4
github-actions[bot] Aug 23, 2023
cff610d
New snapshots for windows-latest 4 of 4
github-actions[bot] Aug 23, 2023
eff45b8
New snapshots for windows-latest 3 of 4
github-actions[bot] Aug 23, 2023
70c7760
New snapshots for macos-latest 4 of 4
github-actions[bot] Aug 23, 2023
b9b2fc0
New snapshots for windows-latest 1 of 4
github-actions[bot] Aug 23, 2023
621f3b6
New snapshots for macos-latest 1 of 4
github-actions[bot] Aug 23, 2023
5c08d78
empty commit
alextaing Aug 24, 2023
004f385
New snapshots for macos-latest 3 of 4
github-actions[bot] Aug 24, 2023
817c2e2
restart tests
alextaing Aug 24, 2023
ae9fb8d
change to studio data instead of git data
alextaing Aug 24, 2023
3041576
Automated linting update and features.json sync
github-actions[bot] Aug 24, 2023
09724f0
forgot exclamation mark
alextaing Aug 24, 2023
fb939d3
Automated linting update and features.json sync
github-actions[bot] Aug 24, 2023
ff3e927
move pages server start back up
alextaing Aug 24, 2023
c60045a
Automated linting update and features.json sync
github-actions[bot] Aug 24, 2023
646b14e
merge
alextaing Aug 24, 2023
dd3b9a4
await at end
alextaing Aug 25, 2023
2a9e946
Automated linting update and features.json sync
github-actions[bot] Aug 25, 2023
ca819c4
use &&
alextaing Aug 25, 2023
ab5271d
Automated linting update and features.json sync
github-actions[bot] Aug 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/studio-plugin/src/ParsingOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default class ParsingOrchestrator {
UUIDToFileMetadata: this.getUUIDToFileMetadata(),
siteSettings,
studioConfig: this.studioConfig,
isWithinCBD: !!process.env.YEXT_CBD_BRANCH,
};
}

Expand Down
23 changes: 8 additions & 15 deletions packages/studio-plugin/src/createStudioPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { readdirSync, existsSync, lstatSync } from "fs";
import upath from "upath";
import lodash from "lodash";
import { STUDIO_PROCESS_ARGS_OBJ } from "./constants";
import { startPagesDevelopmentServer } from "./startPagesDevelopmentServer";
import LocalDataMappingManager from "./LocalDataMappingManager";
import { execSync } from "node:child_process";
import getStudioViteOptions from "./viteconfig/getStudioViteOptions";
import { createDevServer } from "@yext/pages";

/**
* Handles server-client communication.
Expand All @@ -33,9 +32,11 @@ export default async function createStudioPlugin(
);
const pathToUserProjectRoot = getProjectRoot(cliArgs);
const studioConfig = await getStudioConfig(pathToUserProjectRoot, cliArgs);
const pagesDevPortPromise = studioConfig.isPagesJSRepo
alextaing marked this conversation as resolved.
Show resolved Hide resolved
? startPagesDevelopmentServer()
const shouldSpawnPagesDevServer = !process.env.YEXT_CBD_BRANCH && studioConfig.isPagesJSRepo;
const pagesDevPortPromise = shouldSpawnPagesDevServer
alextaing marked this conversation as resolved.
Show resolved Hide resolved
? createDevServer(false, false, 5173)
: null;

const gitWrapper = new GitWrapper(
simpleGit({
baseDir: pathToUserProjectRoot,
Expand All @@ -62,16 +63,7 @@ export default async function createStudioPlugin(
new FileSystemWriter(orchestrator, tsMorphProject)
);

await pagesDevPortPromise?.then((port) => {
if (!port) {
throw new Error("No port found for PagesJS.");
}
console.log("PagesJS running on port:", port);
process.on("exit", () => {
execSync(`npx kill-port ${port}`);
});
});

await pagesDevPortPromise;
return {
name: "yext-studio-vite-plugin",
buildStart() {
Expand Down Expand Up @@ -99,7 +91,8 @@ export default async function createStudioPlugin(
const studioViteOptions = getStudioViteOptions(
args,
studioConfig,
pathToUserProjectRoot
pathToUserProjectRoot,
orchestrator.getStudioData().isWithinCBD
);
return lodash.merge({}, config, studioViteOptions);
},
Expand Down
1 change: 0 additions & 1 deletion packages/studio-plugin/src/git/GitWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default class GitWrapper {
const canPush = await this.canPush();
this.gitData = {
canPush,
isWithinCBD: !!process.env.YEXT_CBD_BRANCH,
};
}
}
1 change: 0 additions & 1 deletion packages/studio-plugin/src/types/GitData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ export interface GitData {
status: boolean;
reason?: string;
};
isWithinCBD: boolean;
}
1 change: 1 addition & 0 deletions packages/studio-plugin/src/types/StudioData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface StudioData {
UUIDToFileMetadata: Record<string, FileMetadata>;
siteSettings?: SiteSettings;
studioConfig: StudioConfigWithDefaulting;
isWithinCBD: boolean;
}
5 changes: 3 additions & 2 deletions packages/studio-plugin/src/viteconfig/getStudioViteOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { StudioConfigWithDefaulting } from "../types";
export default function getStudioViteOptions(
args: ConfigEnv,
studioConfig: StudioConfigWithDefaulting,
pathToUserProjectRoot: string
pathToUserProjectRoot: string,
isWithinCBD: boolean
): UserConfig {
const serverOptions: ServerOptions = {
port: studioConfig.port,
open:
args.mode === "development" &&
args.command === "serve" &&
!process.env.YEXT_CBD_BRANCH &&
!isWithinCBD &&
studioConfig.openBrowser,
watch: {
ignored: pathToUserProjectRoot,
Expand Down
5 changes: 0 additions & 5 deletions packages/studio-plugin/tests/git/GitWrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe("verifying canPush calculation", () => {
status: false,
reason: "No remotes found.",
},
isWithinCBD: false,
};
expect(gitWrapper.getStoredData()).toEqual(expectedData);
});
Expand All @@ -86,7 +85,6 @@ describe("verifying canPush calculation", () => {
status: false,
reason: "Multiple remotes found.",
},
isWithinCBD: false,
};
expect(gitWrapper.getStoredData()).toEqual(expectedData);
});
Expand All @@ -101,7 +99,6 @@ describe("verifying canPush calculation", () => {
status: false,
reason: "No upstream branch found",
},
isWithinCBD: false,
};
expect(gitWrapper.getStoredData()).toEqual(expectedData);
});
Expand All @@ -117,7 +114,6 @@ describe("verifying canPush calculation", () => {
status: false,
reason: "No changes to push.",
},
isWithinCBD: false,
};
expect(gitWrapper.getStoredData()).toEqual(expectedData);
});
Expand All @@ -132,7 +128,6 @@ describe("verifying canPush calculation", () => {
canPush: {
status: true,
},
isWithinCBD: false,
};
expect(gitWrapper.getStoredData()).toEqual(expectedData);
});
Expand Down
1 change: 1 addition & 0 deletions packages/studio/__mocks__/virtual_yext-studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ const mockStudioData: StudioData = {
isPagesJSRepo: false,
port: 8080,
},
isWithinCBD: false,
};
export default mockStudioData;
17 changes: 11 additions & 6 deletions packages/studio/src/components/ActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,37 @@ import AddElementButton from "./AddElementButton";
import UndoRedo from "./UndoRedo";
import SaveButton from "./SaveButton";
import DeployButton from "./DeployButton";
import gitData from "virtual_yext-studio-git-data";
import OpenLivePreviewButton from "./OpenLivePreviewButton";
import ViewportButton from "./Viewport/ViewportButton";
import InfoButton from "./InfoButton";
import useStudioStore from "../store/useStudioStore";

/**
* Renders the top bar of Studio, which includes buttons for performing undo
* and redo actions, and adding elements.
*/
export default function ActionsBar(): JSX.Element {
const studioInCBD = useStudioStore(
(store) => store.studioEnvData.isWithinCBD
);
return (
<div className="flex bg-gray-100 py-3 items-center px-4">
<AddElementButton />
<div className="ml-auto">
<div className="ml-auto h-7">
<InfoButton />
</div>
<div className="ml-4">
<OpenLivePreviewButton />
</div>
{!studioInCBD && (
<div className="ml-4">
<OpenLivePreviewButton />
</div>
)}
<div className="ml-2 flex items-center">
<div className="mr-2">
<ViewportButton />
</div>
<UndoRedo />
</div>
{!gitData.isWithinCBD && <SaveButton />}
{!studioInCBD && <SaveButton />}
<DeployButton />
</div>
);
Expand Down
8 changes: 1 addition & 7 deletions packages/studio/src/components/InfoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,5 @@ const renderModal: renderModalFunction = (isOpen, handleClose) => {
* Renders an info modal including the current Studio version
*/
export default function InfoButton() {
return (
<ButtonWithModal
buttonContent={infoSVG}
buttonClassName="pt-2"
renderModal={renderModal}
/>
);
return <ButtonWithModal buttonContent={infoSVG} renderModal={renderModal} />;
}
2 changes: 1 addition & 1 deletion packages/studio/src/icons/info.svg
4 changes: 2 additions & 2 deletions packages/studio/src/icons/viewport.svg
2 changes: 2 additions & 0 deletions packages/studio/src/store/models/StudioStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PageSlice from "./slices/PageSlice";
import PreviousSaveSlice from "./slices/PreviousSaveSlice";
import SiteSettingSlice from "./slices/SiteSettingsSlice";
import StudioConfigSlice from "./slices/StudioConfigSlice";
import StudioEnvDataSlice from "./slices/StudioEnvDataSlice";

/**
* The overall shape of the Zustand store as the state manager for Studio.
Expand All @@ -20,4 +21,5 @@ export type StudioStore = {
createModule: (modulePath: string) => void;
actions: StudioActions;
studioConfig: StudioConfigSlice;
studioEnvData: StudioEnvDataSlice;
};
6 changes: 6 additions & 0 deletions packages/studio/src/store/models/slices/StudioEnvDataSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* A slice for containing environment data.
*/
export default interface StudioEnvDataSlice {
isWithinCBD: boolean;
}
9 changes: 9 additions & 0 deletions packages/studio/src/store/slices/createStudioEnvDataSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import StudioEnvDataSlice from "../models/slices/StudioEnvDataSlice";
import { SliceCreator } from "../models/utils";
import initialStudioData from "virtual_yext-studio";

const createStudioEnvDataSlice: SliceCreator<StudioEnvDataSlice> = () => ({
isWithinCBD: initialStudioData.isWithinCBD,
});

export default createStudioEnvDataSlice;
2 changes: 2 additions & 0 deletions packages/studio/src/store/useStudioStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import StudioActions from "./StudioActions";
import createStudioConfigSlice from "./slices/createStudioConfigSlice";
import createPreviousSaveSlice from "./slices/createPreviousSaveSlice";
import { addZundoMiddleware } from "./zundoMiddleware";
import createStudioEnvDataSlice from "./slices/createStudioEnvDataSlice";

enableMapSet();

Expand Down Expand Up @@ -46,6 +47,7 @@ const useStudioStore = create<StudioStore>()(
() => get().studioConfig
),
studioConfig: lens(createStudioConfigSlice),
studioEnvData: lens(createStudioEnvDataSlice),
};
})
)
Expand Down