Skip to content

Commit c030fec

Browse files
temp
1 parent 3623ea1 commit c030fec

7 files changed

Lines changed: 139 additions & 82 deletions

File tree

client/src/components/buttons/Button.tsx

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -163,38 +163,6 @@ export function ButtonWithMenuV2({
163163
);
164164
}
165165

166-
export function SingleButtonWithMenu({
167-
children,
168-
className,
169-
color,
170-
direction,
171-
disabled,
172-
id,
173-
size,
174-
}: Omit<ButtonWithMenuV2Props, "default" | "preventPropagation">) {
175-
return (
176-
<UncontrolledDropdown
177-
className={className}
178-
color={color ?? "primary"}
179-
direction={direction ?? "down"}
180-
disabled={disabled}
181-
id={id}
182-
size={size ?? "md"}
183-
>
184-
<DropdownToggle
185-
caret={false}
186-
data-bs-toggle="dropdown"
187-
color={color ?? "primary"}
188-
data-cy="button-with-menu-dropdown"
189-
disabled={disabled}
190-
>
191-
<ThreeDotsVertical />
192-
</DropdownToggle>
193-
<DropdownMenu end>{children}</DropdownMenu>
194-
</UncontrolledDropdown>
195-
);
196-
}
197-
198166
/*
199167
* underline Link with icon
200168
*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type EntityTypes =
22
| "code-repository"
33
| "data-connector"
4+
| "project"
45
| "session-launcher";

client/src/components/offcanvas/OffcanvasHeaderWithType.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import cx from "classnames";
22
import {
33
Database,
44
FileCode,
5+
Folder,
56
PlayCircle,
67
QuestionCircle,
78
} from "react-bootstrap-icons";
@@ -31,6 +32,8 @@ export default function OffcanvasHeaderWithType({
3132
<PlayCircle className="me-1" />
3233
) : entityType === "code-repository" ? (
3334
<FileCode className="me-1" />
35+
) : entityType === "project" ? (
36+
<Folder className="me-1" />
3437
) : (
3538
<QuestionCircle className="me-1" />
3639
);
@@ -43,7 +46,9 @@ export default function OffcanvasHeaderWithType({
4346
? "Session launcher"
4447
: entityType === "code-repository"
4548
? "Code repository"
46-
: "Unknown";
49+
: entityType === "project"
50+
? "Project"
51+
: "Unknown";
4752

4853
return (
4954
<div>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// interface DataConnectorViewProps {
2+
// dataConnector: DataConnectorRead;
3+
// dataConnectorLink?: DataConnectorToProjectLink;
4+
// lastDeposit?: Deposit;
5+
// showView: boolean;
6+
// toggleView: () => void;
7+
// toggleEdit: (initialStep?: number) => void;
8+
// dataConnectorPotentiallyInaccessible?: boolean;
9+
// }
10+
11+
import cx from "classnames";
12+
import { generatePath } from "react-router";
13+
import { Offcanvas, OffcanvasBody } from "reactstrap";
14+
15+
import OffcanvasHeaderWithType from "~/components/offcanvas/OffcanvasHeaderWithType";
16+
import OffcanvasTopButtons from "~/components/offcanvas/OffcanvasTopButtons";
17+
import { ABSOLUTE_ROUTES } from "~/routing/routes.constants";
18+
import { Project } from "../projectsV2/api/projectV2.api";
19+
import ProjectInformation from "./ProjectPageContent/ProjectInformation/ProjectInformation";
20+
import ProjectCopyBanner from "./ProjectPageHeader/ProjectCopyBanner";
21+
import ProjectTemplateInfoBanner from "./ProjectPageHeader/ProjectTemplateInfoBanner";
22+
23+
interface ProjectInformationProps {
24+
isOffcanvasOpen: boolean;
25+
project: Project;
26+
toggleOffcanvas: () => void;
27+
}
28+
export default function ProjectOffcanvas({
29+
isOffcanvasOpen,
30+
project,
31+
toggleOffcanvas,
32+
}: ProjectInformationProps) {
33+
const fullPageLink = generatePath(ABSOLUTE_ROUTES.v2.projects.show.root, {
34+
namespace: project.namespace,
35+
slug: project.slug,
36+
});
37+
38+
return (
39+
<Offcanvas
40+
toggle={toggleOffcanvas}
41+
isOpen={isOffcanvasOpen}
42+
direction="end"
43+
backdrop={true}
44+
>
45+
<OffcanvasBody data-cy="project-offcanvas-view">
46+
<OffcanvasTopButtons
47+
entityType="project"
48+
fullPageLink={fullPageLink}
49+
toggleView={toggleOffcanvas}
50+
/>
51+
52+
<div className={cx("d-flex", "flex-column", "gap-3")}>
53+
<OffcanvasHeaderWithType
54+
entityType="project"
55+
title={project.name}
56+
></OffcanvasHeaderWithType>
57+
58+
{project.description && (
59+
<p className="mb-0" data-cy="project-description">
60+
{project.description}
61+
</p>
62+
)}
63+
{project.is_template && (
64+
<>
65+
<ProjectTemplateInfoBanner project={project} />
66+
<ProjectCopyBanner project={project} />
67+
</>
68+
)}
69+
70+
<ProjectInformation project={project} />
71+
</div>
72+
</OffcanvasBody>
73+
</Offcanvas>
74+
);
75+
}

client/src/features/ProjectPageV2/ProjectPageContent/ProjectInformation/ProjectInformation.tsx

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ function ProjectCopyTemplateInformationBox({ project }: { project: Project }) {
105105
}
106106

107107
interface ProjectInformationProps {
108-
output?: "plain" | "card";
108+
headerTag?: "h2" | "h3" | "h4";
109+
project: Project;
109110
}
110111
export default function ProjectInformation({
111-
output = "plain",
112+
headerTag = "h2",
113+
project,
112114
}: ProjectInformationProps) {
113-
const { project } = useProject();
114-
115115
const permissions = useProjectPermissions({ projectId: project.id });
116116

117117
const { data: members } = useGetProjectsByProjectIdMembersQuery({
@@ -208,29 +208,28 @@ export default function ProjectInformation({
208208
<ProjectCopyTemplateInformationBox project={project} />
209209
</div>
210210
);
211-
return output === "plain" ? (
212-
information
213-
) : (
211+
212+
const Header = headerTag;
213+
return (
214214
<Card data-cy="project-info-card">
215-
<CardHeader>
216-
<div
217-
className={cx(
218-
"align-items-center",
219-
"d-flex",
220-
"justify-content-between",
221-
)}
222-
>
223-
<h2 className="m-0">
224-
<InfoCircle className={cx("me-1", "bi")} />
225-
Info
226-
</h2>
215+
<CardHeader
216+
className={cx(
217+
"align-items-center",
218+
"d-flex",
219+
"justify-content-between",
220+
)}
221+
tag="div"
222+
>
223+
<Header className="m-0">
224+
<InfoCircle className={cx("me-1", "bi")} />
225+
Info
226+
</Header>
227227

228-
<div>
229-
<ProjectInformationButton
230-
userPermissions={permissions}
231-
project={project}
232-
/>
233-
</div>
228+
<div>
229+
<ProjectInformationButton
230+
userPermissions={permissions}
231+
project={project}
232+
/>
234233
</div>
235234
</CardHeader>
236235
<CardBody>{information}</CardBody>

client/src/features/ProjectPageV2/ProjectPageContent/ProjectInformation/ProjectInformationButton.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
* limitations under the License.
1717
*/
1818

