From d2ac5cea2a6cd94969adb76b7f260f4ca822b57a Mon Sep 17 00:00:00 2001 From: yjaaouane Date: Sun, 2 Nov 2025 20:00:35 +0100 Subject: [PATCH 1/3] fix(observability): add services mock resolve: #MAOBS-103 Signed-off-by: yjaaouane --- .../src/__mocks__/services/service.adapter.ts | 14 +++++++ .../src/__mocks__/services/service.mock.ts | 39 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 packages/manager/apps/observability/src/__mocks__/services/service.adapter.ts create mode 100644 packages/manager/apps/observability/src/__mocks__/services/service.mock.ts diff --git a/packages/manager/apps/observability/src/__mocks__/services/service.adapter.ts b/packages/manager/apps/observability/src/__mocks__/services/service.adapter.ts new file mode 100644 index 000000000000..f82d9e3454e7 --- /dev/null +++ b/packages/manager/apps/observability/src/__mocks__/services/service.adapter.ts @@ -0,0 +1,14 @@ +import { apiConfig } from '@/__mocks__/mock.config'; +import { getObservabilityServices as getObservabilityServicesFromMock } from '@/__mocks__/services/service.mock'; +import { getObservabilityServices as getObservabilityServicesFromApi } from '@/data/api/observability.api'; +import { ObservabilityService } from '@/types/observability.type'; + +export const getObservabilityServices = async ( + signal: AbortSignal, +): Promise => { + const isMockEnabled = apiConfig.mode === 'mock'; + console.info('[MOCK-ADAPTER][getObservabilityServices] Mock enabled -> ', isMockEnabled); + return isMockEnabled + ? getObservabilityServicesFromMock(signal) + : getObservabilityServicesFromApi(signal); +}; diff --git a/packages/manager/apps/observability/src/__mocks__/services/service.mock.ts b/packages/manager/apps/observability/src/__mocks__/services/service.mock.ts new file mode 100644 index 000000000000..d0dfb377508d --- /dev/null +++ b/packages/manager/apps/observability/src/__mocks__/services/service.mock.ts @@ -0,0 +1,39 @@ +import { ObservabilityService } from '@/types/observability.type'; + +const servicesDataset: ObservabilityService[] = [ + { id: 'ldp-zf-15501', currentState: { displayName: null } }, + { id: 'ldp-et-42418', currentState: { displayName: null } }, + { id: 'ldp-ms-91722', currentState: { displayName: null } }, + { id: 'ldp-gr-55078', currentState: { displayName: null } }, + { id: 'ldp-io-61871', currentState: { displayName: null } }, + { id: 'ldp-dq-82324', currentState: { displayName: null } }, + { id: 'ldp-jr-81953', currentState: { displayName: null } }, + { id: 'ldp-jj-29716', currentState: { displayName: null } }, + { id: 'ldp-tt-48060', currentState: { displayName: null } }, + { id: 'ldp-np-43247', currentState: { displayName: null } }, + { id: 'ldp-ro-08038', currentState: { displayName: null } }, + { id: 'ldp-ju-54500', currentState: { displayName: null } }, + { id: 'ldp-nv-47025', currentState: { displayName: null } }, + { id: 'ldp-pe-11160', currentState: { displayName: null } }, + { id: 'ldp-mg-73834', currentState: { displayName: null } }, + { id: 'ldp-yy-24693', currentState: { displayName: null } }, + { id: 'ldp-iz-25481', currentState: { displayName: '[DO NOT TOUCH] TTA TRS Quality' } }, + { id: 'ldp-xa-17103', currentState: { displayName: null } }, + { id: 'ldp-np-20814', currentState: { displayName: 'Christian' } }, + { id: 'ldp-ni-50732', currentState: { displayName: null } }, + { id: 'ldp-an-17655', currentState: { displayName: null } }, + { id: 'ldp-hy-49770', currentState: { displayName: 'ldp-hy-49770' } }, + { id: 'ldp-la-85440', currentState: { displayName: 'do not touch' } }, + { id: 'ldp-xq-98460', currentState: { displayName: 'Name' } }, + { id: 'ldp-fr-36016', currentState: { displayName: null } }, + { id: 'ldp-ga-90239', currentState: { displayName: 'Ele QA' } }, + { id: 'ldp-ib-84974', currentState: { displayName: null } }, + { id: 'ldp-rg-93836', currentState: { displayName: '[DO NOT TOUCH] Monito Pingdom' } }, +]; + +export const getObservabilityServices = async ( + signal: AbortSignal, +): Promise => { + console.info(`[MOCK-ADAPTER][getObservabilityServices] > `, signal); + return Promise.resolve(servicesDataset); +}; From f9e5bb61140eed3ec8c8adc4991d55f1c1d07f74 Mon Sep 17 00:00:00 2001 From: yjaaouane Date: Sun, 2 Nov 2025 20:02:42 +0100 Subject: [PATCH 2/3] fix(observability): use tenants creation url resolve: #MAOBS-103 Signed-off-by: yjaaouane --- .../tenants/top-bar/TenantsListTopbar.component.spec.tsx | 6 +++--- .../listing/tenants/top-bar/TenantsListTopbar.component.tsx | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/manager/apps/observability/src/__tests__/components/listing/tenants/top-bar/TenantsListTopbar.component.spec.tsx b/packages/manager/apps/observability/src/__tests__/components/listing/tenants/top-bar/TenantsListTopbar.component.spec.tsx index 3f349a2d012f..5e1b2e651f95 100644 --- a/packages/manager/apps/observability/src/__tests__/components/listing/tenants/top-bar/TenantsListTopbar.component.spec.tsx +++ b/packages/manager/apps/observability/src/__tests__/components/listing/tenants/top-bar/TenantsListTopbar.component.spec.tsx @@ -140,7 +140,7 @@ describe('TenantsListTopbar', () => { }); describe('Navigation Behavior', () => { - it('should navigate to addNew when button is clicked', () => { + it('should navigate to creation when button is clicked', () => { // Act const { container } = render(); const button = getButton(container); @@ -149,7 +149,7 @@ describe('TenantsListTopbar', () => { // Assert expect(mockNavigate).toHaveBeenCalledTimes(1); - expect(mockNavigate).toHaveBeenCalledWith('addNew'); + expect(mockNavigate).toHaveBeenCalledWith('/metrics/tenants/creation'); }); it('should handle multiple clicks', () => { @@ -165,7 +165,7 @@ describe('TenantsListTopbar', () => { // Assert expect(mockNavigate).toHaveBeenCalledTimes(3); - expect(mockNavigate).toHaveBeenCalledWith('addNew'); + expect(mockNavigate).toHaveBeenCalledWith('/metrics/tenants/creation'); }); }); diff --git a/packages/manager/apps/observability/src/components/listing/tenants/top-bar/TenantsListTopbar.component.tsx b/packages/manager/apps/observability/src/components/listing/tenants/top-bar/TenantsListTopbar.component.tsx index 55de778ba79f..f071f0a8260f 100644 --- a/packages/manager/apps/observability/src/components/listing/tenants/top-bar/TenantsListTopbar.component.tsx +++ b/packages/manager/apps/observability/src/components/listing/tenants/top-bar/TenantsListTopbar.component.tsx @@ -7,6 +7,7 @@ import { ODS_BUTTON_VARIANT } from '@ovhcloud/ods-components'; import { ManagerButton } from '@ovh-ux/manager-react-components'; import { useObservabilityServiceContext } from '@/contexts/ObservabilityService.context'; +import { urls } from '@/routes/Routes.constants'; import { IAM_ACTIONS } from '@/utils/iam.constants'; export default function TenantsListTopbar() { @@ -16,7 +17,7 @@ export default function TenantsListTopbar() { const { selectedService, isLoading } = useObservabilityServiceContext(); const addNewTenant = () => { - navigate('addNew'); + navigate(urls.tenantsCreation); }; return ( From 01cf2c41c08329895591df4ed9c907981af0e946 Mon Sep 17 00:00:00 2001 From: yjaaouane Date: Sun, 2 Nov 2025 20:04:07 +0100 Subject: [PATCH 3/3] refactor(observability): use component syntax resolve: #MAOBS-103 Signed-off-by: yjaaouane --- .../tenants/TenantsListDatagrid.component.tsx | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/packages/manager/apps/observability/src/components/listing/tenants/TenantsListDatagrid.component.tsx b/packages/manager/apps/observability/src/components/listing/tenants/TenantsListDatagrid.component.tsx index 67b059ce0463..5fcb2b41c1b8 100644 --- a/packages/manager/apps/observability/src/components/listing/tenants/TenantsListDatagrid.component.tsx +++ b/packages/manager/apps/observability/src/components/listing/tenants/TenantsListDatagrid.component.tsx @@ -67,14 +67,7 @@ export default function TenantsListDatagrid({ isSortable: true, isFilterable: true, enableHiding: false, - cell: (mappedTenant: MappedTenant) => { - const { id: tenantId, name } = mappedTenant; - return DatagridCellLink({ - id: tenantId, - label: name, - path: tenantId, - }); - }, + cell: ({ id, name }: MappedTenant) => , label: t(`${NAMESPACES.DASHBOARD}:name`), type: FilterTypeCategories.String, }, @@ -84,8 +77,9 @@ export default function TenantsListDatagrid({ isSortable: true, isFilterable: true, enableHiding: true, - cell: (mappedTenant: MappedTenant) => - DatagridCellEnpoint({ infrastructure: mappedTenant.infrastructure }), + cell: ({ infrastructure }: MappedTenant) => ( + + ), label: t('tenants:listing.endpoint_cell'), type: FilterTypeCategories.String, }, @@ -96,9 +90,7 @@ export default function TenantsListDatagrid({ isFilterable: true, enableHiding: true, label: t('tenants:listing.retention_cell'), - cell: (mappedTenant: MappedTenant) => ( - {mappedTenant.retention} - ), + cell: ({ retention }: MappedTenant) => {retention}, type: FilterTypeCategories.String, }, { @@ -108,8 +100,8 @@ export default function TenantsListDatagrid({ isFilterable: true, enableHiding: true, label: t('tenants:listing.active_metrics_cell'), - cell: (mappedTenant: MappedTenant) => ( - {mappedTenant.numberOfSeries} + cell: ({ numberOfSeries }: MappedTenant) => ( + {numberOfSeries} ), type: FilterTypeCategories.Numeric, }, @@ -121,8 +113,7 @@ export default function TenantsListDatagrid({ enableHiding: true, type: FilterTypeCategories.String, label: t('tenants:listing.tags_cell'), - cell: (mappedTenant: MappedTenant) => - DatagridTenantCellTags({ tags: mappedTenant.tagsArray }), + cell: ({ tagsArray: tags }: MappedTenant) => , }, { id: 'actions', @@ -147,7 +138,7 @@ export default function TenantsListDatagrid({ }), ); } - }, [isError, error]); + }, [addError, error, isError, t]); const { filters, addFilter, removeFilter } = useColumnFilters();