From 07165fb9af7d5fe8522923c22592047a61403f8d Mon Sep 17 00:00:00 2001 From: Andrea Cordoba Date: Fri, 18 Oct 2024 10:40:52 +0200 Subject: [PATCH] add code suggestions - add file comment - move css import ant the end of the import list - simplify default_url and description assignment to simplify conditional check --- .../admin/UpdateSessionEnvironmentButton.tsx | 4 ++-- .../dashboardV2/DashboardV2Sessions.tsx | 22 ++++++++++++++++++- .../UpdateSessionLauncherModal.tsx | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/client/src/features/admin/UpdateSessionEnvironmentButton.tsx b/client/src/features/admin/UpdateSessionEnvironmentButton.tsx index 685af6bbc..27db9eca2 100644 --- a/client/src/features/admin/UpdateSessionEnvironmentButton.tsx +++ b/client/src/features/admin/UpdateSessionEnvironmentButton.tsx @@ -105,8 +105,8 @@ function UpdateSessionEnvironmentModal({ environmentId: environment.id, container_image: data.container_image, name: data.name, - default_url: data.default_url?.trim() ? data.default_url : "", - description: data.description?.trim() ? data.description : "", + default_url: data.default_url?.trim() || "", + description: data.description?.trim() || "", port: data.port ?? undefined, working_directory: data.working_directory?.trim() || undefined, mount_directory: data.mount_directory?.trim() || undefined, diff --git a/client/src/features/dashboardV2/DashboardV2Sessions.tsx b/client/src/features/dashboardV2/DashboardV2Sessions.tsx index bf145228e..149a1caf9 100644 --- a/client/src/features/dashboardV2/DashboardV2Sessions.tsx +++ b/client/src/features/dashboardV2/DashboardV2Sessions.tsx @@ -1,13 +1,31 @@ +/*! + * Copyright 2024 - Swiss Data Science Center (SDSC) + * A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and + * Eidgenössische Technische Hochschule Zürich (ETHZ). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { SerializedError } from "@reduxjs/toolkit"; import { FetchBaseQueryError, skipToken } from "@reduxjs/toolkit/query"; import cx from "classnames"; import { Link, generatePath } from "react-router-dom-v5-compat"; import { Col, ListGroup, Row } from "reactstrap"; + import { Loader } from "../../components/Loader"; import EnvironmentLogsV2 from "../../components/LogsV2"; import { RtkErrorAlert } from "../../components/errors/RtkErrorAlert"; import { useGetSessionsQuery as useGetSessionsQueryV2 } from "../../features/sessionsV2/sessionsV2.api"; -import "../../notebooks/Notebooks.css"; import { ABSOLUTE_ROUTES } from "../../routing/routes.constants"; import useAppSelector from "../../utils/customHooks/useAppSelector.hook"; import { useGetProjectsByProjectIdQuery } from "../projectsV2/api/projectV2.enhanced-api"; @@ -18,6 +36,8 @@ import { } from "../sessionsV2/components/SessionStatus/SessionStatus"; import { SessionList, SessionV2 } from "../sessionsV2/sessionsV2.types"; +import "../../notebooks/Notebooks.css"; + export default function DashboardV2Sessions() { const { data: sessions, error, isLoading } = useGetSessionsQueryV2(); diff --git a/client/src/features/sessionsV2/components/SessionModals/UpdateSessionLauncherModal.tsx b/client/src/features/sessionsV2/components/SessionModals/UpdateSessionLauncherModal.tsx index f497cb68a..c6a337f5d 100644 --- a/client/src/features/sessionsV2/components/SessionModals/UpdateSessionLauncherModal.tsx +++ b/client/src/features/sessionsV2/components/SessionModals/UpdateSessionLauncherModal.tsx @@ -78,7 +78,7 @@ export default function UpdateSessionLauncherModal({ updateSessionLauncher({ launcherId: launcher.id, name, - description: description.trim() ? description : undefined, + description: description?.trim() || undefined, environment: environment.data, }); },