From 5ae2f828afbc5293535c7fd2481407af1aaeb56e Mon Sep 17 00:00:00 2001 From: gokhangunduz Date: Wed, 16 Aug 2023 17:34:43 +0300 Subject: [PATCH] refactor(robot-header): :tada: update robot header with services component --- package.json | 2 +- src/components/Button/Button.tsx | 2 +- src/components/Cells/StateCell.tsx | 1 + src/components/RobotHeader/RobotHeader.tsx | 34 +------------- .../RobotServiceButtons.tsx | 44 +++++++++++++++++++ .../VersionViewer/VersionViewer.tsx | 25 ++++++----- src/helpers/envProvider.ts | 5 +++ src/pages/RobotPage/Overview/Overview.tsx | 20 +++++++++ src/pages/RobotPage/RobotPage.tsx | 9 ++-- src/toolkit/RobotSlice.ts | 7 +-- 10 files changed, 96 insertions(+), 53 deletions(-) create mode 100644 src/components/RobotServiceButtons/RobotServiceButtons.tsx diff --git a/package.json b/package.json index 4749805c..ae852f55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.12.5", + "version": "0.12.6", "private": true, "dependencies": { "@emotion/css": "^11.10.6", diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 1b8a8a6e..d90297b6 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -4,7 +4,7 @@ interface ButtonProps { type?: "button" | "submit" | "reset"; text: any; onClick?: () => void; - loading?: boolean; + loading?: boolean | null; disabled?: boolean; className?: string; } diff --git a/src/components/Cells/StateCell.tsx b/src/components/Cells/StateCell.tsx index 18ed1a7d..7a16b7a9 100644 --- a/src/components/Cells/StateCell.tsx +++ b/src/components/Cells/StateCell.tsx @@ -85,6 +85,7 @@ export default function StateCell({ state, isRobolaunchState }: IStateCell) { state === "WaitingForCredentials" || state === "ConfiguringEnvironment" || state === "CreatingDevelopmentSuite" || + state === "ConfiguringWorkspaces" || state === "BuildingRobot" ? (
{url?.robotName} -
@@ -55,43 +54,14 @@ export default function RobotHeader({ {url?.organizationName} Organization - Ankara, Turkiye
-
-
- - -
+ + + +
+ ); +} diff --git a/src/components/VersionViewer/VersionViewer.tsx b/src/components/VersionViewer/VersionViewer.tsx index 199f0117..b3454624 100644 --- a/src/components/VersionViewer/VersionViewer.tsx +++ b/src/components/VersionViewer/VersionViewer.tsx @@ -1,23 +1,24 @@ -import React from "react"; +import React, { ReactElement } from "react"; import packageJSON from "../../../package.json"; +import { envFrontendUrl, isProduction } from "../../helpers/envProvider"; + +export default function VersionViewer(): ReactElement { + const developmentURL = `http://localhost:3000${ + window.location.href?.split("robolaunch.cloud")[1] || "" + }`; + + const productionURL = `${envFrontendUrl}${ + window.location.href?.split("3000")[1] || "" + }`; -export default function VersionViewer() { return (
{ - if (process.env.NODE_ENV === "development") { - window.location.href = `${process.env.REACT_APP_FRONTEND_URL}${ - window.location.href?.split("3000")[1] || "" - }`; - } else if (process.env.NODE_ENV === "production") { - window.location.href = `http://localhost:3000${ - window.location.href?.split("robolaunch.cloud")[1] || "" - }`; - } + window.location.href = isProduction ? developmentURL : productionURL; }} className="fixed bottom-0 right-1 z-50 text-[0.64rem] text-layer-light-700 cursor-crosshair" > - {process.env.NODE_ENV === "production" ? "P" : "D"} {packageJSON?.version} + {isProduction ? "P" : "D"} {packageJSON?.version}
); } diff --git a/src/helpers/envProvider.ts b/src/helpers/envProvider.ts index 7ad728ac..84a84368 100644 --- a/src/helpers/envProvider.ts +++ b/src/helpers/envProvider.ts @@ -1,2 +1,7 @@ export const envOnPremise: boolean = process.env.REACT_APP_ON_PREMISE === "true" ? true : false; + +export const envFrontendUrl: string = process.env.REACT_APP_FRONTEND_URL || ""; + +export const isProduction: boolean = + process.env.NODE_ENV === "production" ? true : false; diff --git a/src/pages/RobotPage/Overview/Overview.tsx b/src/pages/RobotPage/Overview/Overview.tsx index 2805defe..3e0d86d5 100644 --- a/src/pages/RobotPage/Overview/Overview.tsx +++ b/src/pages/RobotPage/Overview/Overview.tsx @@ -35,12 +35,32 @@ export default function Overview({ component={ envOnPremise ? (