Skip to content

Commit f43511a

Browse files
refactor: fix some admin page modals, titles and content visual glitches (#3894)
1 parent 0b2e433 commit f43511a

File tree

8 files changed

+117
-101
lines changed

8 files changed

+117
-101
lines changed

client/src/components/container/CollapseBody.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ export default function CollapseBody({
2727
className,
2828
children,
2929
}: CollapseBodyProps) {
30+
const customMarginStart = /\bms-(?:auto|[0-5])\b/.test(className ?? "");
31+
const customPaddingStart = /\bps-(?:auto|[0-5])\b/.test(className ?? "");
32+
3033
return (
3134
<div
3235
className={cx(
3336
"border-3",
3437
"border-dark-subtle",
3538
"border-start",
36-
"ms-1",
37-
"ps-2",
39+
!customMarginStart && "ms-1",
40+
!customPaddingStart && "ps-2",
3841
className
3942
)}
4043
>

client/src/features/admin/AddSessionEnvironmentButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function AddSessionEnvironmentButton() {
4545

4646
return (
4747
<>
48-
<Button className="btn-outline-rk-green" onClick={toggle}>
48+
<Button color="primary" onClick={toggle}>
4949
<PlusLg className={cx("bi", "me-1")} />
5050
Add Session Environment
5151
</Button>
@@ -128,7 +128,7 @@ function AddSessionEnvironmentModal({
128128
toggle={toggle}
129129
>
130130
<Form
131-
className="form-rk-green"
131+
className="modal-content"
132132
noValidate
133133
onSubmit={handleSubmit(onSubmit)}
134134
>
@@ -140,11 +140,11 @@ function AddSessionEnvironmentModal({
140140
<SessionEnvironmentFormContent control={control} errors={errors} />
141141
</ModalBody>
142142
<ModalFooter>
143-
<Button className="btn-outline-rk-green" onClick={toggle}>
143+
<Button color="outline-primary" onClick={toggle}>
144144
<XLg className={cx("bi", "me-1")} />
145145
Cancel
146146
</Button>
147-
<Button disabled={result.isLoading} type="submit">
147+
<Button color="primary" disabled={result.isLoading} type="submit">
148148
{result.isLoading ? (
149149
<Loader className="me-1" inline size={16} />
150150
) : (

client/src/features/admin/ConnectedServicesSection.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import UpdateConnectedServiceButton from "./UpdateConnectedServiceButton";
4444
export default function ConnectedServicesSection() {
4545
return (
4646
<section className="mt-4">
47-
<h2 className="fs-4">Integrations</h2>
47+
<h2>Integrations</h2>
4848
<ConnectedServices />
4949
</section>
5050
);
@@ -103,10 +103,7 @@ function ConnectedService({ provider }: ConnectedServiceProps) {
103103
return (
104104
<Col xs={12} md={6}>
105105
<Card>
106-
<CardHeader
107-
className={cx("bg-white", "border-0", "rounded", "fs-6", "p-0")}
108-
tag="h5"
109-
>
106+
<CardHeader className={cx("fs-4", "p-0")} tag="h3">
110107
<button
111108
className={cx(
112109
"align-items-center",

client/src/features/admin/DeleteSessionEnvironmentButton.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,16 @@ function DeleteSessionEnvironmentModal({
8686
}, [isOpen, result]);
8787

8888
return (
89-
<Modal
90-
backdrop="static"
91-
centered
92-
fullscreen="lg"
93-
isOpen={isOpen}
94-
size="lg"
95-
toggle={toggle}
96-
>
89+
<Modal backdrop="static" centered isOpen={isOpen} size="lg" toggle={toggle}>
9790
<ModalHeader tag="h2" toggle={toggle}>
9891
Are you sure?
9992
</ModalHeader>
10093
<ModalBody>
10194
{result.error && <RtkErrorAlert error={result.error} />}
10295

10396
<p className="mb-0">
104-
Please confirm that you want to delete the {environment.name} session
105-
environment.
97+
Please confirm that you want to delete the{" "}
98+
<code>{environment.name}</code> session environment.
10699
</p>
107100
</ModalBody>
108101
<ModalFooter>

client/src/features/admin/SessionEnvironmentAdvancedFields.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function SessionEnvironmentAdvancedFields({
6666
</button>
6767

6868
<Collapse isOpen={isAdvancedSettingOpen}>
69-
<CollapseBody className="mt-1">
69+
<CollapseBody className={cx("ms-0", "mt-4")}>
7070
<AdvancedSettingsFields<SessionEnvironmentForm>
7171
control={control}
7272
errors={errors}

client/src/features/admin/SessionEnvironmentsSection.tsx

Lines changed: 90 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717
*/
1818

1919
import cx from "classnames";
20+
import { useCallback, useState } from "react";
2021
import {
2122
Card,
2223
CardBody,
24+
CardHeader,
2325
CardText,
24-
CardTitle,
2526
Col,
27+
Collapse,
2628
Container,
2729
Row,
2830
} from "reactstrap";
2931

3032
import { CommandCopy } from "~/components/commandCopy/CommandCopy";
3133
import { RtkErrorAlert } from "~/components/errors/RtkErrorAlert";
3234
import { ErrorLabel } from "~/components/formlabels/FormLabels";
35+
import ChevronFlippedIcon from "~/components/icons/ChevronFlippedIcon";
3336
import { Loader } from "~/components/Loader";
3437
import { TimeCaption } from "~/components/TimeCaption";
3538
import type {
@@ -45,7 +48,7 @@ import UpdateSessionEnvironmentButton from "./UpdateSessionEnvironmentButton";
4548
export default function SessionEnvironmentsSection() {
4649
return (
4750
<section className="mt-4">
48-
<h2 className="fs-4">Session Environments - Renku 2.0</h2>
51+
<h2>Session Environments</h2>
4952
<SessionEnvironments />
5053
</section>
5154
);
@@ -121,69 +124,95 @@ function SessionEnvironmentDisplay({
121124
strip_path_prefix,
122125
} = environment;
123126

127+
const [isOpen, setIsOpen] = useState(false);
128+
const toggle = useCallback(() => {
129+
setIsOpen((isOpen) => !isOpen);
130+
}, []);
131+
124132
return (
125133
<Col className={cx("col-12", "col-sm-6")}>
126134
<Card>
127-
<CardBody>
128-
<CardTitle className={cx("mb-0", "fs-5")} tag="h5">
129-
{name}
130-
</CardTitle>
131-
<CardText className="mb-0">
132-
{description ? description : <i>No description</i>}
133-
</CardText>
134-
<CardText className="mb-0" tag="div">
135-
<CommandCopy command={container_image} />
136-
</CardText>
137-
<CardText className="mb-0">
138-
{default_url ? (
139-
<>
140-
Default URL: <code>{default_url}</code>
141-
</>
142-
) : (
143-
<i>
144-
No default URL {"("}will use <code>{"/lab"}</code>
145-
{")"}
146-
</i>
135+
<CardHeader className={cx("fs-4", "p-0")} tag="h3">
136+
<button
137+
className={cx(
138+
"align-items-center",
139+
"bg-transparent",
140+
"border-0",
141+
"d-flex",
142+
"fw-bold",
143+
"gap-3",
144+
"p-3",
145+
"w-100"
147146
)}
148-
</CardText>
149-
<CardText className="mb-0">
150-
Mount directory: <code>{mount_directory}</code>
151-
</CardText>
152-
<CardText className="mb-0">
153-
Work directory: <code>{working_directory}</code>
154-
</CardText>
155-
<CardText className="mb-0">
156-
Port: <code>{port}</code>
157-
</CardText>
158-
<CardText className="mb-0">
159-
GID: <code>{gid}</code>
160-
</CardText>
161-
<CardText className="mb-0">
162-
UID: <code>{uid}</code>
163-
</CardText>
164-
<CardText className="mb-0">
165-
Command:{" "}
166-
<EnvironmentCode value={command ? safeStringify(command) : "-"} />
167-
</CardText>
168-
<CardText className="mb-0">
169-
Args: <EnvironmentCode value={args ? safeStringify(args) : "-"} />
170-
</CardText>
171-
<CardText className="mb-0">
172-
Strip path prefix: {strip_path_prefix ? "Yes" : "No"}
173-
</CardText>
174-
<CardText>
175-
<TimeCaption
176-
datetime={creation_date}
177-
enableTooltip
178-
prefix="Created"
179-
/>
180-
</CardText>
181-
182-
<div className={cx("d-flex", "justify-content-end", "gap-2")}>
183-
<UpdateSessionEnvironmentButton environment={environment} />
184-
<DeleteSessionEnvironmentButton environment={environment} />
185-
</div>
186-
</CardBody>
147+
onClick={toggle}
148+
type="button"
149+
>
150+
{name}
151+
<div className="ms-auto">
152+
<ChevronFlippedIcon flipped={isOpen} />
153+
</div>
154+
</button>
155+
</CardHeader>
156+
157+
<Collapse isOpen={isOpen}>
158+
<CardBody className="pt-0">
159+
<CardText className="mb-0">
160+
{description ? description : <i>No description</i>}
161+
</CardText>
162+
<CardText className="mb-0" tag="div">
163+
<CommandCopy command={container_image} />
164+
</CardText>
165+
<CardText className="mb-0">
166+
{default_url ? (
167+
<>
168+
Default URL: <code>{default_url}</code>
169+
</>
170+
) : (
171+
<i>
172+
No default URL {"("}will use <code>{"/lab"}</code>
173+
{")"}
174+
</i>
175+
)}
176+
</CardText>
177+
<CardText className="mb-0">
178+
Mount directory: <code>{mount_directory}</code>
179+
</CardText>
180+
<CardText className="mb-0">
181+
Work directory: <code>{working_directory}</code>
182+
</CardText>
183+
<CardText className="mb-0">
184+
Port: <code>{port}</code>
185+
</CardText>
186+
<CardText className="mb-0">
187+
GID: <code>{gid}</code>
188+
</CardText>
189+
<CardText className="mb-0">
190+
UID: <code>{uid}</code>
191+
</CardText>
192+
<CardText className="mb-0">
193+
Command:{" "}
194+
<EnvironmentCode value={command ? safeStringify(command) : "-"} />
195+
</CardText>
196+
<CardText className="mb-0">
197+
Args: <EnvironmentCode value={args ? safeStringify(args) : "-"} />
198+
</CardText>
199+
<CardText className="mb-0">
200+
Strip path prefix: {strip_path_prefix ? "Yes" : "No"}
201+
</CardText>
202+
<CardText>
203+
<TimeCaption
204+
datetime={creation_date}
205+
enableTooltip
206+
prefix="Created"
207+
/>
208+
</CardText>
209+
210+
<div className={cx("d-flex", "justify-content-end", "gap-2")}>
211+
<UpdateSessionEnvironmentButton environment={environment} />
212+
<DeleteSessionEnvironmentButton environment={environment} />
213+
</div>
214+
</CardBody>
215+
</Collapse>
187216
</Card>
188217
</Col>
189218
);

client/src/features/admin/UpdateSessionEnvironmentButton.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ import SessionEnvironmentFormContent, {
3939
SessionEnvironmentForm,
4040
} from "./SessionEnvironmentFormContent";
4141

42-
import ButtonStyles from "~/components/buttons/Buttons.module.scss";
43-
4442
interface UpdateSessionEnvironmentButtonProps {
4543
environment: SessionEnvironment;
4644
}
@@ -55,17 +53,9 @@ export default function UpdateSessionEnvironmentButton({
5553

5654
return (
5755
<>
58-
<Button
59-
className={cx(
60-
"bg-transparent",
61-
"shadow-none",
62-
"border-0",
63-
ButtonStyles.EditButton
64-
)}
65-
onClick={toggle}
66-
>
67-
<PencilSquare size={24} />
68-
<span className="visually-hidden">Edit</span>
56+
<Button color="outline-primary" onClick={toggle}>
57+
<PencilSquare className={cx("bi", "me-1")} />
58+
Edit
6959
</Button>
7060
<UpdateSessionEnvironmentModal
7161
environment={environment}
@@ -153,7 +143,7 @@ function UpdateSessionEnvironmentModal({
153143
toggle={toggle}
154144
>
155145
<Form
156-
className="form-rk-green"
146+
className="modal-content"
157147
noValidate
158148
onSubmit={handleSubmit(onSubmit)}
159149
>
@@ -165,11 +155,15 @@ function UpdateSessionEnvironmentModal({
165155
<SessionEnvironmentFormContent control={control} errors={errors} />
166156
</ModalBody>
167157
<ModalFooter>
168-
<Button className="btn-outline-rk-green" onClick={toggle}>
158+
<Button color="outline-primary" onClick={toggle}>
169159
<XLg className={cx("bi", "me-1")} />
170160
Cancel
171161
</Button>
172-
<Button disabled={result.isLoading || !isDirty} type="submit">
162+
<Button
163+
color="primary"
164+
disabled={result.isLoading || !isDirty}
165+
type="submit"
166+
>
173167
{result.isLoading ? (
174168
<Loader className="me-1" inline size={16} />
175169
) : (

client/src/features/sessionsV2/components/SessionForm/AdvancedSettingsFields.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export function AdvancedSettingsFields<
257257
return (
258258
<>
259259
<div className={cx("row", "gy-3", "mb-3")}>
260-
<div className={cx("col-12", "col-md-9")}>
260+
<div className={cx("col-12", "col-md-9", "mt-0")}>
261261
<FormField<T>
262262
control={control}
263263
name={"default_url" as Path<T>}
@@ -268,7 +268,7 @@ export function AdvancedSettingsFields<
268268
type="text"
269269
/>
270270
</div>
271-
<div className={cx("col-12", "col-md-3")}>
271+
<div className={cx("col-12", "col-md-3", "mt-md-0")}>
272272
<FormField<T>
273273
control={control}
274274
name={"port" as Path<T>}

0 commit comments

Comments
 (0)