Skip to content

Commit

Permalink
Merge pull request #71 from projectsveltos/profiles-fix
Browse files Browse the repository at this point in the history
Minor UI  fixes
  • Loading branch information
Safouene1 authored Feb 9, 2025
2 parents 4c4ada3 + adb862d commit 24084e0
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 24 deletions.
2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<title>Sveltos Dashboard</title>
</head>
<body class="min-h-screen">
<div data-tf-live="01HX9Q850M9T9MMPQW2GDCN5SK"></div>
<script src="//embed.typeform.com/next/embed.js"></script>
<noscript> To use SveltosUI, please enable JavaScript. </noscript>
<div id="root" class="relative flex min-h-screen flex-col"></div>
<script type="module" src="/src/main.tsx"></script>
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function App() {
queryClient.setDefaultOptions({
queries: {
retry: 2,
staleTime: 30 * 1000,
onError: (error: unknown) => {
if (error instanceof Error) {
if (
Expand All @@ -38,7 +39,7 @@ export default function App() {
if (token) {
authenticate(token);
}
}, [window.location.search]);
}, [authenticate]);

return (
<ThemeProvider>
Expand Down
10 changes: 10 additions & 0 deletions src/lib/components/layouts/AppLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { Outlet } from "react-router-dom";
import { Header } from "./Header";
import { Footer } from "./Footer";
import { Logo } from "@/lib/components/assets/logo/logo";
import { appConfig } from "@/config/app";

export function Applayout() {
return (
<>
<Header />
<a
href={appConfig.github.url}
target="_blank"
className="fixed right-2 top-1/2 -translate-y-1/2 bg-primary text-white px-6 py-2 rounded-lg shadow-lg rotate-90 flex items-center space-x-2"
rel="noreferrer"
>
<span>Powered by</span> <Logo />
</a>
<div className="flex-grow flex flex-col">
<div className="container px-4 md:px-8 flex-grow flex flex-col">
<Outlet />
Expand Down
1 change: 0 additions & 1 deletion src/modules/clusters/clusters-list/hooks/useClusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const useClusters = (
() => fetchClusters(type, page, searchParams),
{
keepPreviousData: false,
cacheTime: 0,
},
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ type ProfileSpecCardProps = {
env: string;
};
};
helmCharts?: {
chartName: string;
chartVersion: string;
}[];
syncMode: string;
stopMatchingBehavior: string;
policyRefs?: {
Expand All @@ -31,7 +35,7 @@ export const ProfileSpecCard = ({ spec }: ProfileSpecCardProps) => {
<Card className="overflow-hidden">
<CardHeader>
<CardTitle className={"flex items-center"}>
<FileSliders className={"w-4 h-4 mx-0.5"} /> Specs
<FileSliders className={"w-4 h-4 mx-0.5"} /> Spec
</CardTitle>
<CardDescription>
Profile specifications for the selected profile
Expand All @@ -43,11 +47,13 @@ export const ProfileSpecCard = ({ spec }: ProfileSpecCardProps) => {
<dt className="text-sm text-muted-foreground">Cluster Selector</dt>
<dd className="font-medium">
<Badge variant={"outline"}>
{spec.clusterSelector.matchLabels.env}
{Object.entries(spec.clusterSelector.matchLabels).map(
([key, value]) => `${key}: ${value}`,
)}
</Badge>
</dd>
<dt className="text-sm text-muted-foreground">Sync Mode</dt>
<dd className="text-sm font-medium">{spec.syncMode}</dd>
<Badge className="text-sm font-medium">{spec.syncMode}</Badge>
{spec?.policyRefs && (
<>
<dt className="text-sm text-muted-foreground">Policy Refs</dt>
Expand All @@ -60,6 +66,18 @@ export const ProfileSpecCard = ({ spec }: ProfileSpecCardProps) => {
</dd>
</>
)}
{spec?.helmCharts && (
<>
<dt className="text-sm text-muted-foreground">Helm Charts</dt>
<dd>
{spec.helmCharts.map((chart, index) => (
<Badge key={index} variant={"outline"}>
{chart.chartName} ({chart.chartVersion})
</Badge>
))}
</dd>
</>
)}
</dl>
</div>
</CardContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { DependentsNode } from "@/modules/profiles/profile-information/component
import { ClusterNode } from "@/modules/profiles/profile-information/components/ProfileRelations/Nodes/ClusterNode";
import { Button } from "@/lib/components/ui/button";
import { Dependency } from "@/types/profile.types";
import { Badge } from "@/lib/components/ui/badge";

const nodeTypes = {
custom: ClusterNode,
Expand Down Expand Up @@ -76,7 +77,7 @@ export function ProfileRelations({
position: { x: 0, y: 0 },
},
];
// TODO if more than 4 clusters , should add it on bottom

const horizontalSpacing = 200;
const verticalSpacing = 120;

Expand Down Expand Up @@ -131,11 +132,20 @@ export function ProfileRelations({
<CardHeader>
<CardTitle className={"flex items-center"}>
<Cable className={"w-4 h-4 mx-0.5"} /> Profile
<div className=" flex ml-auto gap-2 ">
<Badge variant={"label"} className={" "}>
Total dependents: {profile.dependents.length}
</Badge>
<Badge variant={"label"}>
Total dependencies: {profile.dependencies.length}
</Badge>
</div>
</CardTitle>
<CardDescription>
Profile specifications for the selected profile
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
Profile associations with linked dependents and dependencies within
the cluster.
<div className="flex items-center my-2">
<span className={"ml-auto flex items-center gap-2"}>
<Button size="sm" variant="outline" className="h-7 gap-1">
<File className="h-3.5 w-3.5" />
<span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
Expand All @@ -153,7 +163,7 @@ export function ProfileRelations({
Drag And Drop
</span>
</Button>
</div>
</span>
</div>
</CardDescription>
</CardHeader>
Expand Down
17 changes: 7 additions & 10 deletions src/modules/profiles/profile-information/hooks/useProfileInfo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useQuery, UseQueryResult } from "react-query";

import client from "@/api-client/apiClient";

import { API_ENDPOINTS } from "@/api-client/endpoints";
import { ProfileInfo } from "@/types/profile.types";
import { useMemo } from "react";

const fetchProfileInfo = async (name: string, kind: string) => {
const { data } = await client.get(API_ENDPOINTS.PROFILE, {
params: {
Expand All @@ -13,18 +13,15 @@ const fetchProfileInfo = async (name: string, kind: string) => {
});
return data;
};

const useProfileInfo = (
name: string,
kind: string,
): UseQueryResult<ProfileInfo, Error> => {
return useQuery(
["profile-info", name, kind],
() => fetchProfileInfo(name, kind),
{
keepPreviousData: false,
cacheTime: 0,
},
);
const queryKey = useMemo(() => ["profile-info", name, kind], [name, kind]);
return useQuery(queryKey, () => fetchProfileInfo(name, kind), {
keepPreviousData: false,
});
};

export default useProfileInfo;
2 changes: 1 addition & 1 deletion src/modules/profiles/profiles-list/ProfileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function ProfileList() {
<PageHeading
title={"Profiles"}
description={
"You can view all tiers , profiles and visualize dependants and dependencies "
"You can view all tiers , profiles and visualize dependents and dependencies "
}
/>
{(isLoading || isPreviousData) && <LoadingTier />}
Expand Down
1 change: 0 additions & 1 deletion src/modules/profiles/profiles-list/hooks/useProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const fetchProfiles = async (): Promise<Array<TierData>> => {
const useProfiles = (): UseQueryResult<Array<TierData>, Error> => {
return useQuery(["profiles"], () => fetchProfiles(), {
keepPreviousData: false,
cacheTime: 0,
});
};

Expand Down

0 comments on commit 24084e0

Please sign in to comment.