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

53 lines
1.7 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-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";
import { CreateProjectScreenPath } from "../../create_project/create_project_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(() => {
const [store] = React.useState(() => new AllProjectStore(new ProjectRepository()));
2023-12-28 17:18:12 +03:00
const navigate = useNavigate();
React.useEffect(() => {
store.init();
}, [store]);
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={CreateProjectScreenPath}
2024-06-04 13:19:22 +03:00
isError={false}
isLoading={store.isLoading}
2023-11-16 00:40:35 +03:00
children={
<div>
{store.projectsModels?.map((el) => {
2023-12-28 17:18:12 +03:00
return (
<div style={{ margin: "10px", backgroundColor: "Highlight" }}>
{el.isActive ? (
<Button
onClick={() => {
navigate(`${PipelineInstanceScreenPath}${el._id}`);
}}
>
instance screen
</Button>
) : null}
2023-12-28 17:18:12 +03:00
<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
});