19-
import cx from "classnames";
20-
import { useCallback, useState } from "react";
21-
import { DropdownItem } from "reactstrap";
19+
import { useCallback, useRef, useState } from "react";
20+
import { Button, UncontrolledTooltip } from "reactstrap";
2221

2322
import { useGetUserQueryState } from "~/features/usersV2/api/users.api";
24-
import { SingleButtonWithMenu } from "../../../../components/buttons/Button";
2523
import BootstrapCopyIcon from "../../../../components/icons/BootstrapCopyIcon";
2624
import type { Project } from "../../../projectsV2/api/projectV2.api";
2725
import ProjectCopyModal from "../../ProjectPageHeader/ProjectCopyModal";
@@ -38,27 +36,29 @@ export default function ProjectInformationButton({
3836
const toggleCopyModal = useCallback(() => {
3937
setCopyModalOpen((open) => !open);
4038
}, []);
39+
const ref = useRef(null);
40+
4141
const isUserLoggedIn = !!currentUser?.isLoggedIn;
4242
if (!isUserLoggedIn) return null;
4343
return (
44-
<>
45-
<SingleButtonWithMenu color="outline-primary" size="sm">
46-
<DropdownItem
47-
data-cy="project-copy-menu-item"
48-
onClick={toggleCopyModal}
49-
>
50-
<BootstrapCopyIcon className={cx("bi")} />
51-
<span className={cx("ms-2")}>Copy project</span>
52-
</DropdownItem>
53-
</SingleButtonWithMenu>
54-
{
55-
<ProjectCopyModal
56-
currentUser={currentUser}
57-
isOpen={isCopyModalOpen}
58-
project={project}
59-
toggle={toggleCopyModal}
60-
/>
61-
}
62-
</>
44+
<div ref={ref}>
45+
<Button
46+
color="outline-primary"
47+
data-cy="project-copy-button"
48+
onClick={toggleCopyModal}
49+
size="sm"
50+
>
51+
<BootstrapCopyIcon />
52+
</Button>
53+
<UncontrolledTooltip target={ref} trigger="hover">
54+
Copy project
55+
</UncontrolledTooltip>
56+
<ProjectCopyModal
57+
currentUser={currentUser}
58+
isOpen={isCopyModalOpen}
59+
project={project}
60+
toggle={toggleCopyModal}
61+
/>
62+
</div>
6363
);
6464
}

client/src/features/ProjectPageV2/ProjectPageContent/ProjectOverviewPage.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
* limitations under the License
1717
*/
1818

19+
import { useState } from "react";
1920
import { Col, Row } from "reactstrap";
2021

2122
import { useProject } from "~/routes/projects/root";
2223
import SessionsV2 from "../../sessionsV2/SessionsV2";
24+
import ProjectOffcanvas from "../ProjectOffcanvas";
2325
import { CodeRepositoriesDisplay } from "./CodeRepositories/RepositoriesBox";
2426
import ProjectDataConnectorsBox from "./DataConnectors/ProjectDataConnectorsBox";
2527
import Documentation from "./Documentation/Documentation";
@@ -28,6 +30,8 @@ import ProjectInformation from "./ProjectInformation/ProjectInformation";
2830
export default function ProjectOverviewPage() {
2931
const { project } = useProject();
3032

33+
const [isOffcanvasOpen, setIsOffcanvasOpen] = useState(true);
34+
3135
return (
3236
<Row className="g-4">
3337
<Col xs={12} md={8} xl={9}>
@@ -48,9 +52,14 @@ export default function ProjectOverviewPage() {
4852
</Col>
4953
<Col xs={12} md={4} xl={3}>
5054
<div className="mb-3">
51-
<ProjectInformation output="card" />
55+
<ProjectInformation project={project} />
5256
</div>
5357
</Col>
58+
<ProjectOffcanvas
59+
isOffcanvasOpen={isOffcanvasOpen}
60+
project={project}
61+
toggleOffcanvas={() => setIsOffcanvasOpen(!isOffcanvasOpen)}
62+
/>
5463
</Row>
5564
);
5665
}

0 commit comments

Comments
 (0)