|
| 1 | +/*! |
| 2 | + * Copyright 2025 - Swiss Data Science Center (SDSC) |
| 3 | + * A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and |
| 4 | + * Eidgenössische Technische Hochschule Zürich (ETHZ). |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +import cx from "classnames"; |
| 20 | +import { Col, Row } from "reactstrap"; |
| 21 | +import { Project } from "../../projectsV2/api/projectV2.api"; |
| 22 | +import ActiveSessionButton from "../components/SessionButton/ActiveSessionButton"; |
| 23 | +import { |
| 24 | + getSessionStatusStyles, |
| 25 | + SessionStatusV2Description, |
| 26 | + SessionStatusV2Label, |
| 27 | +} from "../components/SessionStatus/SessionStatus"; |
| 28 | +import { getShowSessionUrlByProject } from "../SessionsV2"; |
| 29 | +import { SessionV2 } from "../sessionsV2.types"; |
| 30 | +import styles from "./Session.module.scss"; |
| 31 | + |
| 32 | +interface SessionCardProps { |
| 33 | + project: Project; |
| 34 | + session?: SessionV2; |
| 35 | +} |
| 36 | +export default function SessionCard({ project, session }: SessionCardProps) { |
| 37 | + if (!session) return null; |
| 38 | + |
| 39 | + const stylesPerSession = getSessionStatusStyles(session); |
| 40 | + |
| 41 | + return ( |
| 42 | + <div |
| 43 | + data-cy="session-item" |
| 44 | + className={cx( |
| 45 | + `bg-${stylesPerSession.bgColor}`, |
| 46 | + `bg-opacity-${stylesPerSession.bgOpacity}`, |
| 47 | + "p-0", |
| 48 | + "pb-3" |
| 49 | + )} |
| 50 | + > |
| 51 | + <img |
| 52 | + src={stylesPerSession.sessionLine} |
| 53 | + className={cx("position-absolute", styles.SessionLine)} |
| 54 | + alt="Session line indicator" |
| 55 | + loading="lazy" |
| 56 | + /> |
| 57 | + <div className={cx("ms-5", "px-3", "pt-3")}> |
| 58 | + <Row className="g-2"> |
| 59 | + <Col xs={12} xl="auto"> |
| 60 | + <Row className="g-2"> |
| 61 | + <Col |
| 62 | + xs={12} |
| 63 | + xl={12} |
| 64 | + className={cx( |
| 65 | + "d-inline-block", |
| 66 | + "link-primary", |
| 67 | + "text-body", |
| 68 | + "mt-1" |
| 69 | + )} |
| 70 | + > |
| 71 | + <span className={cx("small", "text-muted", "me-3")}> |
| 72 | + Session |
| 73 | + </span> |
| 74 | + </Col> |
| 75 | + <Col |
| 76 | + className={cx("align-items-center", "mt-0", "gap-2")} |
| 77 | + xs="12" |
| 78 | + xl="auto" |
| 79 | + > |
| 80 | + <SessionStatusV2Label session={session} /> |
| 81 | + </Col> |
| 82 | + <Col |
| 83 | + xs="auto" |
| 84 | + className={cx("mt-0", "ms-0", "ms-xl-3", "d-flex")} |
| 85 | + > |
| 86 | + <SessionStatusV2Description |
| 87 | + session={session} |
| 88 | + showInfoDetails={false} |
| 89 | + /> |
| 90 | + </Col> |
| 91 | + </Row> |
| 92 | + </Col> |
| 93 | + <Col |
| 94 | + xs={12} |
| 95 | + xl="auto" |
| 96 | + className={cx("d-flex", "ms-md-auto", "justify-content-end")} |
| 97 | + > |
| 98 | + <div> |
| 99 | + <ActiveSessionButton |
| 100 | + session={session} |
| 101 | + showSessionUrl={getShowSessionUrlByProject( |
| 102 | + project, |
| 103 | + session.name |
| 104 | + )} |
| 105 | + /> |
| 106 | + </div> |
| 107 | + </Col> |
| 108 | + </Row> |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + ); |
| 112 | +} |
0 commit comments