Skip to content

Commit a64a8b0

Browse files
committed
feat(backup-agent): fix feedbacks
ref: #BKP-498 Signed-off-by: Vincent Bonmarchand <[email protected]>
1 parent 0611c40 commit a64a8b0

File tree

13 files changed

+79
-108
lines changed

13 files changed

+79
-108
lines changed

packages/manager/modules/backup-agent/src/components/CommonTiles/GeneralInformationsTile/GeneralInformationTile.component.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { NAMESPACES } from "@ovh-ux/manager-common-translations";
44
import { OdsSkeleton } from "@ovhcloud/ods-components/react";
55
import { useLocationDetails } from "@/data/hooks/location/getLocationDetails";
66
import { ResourceStatusBadge } from "@/components/ResourceStatusBadge/ResourceStatusBadge.components";
7-
import {WithRegion} from "@/types/Utils.type";
8-
import {Resource} from "@/types/Resource.type";
7+
import { WithRegion } from "@/types/Utils.type";
8+
import { Resource } from "@/types/Resource.type";
99

1010
export type GeneralInformationTileProps<T extends { name: string }> = {
1111
resourceDetails?: Pick<Resource<T>, 'resourceStatus'> & { currentState: WithRegion<T> };
1212
isLoading: boolean;
1313
};
1414

15-
export function GeneralInformationTile<T extends { name: string }>({ resourceDetails, isLoading }: Readonly<GeneralInformationTileProps<T>>) {
15+
const GeneralInformationTile = <T extends { name: string }>({ resourceDetails, isLoading }: GeneralInformationTileProps<T>) => {
1616
const { t } = useTranslation([NAMESPACES.DASHBOARD, NAMESPACES.STATUS, NAMESPACES.REGION, 'dashboard']);
1717
const { data: locationData, isLoading: isLocationLoading } = useLocationDetails(resourceDetails?.currentState.region)
1818

@@ -50,3 +50,5 @@ export function GeneralInformationTile<T extends { name: string }>({ resourceDet
5050
</ManagerTile>
5151
);
5252
}
53+
54+
export default GeneralInformationTile;

packages/manager/modules/backup-agent/src/components/CommonTiles/GeneralInformationsTile/__tests__/GeneralInformationTile.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, screen } from "@testing-library/react"
33
import { NAMESPACES } from "@ovh-ux/manager-common-translations";
44
import { mockVaults } from "@/mocks/vaults/vaults";
55

6-
import { GeneralInformationTile } from "../GeneralInformationTile.component"
6+
import GeneralInformationTile from "../GeneralInformationTile.component"
77
import { mockLocations } from "@/mocks/location/locations";
88

99
const TILE_TITLE = `${NAMESPACES.DASHBOARD}:general_information`

packages/manager/modules/backup-agent/src/data/hooks/tenants/useVspcTenants.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,34 @@ export const useVSPCTenantsMocks = (): TUseVSPCTenantsResult =>
3535

3636
export const useInstalledBackupAgents = ({
3737
vspcTenants,
38-
}: {
39-
vspcTenants: AssociatedTenantVSPC[];
40-
} & Partial<Omit<DefinedInitialDataOptions<Resource<VSPCTenant>, unknown>, "queryKey" | "queryFn">>) => {
41-
const vspcTenantIds = useMemo(() => {
42-
if (!vspcTenants) return [];
43-
return vspcTenants.map((vspc) => vspc.id);
44-
}, [vspcTenants]);
45-
const vspcTenantQueries = useQueries({
38+
}: Readonly<{
39+
vspcTenants: readonly AssociatedTenantVSPC[];
40+
}> & Readonly<
41+
Partial<
42+
Omit<
43+
DefinedInitialDataOptions<Resource<VSPCTenant>, unknown>,
44+
"queryKey" | "queryFn"
45+
>
46+
>
47+
>) => {
48+
49+
const vspcTenantIds = vspcTenants?.map((v) => v.id) ?? [];
50+
51+
return useQueries({
4652
queries: vspcTenantIds.map((vspcTenantId) => ({
47-
queryKey: ['vspcTenantDetails', vspcTenantId],
53+
queryKey: ["vspcTenantDetails", vspcTenantId],
4854
queryFn: () => getVSPCTenantDetails(vspcTenantId),
4955
enabled: !!vspcTenantId,
5056
})),
5157
combine: (results) => {
5258
const tenants = results
53-
.map((r) => r.data)
54-
.filter((tenant): tenant is VSPCTenant => !!tenant);
55-
59+
.map((r) => r.data)
60+
.filter((t): t is VSPCTenant => Boolean(t));
61+
5662
return {
5763
installedBackupAgents: countBackupAgents(tenants),
5864
isLoading: results.some((q) => q.isLoading),
59-
}
65+
};
6066
},
6167
});
62-
return vspcTenantQueries;
63-
};
68+
};

packages/manager/modules/backup-agent/src/pages/services/dashboard/general-information/GeneralInformation.page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { BillingInformationsTileStandard } from "@ovh-ux/billing-informations"
22

3-
import { GeneralInformationTenantTile } from "./_components/general-information-tenant-tile/GeneralInformationTenantTile.component";
43
import { useParams } from "react-router-dom";
54
import { useBackupTenantDetails } from "@/data/hooks/tenants/useBackupTenantDetails";
6-
import { SubscriptionTile } from "./_components/subscription-tile/SubscriptionTile.component";
5+
import SubscriptionTile from "./_components/subscription-tile/SubscriptionTile.component";
6+
import GeneralInformationTenantTile from "./_components/general-information-tenant-tile/GeneralInformationTenantTile.component";
77

88

