webstudio/ui/src/features/all_projects/presentation/all_projects_screen.tsx

65 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-11-10 12:06:40 +03:00
import * as React from "react";
2023-11-16 00:40:35 +03:00
import { AllProjectStore } from "./all_projects_store";
import { ProjectRepository } from "../data/project_repository";
import { LoadPage } from "../../../core/ui/pages/load_page";
import { observer } from "mobx-react-lite";
2023-11-10 12:06:40 +03:00
import { SelectProjectScreenPath } from "../../select_project/presentation/select_project";
2023-12-28 17:18:12 +03:00
import { useNavigate } from "react-router-dom";
import { Button } from "antd";
import { PipelineInstanceScreenPath } from "../../pipeline_instance_main_screen/pipeline_instance_screen";
2023-11-10 12:06:40 +03:00
export const AllProjectScreenPath = "/";
2023-11-16 00:40:35 +03:00
export const AllProjectScreen: React.FunctionComponent = observer(() => {
2023-12-28 17:18:12 +03:00
const [allProjectStore] = React.useState(() => new AllProjectStore(new ProjectRepository()));
const navigate = useNavigate();
React.useEffect(() => {
allProjectStore.init();
}, [allProjectStore]);
2023-11-16 00:40:35 +03:00
2023-11-10 12:06:40 +03:00
return (
<>
2023-11-16 00:40:35 +03:00
<LoadPage
2023-11-14 20:44:06 +03:00
largeText={"Projects"}
2023-11-16 00:40:35 +03:00
needBackButton={false}
minText="create project?"
path={SelectProjectScreenPath}
isError={allProjectStore.isError}
isLoading={allProjectStore.isLoading}
children={
<div>
2023-12-28 17:18:12 +03:00
<h1>Projects</h1>
<h5 style={{ backgroundColor: "ButtonShadow" }}>
<Button
onClick={() => {
navigate(PipelineInstanceScreenPath + allProjectStore.activePipeline?.projectUUID ?? "");
}}
>
Project main panel
</Button>
{allProjectStore.activePipeline?.projectUUID ?? "loading"}
</h5>
2023-11-16 00:40:35 +03:00
{allProjectStore.projectsModels?.map((el) => {
2023-12-28 17:18:12 +03:00
return (
<div style={{ margin: "10px", backgroundColor: "Highlight" }}>
<Button
onClick={() => {
allProjectStore.setPipelineActive(el._id ?? "").then(() => {
allProjectStore.init();
navigate(PipelineInstanceScreenPath + el._id ?? "");
});
}}
>
set active project
</Button>
<div style={{ margin: "10px", display: "contents" }}> {el.description}</div>
</div>
);
2023-11-16 00:40:35 +03:00
})}
</div>
}
2023-11-10 12:06:40 +03:00
/>
</>
);
2023-11-16 00:40:35 +03:00
});