Skip to content

Commit bf76484

Browse files
committed
fix: rebase leftovers
1 parent 6877cbc commit bf76484

File tree

7 files changed

+80
-23
lines changed

7 files changed

+80
-23
lines changed

src/components/pages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export { External404 } from "@components/pages/external404";
66
export { Internal404 } from "@components/pages/internal404";
77
export { Intro } from "@components/pages/intro";
88
export { Project } from "@components/pages/project";
9+
export { ProjectExplorerGuard } from "@components/pages/projectExplorerGuard";
910
export { TemplateLanding } from "@components/pages/templateLanding";

src/components/pages/project.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import React, { useEffect, useState } from "react";
33
import { Outlet, useParams } from "react-router-dom";
44

55
import { EventListenerName } from "@src/enums";
6-
import { DrawerName } from "@src/enums/components";
7-
import { triggerEvent, useEventListener } from "@src/hooks";
6+
import { useEventListener } from "@src/hooks";
87
import { useCacheStore, useManualRunStore, useProjectStore, useSharedBetweenProjectsStore } from "@src/store";
98
import { UserTrackingUtils } from "@src/utilities";
109

@@ -19,9 +18,10 @@ export const Project = () => {
1918
const { fetchManualRunConfiguration } = useManualRunStore();
2019
const { projectId } = useParams();
2120
const { getProject } = useProjectStore();
22-
const { isProjectFilesVisible, setIsProjectFilesVisible, isDrawerOpen } = useSharedBetweenProjectsStore();
21+
const { isProjectFilesVisible, setIsProjectFilesVisible } = useSharedBetweenProjectsStore();
2322
const [isConnectionLoadingFromChatbot, setIsConnectionLoadingFromChatbot] = useState(false);
2423
const [showFiles, setShowFiles] = useState(false);
24+
2525
const openConnectionFromChatbot = () => {
2626
setIsConnectionLoadingFromChatbot(true);
2727
setTimeout(() => {
@@ -43,23 +43,18 @@ export const Project = () => {
4343
useEffect(() => {
4444
if (!projectId) return;
4545
loadProject(projectId!);
46+
// eslint-disable-next-line react-hooks/exhaustive-deps
47+
}, [projectId]);
4648

47-
if (
48-
!!isDrawerOpen(projectId!, DrawerName.projectSettings) ||
49-
isDrawerOpen(projectId!, DrawerName.projectSettings) === undefined
50-
) {
51-
triggerEvent(EventListenerName.displayProjectConfigSidebar);
52-
}
49+
useEffect(() => {
50+
if (!projectId) return;
5351

5452
if (!!isProjectFilesVisible[projectId] || isProjectFilesVisible[projectId!] === undefined) {
5553
setShowFiles(true);
56-
setIsProjectFilesVisible(projectId, true);
57-
return;
54+
} else {
55+
setShowFiles(false);
5856
}
59-
60-
setShowFiles(false);
61-
// eslint-disable-next-line react-hooks/exhaustive-deps
62-
}, [isProjectFilesVisible, projectId]);
57+
}, [isProjectFilesVisible, projectId, setIsProjectFilesVisible]);
6358

6459
const handleShowProjectFiles = () => {
6560
if (!projectId) return;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React, { useEffect, useMemo } from "react";
2+
3+
import { Navigate, useLocation, useParams } from "react-router-dom";
4+
5+
import { Project } from "./project";
6+
import { EventListenerName } from "@src/enums";
7+
import { DrawerName } from "@src/enums/components";
8+
import { triggerEvent } from "@src/hooks";
9+
import { useSharedBetweenProjectsStore } from "@src/store";
10+
import { extractSettingsPath } from "@src/utilities";
11+
12+
export const ProjectExplorerGuard = () => {
13+
const { projectId } = useParams();
14+
const location = useLocation();
15+
const { settingsPath } = extractSettingsPath(location.pathname);
16+
const { isDrawerOpen, setIsProjectFilesVisible, isProjectFilesVisible } = useSharedBetweenProjectsStore();
17+
18+
const shouldRedirectToSettings = useMemo(() => {
19+
if (!projectId) return false;
20+
21+
const isProjectSettingsDrawerOpen =
22+
isDrawerOpen(projectId, DrawerName.projectSettings) || settingsPath !== "settings";
23+
24+
return !!isProjectSettingsDrawerOpen || isProjectSettingsDrawerOpen === undefined;
25+
}, [projectId, isDrawerOpen, settingsPath]);
26+
27+
useEffect(() => {
28+
if (!projectId) return;
29+
30+
if (shouldRedirectToSettings) {
31+
triggerEvent(EventListenerName.displayProjectConfigSidebar);
32+
}
33+
34+
if (!!isProjectFilesVisible[projectId] || isProjectFilesVisible[projectId] === undefined) {
35+
setIsProjectFilesVisible(projectId, true);
36+
}
37+
}, [projectId, shouldRedirectToSettings, isProjectFilesVisible, setIsProjectFilesVisible]);
38+
39+
if (shouldRedirectToSettings && settingsPath !== "settings") {
40+
return <Navigate replace to="settings" />;
41+
}
42+
43+
return <Project />;
44+
};

src/hooks/tour/useTourActionListener.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ export const useTourActionListener = () => {
4949
createTourOverlay(activeStep?.overlayAboveDrawer);
5050

5151
const delayMs = activeStep?.popoverDelayMs ?? 0;
52-
console.log("delayMs", delayMs);
53-
console.log("activeStep", activeStep);
54-
console.log("element", element);
5552
if (delayMs > 0) {
5653
popoverTimeoutRef.current = setTimeout(() => {
5754
setPopoverVisible(true);

src/routes.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import React from "react";
33
import { Navigate } from "react-router-dom";
44

55
import { MemberRole } from "@enums";
6+
import { EditConnection, AddConnection } from "@project-connections";
7+
import { AddTrigger, EditTrigger } from "@project-triggers";
8+
import { AddVariable, EditVariable } from "@project-variables";
69
import { legacyRoutes } from "@src/routes.legacy";
710

811
import { CreateNewProject, DeploymentsTable, EventViewer, ProtectedRoute, SessionsTable } from "@components/organisms";
912
import { ProjectSettingsDrawer } from "@components/organisms/configuration";
1013
import { ProjectSettingsMainView } from "@components/organisms/configuration/configurationView";
11-
import { AddConnection, EditConnection } from "@components/organisms/configuration/connections";
12-
import { AddTrigger, EditTrigger } from "@components/organisms/configuration/triggers";
13-
import { AddVariable, EditVariable } from "@components/organisms/configuration/variables";
1414
import { TemplatesCatalog } from "@components/organisms/dashboard/templates";
1515
import { SessionViewer } from "@components/organisms/deployments";
1616
import { ActivityList, SessionOutputs } from "@components/organisms/deployments/sessions/tabs";
@@ -23,7 +23,15 @@ import {
2323
import { OrganizationBilling } from "@components/organisms/settings/organization/billing";
2424
import { ClientConfiguration, Profile, UserOrganizationsTable } from "@components/organisms/settings/user";
2525
import { EventsList } from "@components/organisms/shared";
26-
import { ChatPage, CustomError, Dashboard, Internal404, Intro, Project, TemplateLanding } from "@components/pages";
26+
import {
27+
ChatPage,
28+
CustomError,
29+
Dashboard,
30+
Internal404,
31+
Intro,
32+
ProjectExplorerGuard,
33+
TemplateLanding,
34+
} from "@components/pages";
2735
import { AppLayout, EventsLayout } from "@components/templates";
2836
import { ProjectWrapper } from "@components/templates/projectWrapper";
2937
import { SettingsLayout } from "@components/templates/settingsLayout";
@@ -76,7 +84,7 @@ export const mainRoutes = [
7684
{ path: "code", element: <Navigate relative="route" replace to="explorer" /> },
7785
{
7886
path: "explorer",
79-
element: <Project />,
87+
element: <ProjectExplorerGuard />,
8088
children: [
8189
{
8290
path: "settings",

tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"paths": {
2727
"@assets": ["./src/assets/index"],
2828
"@assets/*": ["./src/assets/*"],
29+
"@project-config": ["./src/components/organisms/configuration/index"],
30+
"@project-config/*": ["./src/components/organisms/configuration/*"],
31+
"@project-connections/*": ["./src/components/organisms/configuration/connections/*"],
32+
"@project-connections": ["./src/components/organisms/configuration/connections/index"],
33+
"@project-triggers": ["./src/components/organisms/configuration/triggers/index"],
34+
"@project-triggers/*": ["./src/components/organisms/configuration/triggers/*"],
35+
"@project-variables": ["./src/components/organisms/configuration/variables/index"],
36+
"@project-variables/*": ["./src/components/organisms/configuration/variables/*"],
2937
"@components/*": ["./src/components/*"],
3038
"@contexts": ["./src/contexts/index"],
3139
"@contexts/*": ["./src/contexts/*"],

vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ export default defineConfig({
165165
"@utils": path.resolve(__dirname, "./src/utils"),
166166
"@validations": path.resolve(__dirname, "./src/validations"),
167167
"tailwind-config": path.resolve(__dirname, "./tailwind.config.cjs"),
168+
"@project-config": path.resolve(__dirname, "./src/components/organisms/configuration"),
169+
"@project-connections": path.resolve(__dirname, "./src/components/organisms/configuration/connections"),
170+
"@project-triggers": path.resolve(__dirname, "./src/components/organisms/configuration/triggers"),
171+
"@project-variables": path.resolve(__dirname, "./src/components/organisms/configuration/variables"),
168172
},
169173
},
170174
server: {

0 commit comments

Comments
 (0)