99
export default function GeneralInformationPage() {

packages/manager/modules/backup-agent/src/pages/services/dashboard/general-information/_components/__tests__/GeneralInformationTenantTile.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { vi } from "vitest"
22
import { render, screen } from "@testing-library/react"
33

4-
import { GeneralInformationTenantTile } from "../general-information-tenant-tile/GeneralInformationTenantTile.component";
4+
import GeneralInformationTenantTile from "../general-information-tenant-tile/GeneralInformationTenantTile.component";
55
import { GeneralInformationTileProps } from "@/components/CommonTiles/GeneralInformationsTile/GeneralInformationTile.component";
66
import { TENANTS_MOCKS } from "@/mocks/tenant/tenants.mock";
77

packages/manager/modules/backup-agent/src/pages/services/dashboard/general-information/_components/__tests__/SubscriptionTile.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, screen } from "@testing-library/react"
33
import { NAMESPACES } from "@ovh-ux/manager-common-translations";
44
import { mockVaults } from "@/mocks/vaults/vaults";
55

6-
import { SubscriptionTile } from "../subscription-tile/SubscriptionTile.component"
6+
import SubscriptionTile from "../subscription-tile/SubscriptionTile.component"
77
import { TENANTS_MOCKS } from "@/mocks/tenant/tenants.mock";
88
import { MemoryRouter } from "react-router-dom";
99
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import GeneralInformationTile from '@/components/CommonTiles/GeneralInformationsTile/GeneralInformationTile.component';
12
import { useBackupTenantDetails } from '@/data/hooks/tenants/useBackupTenantDetails';
2-
import { GeneralInformationTile } from '@/components/CommonTiles/GeneralInformationsTile/GeneralInformationTile.component';
33

44
type GeneralInformationTenantTileProps = {
55
tenantId: string
66
};
77

8-
export function GeneralInformationTenantTile({ tenantId }: Readonly<GeneralInformationTenantTileProps>) {
8+
const GeneralInformationTenantTile = ({ tenantId }: GeneralInformationTenantTileProps) => {
99
const { data, isLoading } = useBackupTenantDetails({ tenantId })
1010

1111
return <GeneralInformationTile resourceDetails={data} isLoading={isLoading} />
1212
}
13+
14+
export default GeneralInformationTenantTile;

packages/manager/modules/backup-agent/src/pages/services/dashboard/general-information/_components/subscription-tile/SubscriptionTile.component.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,35 @@ import { NAMESPACES } from "@ovh-ux/manager-common-translations";
44
import { OdsSkeleton } from "@ovhcloud/ods-components/react";
55
import { BACKUP_AGENT_NAMESPACES } from "@/BackupAgent.translations";
66
import { useBackupTenantDetails } from '@/data/hooks/tenants/useBackupTenantDetails';
7-
import { InstalledAgents } from './_components/InstalledAgents.component';
8-
import { ConnectedVaults } from './_components/ConnectedVaults.component';
97
import { useHref } from 'react-router-dom';
108
import { urls } from '@/routes/Routes.constants';
9+
import { useTenantBackupStats } from './_hooks/useTenantBackupStats';
1110

1211
type SubscriptionTileProps = {
1312
tenantId?: string;
1413
};
1514

16-
export function SubscriptionTile({ tenantId }: Readonly<SubscriptionTileProps>) {
15+
const SubscriptionTile = ({ tenantId }: SubscriptionTileProps) => {
1716
const { t } = useTranslation([NAMESPACES.DASHBOARD, NAMESPACES.BILLING, BACKUP_AGENT_NAMESPACES.SERVICE_DASHBOARD]);
1817
const { data, isLoading } = useBackupTenantDetails({ tenantId: tenantId! })
1918
const billingHref = useHref(urls.listingBilling)
19+
const { connectedVaultsText, installedAgentsText } = useTenantBackupStats({ tenantDetails: data, vspcTenants: data?.currentState.vspcTenants });
20+
2021
return (
2122
<ManagerTile>
2223
<ManagerTile.Title>{t(`${NAMESPACES.BILLING}:subscription`)}</ManagerTile.Title>
2324
<ManagerTile.Divider />
2425
<ManagerTile.Item>
2526
<ManagerTile.Item.Label>{t(`${BACKUP_AGENT_NAMESPACES.SERVICE_DASHBOARD}:installed_agents`)}</ManagerTile.Item.Label>
2627
<ManagerTile.Item.Description>
27-
{isLoading ? <OdsSkeleton /> : <InstalledAgents vspcTenants={data?.currentState.vspcTenants} />}
28+
{isLoading ? <OdsSkeleton /> : installedAgentsText}
2829
</ManagerTile.Item.Description>
2930
</ManagerTile.Item>
3031
<ManagerTile.Divider />
3132
<ManagerTile.Item>
3233
<ManagerTile.Item.Label>{t(`${BACKUP_AGENT_NAMESPACES.SERVICE_DASHBOARD}:connected_vaults`)}</ManagerTile.Item.Label>
3334
<ManagerTile.Item.Description>
34-
{isLoading ? <OdsSkeleton /> : <ConnectedVaults tenantDetails={data} />}
35+
{isLoading ? <OdsSkeleton /> : connectedVaultsText}
3536
</ManagerTile.Item.Description>
3637
</ManagerTile.Item>
3738
<ManagerTile.Divider />
@@ -41,3 +42,5 @@ export function SubscriptionTile({ tenantId }: Readonly<SubscriptionTileProps>)
4142
</ManagerTile>
4243
);
4344
}
45+
46+
export default SubscriptionTile;

packages/manager/modules/backup-agent/src/pages/services/dashboard/general-information/_components/subscription-tile/_components/ConnectedVaults.component.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/manager/modules/backup-agent/src/pages/services/dashboard/general-information/_components/subscription-tile/_components/InstalledAgents.component.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)