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

feat: add project settings (edit name, description, tags ...) #5

Merged
merged 5 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
109 changes: 109 additions & 0 deletions webui/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,71 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateProject",
"description": null,
"args": [
{
"name": "description",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "name",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "tags",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "OBJECT",
"name": "Project",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
Expand Down Expand Up @@ -1344,6 +1409,30 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "description",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "displayName",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": null,
Expand Down Expand Up @@ -1459,6 +1548,26 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "tags",
"description": null,
"args": [],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
Expand Down
106 changes: 78 additions & 28 deletions webui/src/Components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { FC } from "react";
import { Github } from "@styled-icons/bootstrap";
import { EllipsisVertical } from "@styled-icons/fa-solid";
import { StatefulPopover } from "baseui/popover";
import { StatefulMenu } from "baseui/menu";
import { Breadcrumbs } from "baseui/breadcrumbs";
import styles, { Link, Container, RunButton, PopoverButton } from "./styles";
import styles, {
Link,
Container,
RunButton,
PopoverButton,
GithubLink,
} from "./styles";
import { Spinner } from "baseui/spinner";
import { Project, Repository } from "../../Hooks/GraphQL";

export type HeaderProps = {
id: string;
Expand All @@ -13,40 +21,82 @@ export type HeaderProps = {
breadcrumbs?: { title: string; link?: string }[];
showRunButton?: boolean;
loading?: boolean;
linkedRepository?: Repository | null;
project?: Project | null;
};

const Header: FC<HeaderProps> = (props) => {
const { id, breadcrumbs, onRun, menu, showRunButton } = props;
const { id, breadcrumbs, onRun, menu, showRunButton, linkedRepository } =
props;
return (
<Container>
<Breadcrumbs
overrides={{
Root: {
style: {
display: "flex",
flexDirection: "row",
alignItems: "center",
flex: 1,
},
},
ListItem: {
style: ({ $theme }) => ({
fontFamily: $theme.primaryFontFamily,
}),
},
<div
style={{
marginRight: 15,
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<img
src={props.project?.picture}
style={{ maxHeight: 34, maxWidth: 34 }}
/>
</div>
<div
style={{
flex: 1,
display: "flex",
flexDirection: "column",
justifyContent: "center",
}}
>
{breadcrumbs?.map(({ title, link }, index) => {
if (link) {
return (
<Link key={index} to={link} style={{ color: "#ffffffb0" }}>
{title}
</Link>
);
}
return <span key={index}>{title}</span>;
})}
</Breadcrumbs>
<Breadcrumbs
overrides={{
Root: {
style: {
display: "flex",
flexDirection: "row",
alignItems: "center",
flex: 1,
},
},
ListItem: {
style: ({ $theme }) => ({
fontFamily: $theme.primaryFontFamily,
}),
},
}}
>
{breadcrumbs?.map(({ title, link }, index) => {
if (link) {
return (
<Link key={index} to={link} style={{ color: "#ffffffb0" }}>
{title}
</Link>
);
}
return <span key={index}>{title}</span>;
})}
</Breadcrumbs>
<p
style={{
fontSize: 14,
margin: 0,
marginTop: 3,
color: "rgba(255, 255, 255, 0.75)",
}}
>
{props.project?.description}
</p>
</div>
{linkedRepository && (
<div style={{ display: "flex", alignItems: "center", marginRight: 20 }}>
<GithubLink href={linkedRepository.repoUrl} target="_blank">
<Github size={20} />
</GithubLink>
</div>
)}
{!!menu?.length && (
<StatefulPopover
placement="bottomRight"
Expand Down
27 changes: 17 additions & 10 deletions webui/src/Components/Header/HeaderWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
useGetRunLazyQuery,
useRunPipelineMutation,
} from "../../Hooks/GraphQL";
import { useRecoilValue } from "recoil";
import { useRecoilState, useRecoilValue } from "recoil";
import { ComposerState } from "../../Containers/Project/MainContent/Composer/ComposerState";
import { AuthState } from "../../Containers/Auth/AuthState";
import { ProjectState } from "../../Containers/Project/ProjectState";

export type HeaderWithDataProps = {
breadcrumbs?: { title: string; link?: string }[];
Expand All @@ -26,7 +27,7 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
const navigate = useNavigate();
const { pathname } = useLocation();
const { id } = useParams();
const [project, setProject] = useState<Project | null | undefined>(null);
const [{ project }, setProjectState] = useRecoilState(ProjectState);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [actions, setActions] = useState<any[]>([]);
const [run, setRun] = useState<Run | null | undefined>(null);
Expand All @@ -45,7 +46,7 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
const [getActions] = useGetActionsLazyQuery();
const { data } = useGetActionsQuery({
variables: {
projectId: project?.id || "",
projectId: id!,
},
fetchPolicy: "cache-and-network",
});
Expand All @@ -55,6 +56,9 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
const [getLinkedRepository] = useGetLinkedRepositoryLazyQuery();
const [loading, setLoading] = useState(false);

const setProject = (value?: Project | null) =>
setProjectState({ project: value });

useEffect(() => {
if (pathname.startsWith("/run")) {
getRun().then(({ data }) => {
Expand Down Expand Up @@ -86,16 +90,16 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
}, [pathname]);

useEffect(() => {
if (!me || !project) {
if (!me || !id) {
return;
}
getLinkedRepository({
variables: {
projectId: project.id,
projectId: pathname.startsWith("/run") ? project!.id : id,
},
fetchPolicy: "cache-and-network",
fetchPolicy: "network-only",
}).then((res) => setLinkedRepository(res.data?.linkedRepository));
}, [me, getLinkedRepository, project]);
}, [me, getLinkedRepository, id, project, pathname]);

useEffect(() => {
if (!data) {
Expand Down Expand Up @@ -124,7 +128,7 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
link: "/",
},
{
title: project?.name || "",
title: project?.displayName || project?.name || "",
link: run && project?.id ? `/project/${project.id}` : undefined,
},
];
Expand All @@ -142,7 +146,7 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
setTimeout(() => {
getActions({
variables: {
projectId: project.id,
projectId: pathname.startsWith("/run") ? project!.id : id!,
},
fetchPolicy: "cache-and-network",
}).then(({ data }) => {
Expand All @@ -161,11 +165,14 @@ const HeaderWithData: FC<HeaderWithDataProps> = () => {
showRunButton={
!!project &&
!pathname.startsWith("/link-project") &&
(!!actions?.filter((x) => x.enabled).length ||
((project?.path !== "empty" &&
!!actions?.filter((x) => x.enabled).length) ||
(project?.path !== "empty" && !linkedRepository) ||
(!!linkedRepository && !!actions?.filter((x) => x.enabled).length))
}
loading={loading}
linkedRepository={linkedRepository}
project={project}
/>
);
};
Expand Down
Loading
Loading