diff --git a/ui/.vscode/extensions.json b/ui/.vscode/extensions.json new file mode 100644 index 0000000..bcb8510 --- /dev/null +++ b/ui/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "SonarSource.sonarlint-vscode"], + "unwantedRecommendations": [] +} diff --git a/ui/README.md b/ui/README.md index 3271e6d..f8ec44c 100644 --- a/ui/README.md +++ b/ui/README.md @@ -1,6 +1,6 @@ # SwarmCD UI -This repository contains the code for the Swarm-CD UI, a web-based user interface for checking the deployment status. The UI is built using React and bundled by Vite for fast and efficient development and build processes. +This repository contains the code for the SwarmCD UI, a web-based user interface for checking the deployment status. The UI is built using React and bundled by Vite for fast and efficient development and build processes. ## Installation @@ -12,7 +12,7 @@ This repository contains the code for the Swarm-CD UI, a web-based user interfac ## Directory structure -``` +```text swarm-cd-ui/ ├── public/ # Static assets ├── src/ # Source files @@ -24,3 +24,19 @@ swarm-cd-ui/ ├── package.json # Project metadata and scripts └── vite.config.ts # Vite configuration ``` + +Recommended `.vscode/settings.json`: + +```json +{ + "editor.codeActionsOnSave": { + "source.organizeImports": "always", + "source.fixAll.eslint": "always" + }, + "editor.tabSize": 2, + "editor.formatOnSave": true, + "eslint.format.enable": true, + "eslint.lintTask.enable": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" +} +``` diff --git a/ui/src/App.tsx b/ui/src/App.tsx index ee3e44e..89837ae 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -11,13 +11,13 @@ function App(): React.ReactElement { return ( <> - setSearchQuery(query)} /> - {error !== null ? ( - + setSearchQuery(query)} error={error !== null} /> + {error === null ? ( + + ) : ( + {error} - ) : ( - )} diff --git a/ui/src/components/HeaderBar.tsx b/ui/src/components/HeaderBar.tsx index f81609e..a6938cc 100644 --- a/ui/src/components/HeaderBar.tsx +++ b/ui/src/components/HeaderBar.tsx @@ -3,7 +3,13 @@ import React from "react" import { FaGithub } from "react-icons/fa" import ColorToggleButton from "./ColorToggleButton" -function HeaderBar({ onQueryChange }: { onQueryChange: (query: string) => void }): React.ReactElement { +function HeaderBar({ + onQueryChange, + error +}: Readonly<{ + onQueryChange: (query: string) => void + error: boolean +}>): React.ReactElement { return ( void } size="lg" variant="filled" bg={useColorModeValue("gray.200", "gray.800")} + disabled={error} /> diff --git a/ui/src/components/StatusCard.tsx b/ui/src/components/StatusCard.tsx index a85141c..f886d1e 100644 --- a/ui/src/components/StatusCard.tsx +++ b/ui/src/components/StatusCard.tsx @@ -13,16 +13,14 @@ function StatusCard({ repoURL: string }>): React.ReactElement { return ( - + Name: {name} {error !== "" && ( <> - - Error: - + Error: {error} )} diff --git a/ui/src/components/StatusCardList.tsx b/ui/src/components/StatusCardList.tsx index 8adbc3c..4f87ba0 100644 --- a/ui/src/components/StatusCardList.tsx +++ b/ui/src/components/StatusCardList.tsx @@ -1,3 +1,4 @@ +import { Text } from "@chakra-ui/react" import React, { useEffect, useState } from "react" import { StackStatus } from "../hooks/useFetchStatuses" import StatusCard from "./StatusCard" @@ -6,15 +7,23 @@ function StatusCardList({ statuses, query }: Readonly<{ statuses: StackStatus[]; const [filteredStatuses, setFilteredStatuses] = useState(statuses) useEffect(() => { - const filtered = statuses.filter(status => Object.values(status).join().toLowerCase().includes(query.toLowerCase())) + const filtered = statuses.filter(status => + Object.values(status).some(value => value.toString().toLowerCase().includes(query.toLowerCase())) + ) setFilteredStatuses(filtered) }, [statuses, query]) return ( <> - {filteredStatuses.map((item, index) => ( - - ))} + {filteredStatuses.length === 0 ? ( + + No items available + + ) : ( + filteredStatuses.map((item, index) => ( + + )) + )} ) }