From 41ce7559501c7acdacf43dc3e2f2524b13dd7003 Mon Sep 17 00:00:00 2001 From: "maciej.moscicki" Date: Fri, 2 Aug 2024 14:24:50 +0200 Subject: [PATCH] adjust ui --- hermes-console/json-server/db.json | 26 ++++-------- hermes-console/json-server/routes.json | 4 +- hermes-console/src/api/hermes-client/index.ts | 14 +------ hermes-console/src/dummy/store.ts | 2 - hermes-console/src/mocks/handlers.ts | 11 ----- hermes-console/src/store/consistency/types.ts | 2 - .../consistency/useConsistencyStore.spec.ts | 11 ----- .../store/consistency/useConsistencyStore.ts | 26 +----------- .../admin/consistency/ConsistencyView.spec.ts | 42 ------------------- .../admin/consistency/ConsistencyView.vue | 10 ----- 10 files changed, 10 insertions(+), 138 deletions(-) diff --git a/hermes-console/json-server/db.json b/hermes-console/json-server/db.json index 8c2720872d..f921a762b6 100644 --- a/hermes-console/json-server/db.json +++ b/hermes-console/json-server/db.json @@ -7,22 +7,12 @@ "pl.allegro.public.group", "pl.allegro.public.admin" ], - "consistencyGroups": [ - "pl.allegro.public.offer", - "pl.allegro.public.offer.product", - "pl.allegro.public.order", - "pl.allegro.public.user", - "pl.allegro.public.group", - "pl.allegro.public.admin", - "pl.allegro.public.offer2", - "pl.allegro.public.offer.product2", - "pl.allegro.public.order2", - "pl.allegro.public.user2", - "pl.allegro.public.group2", - "pl.allegro.public.admin2" - ], - "topicDashboardUrl": {"url": "https://www.google.com/search?q=topic"}, - "subscriptionDashboardUrl": {"url": "https://www.google.com/search?q=subscription" }, + "topicDashboardUrl": { + "url": "https://www.google.com/search?q=topic" + }, + "subscriptionDashboardUrl": { + "url": "https://www.google.com/search?q=subscription" + }, "inconsistentGroups": [ { "name": "pl.allegro.public.group", @@ -60,9 +50,7 @@ ] } ] - } - ], - "inconsistentGroups2": [ + }, { "name": "pl.allegro.public.group2", "inconsistentMetadata": [ diff --git a/hermes-console/json-server/routes.json b/hermes-console/json-server/routes.json index eb0b5ae948..a7461aa3b3 100644 --- a/hermes-console/json-server/routes.json +++ b/hermes-console/json-server/routes.json @@ -1,8 +1,6 @@ { "/consistency/inconsistencies/topics": "/inconsistentTopics", - "/consistency/groups": "/consistencyGroups", - "/consistency/inconsistencies/groups?groupNames=pl.allegro.public.offer*": "/inconsistentGroups", - "/consistency/inconsistencies/groups?groupNames=pl.allegro.public.group2*": "/inconsistentGroups2", + "/consistency/inconsistencies/groups": "/inconsistentGroups", "/groups": "/groups", "/owners/sources/Service%20Catalog/:id": "/topicsOwners/:id", "/readiness/datacenters": "/readinessDatacenters", diff --git a/hermes-console/src/api/hermes-client/index.ts b/hermes-console/src/api/hermes-client/index.ts index 4c4f6f89a4..55cd8dd807 100644 --- a/hermes-console/src/api/hermes-client/index.ts +++ b/hermes-console/src/api/hermes-client/index.ts @@ -206,21 +206,9 @@ export function fetchConsumerGroups( ); } -export function fetchConsistencyGroups(): ResponsePromise { - return axios.get('/consistency/groups'); -} - export function fetchInconsistentGroups( - groups: string[], ): ResponsePromise { - return axios.get('/consistency/inconsistencies/groups', { - params: { - groupNames: groups, - }, - paramsSerializer: { - indexes: null, - }, - }); + return axios.get('/consistency/inconsistencies/groups'); } export function fetchInconsistentTopics(): ResponsePromise { diff --git a/hermes-console/src/dummy/store.ts b/hermes-console/src/dummy/store.ts index 945f259815..5bfc683e4b 100644 --- a/hermes-console/src/dummy/store.ts +++ b/hermes-console/src/dummy/store.ts @@ -33,8 +33,6 @@ export const authStoreState: AuthStoreState = { }; export const consistencyStoreState: ConsistencyStoreState = { - fetchInProgress: false, - progressPercent: 0, error: { fetchError: null, }, diff --git a/hermes-console/src/mocks/handlers.ts b/hermes-console/src/mocks/handlers.ts index d2eceac040..06eb7e46eb 100644 --- a/hermes-console/src/mocks/handlers.ts +++ b/hermes-console/src/mocks/handlers.ts @@ -626,17 +626,6 @@ export const fetchConsistencyGroupsHandler = ({ return HttpResponse.json(groups); }); -export const fetchConsistencyGroupsErrorHandler = ({ - errorCode = 500, -}: { - errorCode?: number; -}) => - http.get(`${url}/consistency/groups`, () => { - return new HttpResponse(undefined, { - status: errorCode, - }); - }); - export const fetchGroupInconsistenciesHandler = ({ groupsInconsistency, }: { diff --git a/hermes-console/src/store/consistency/types.ts b/hermes-console/src/store/consistency/types.ts index c02f394d94..b12967aaa9 100644 --- a/hermes-console/src/store/consistency/types.ts +++ b/hermes-console/src/store/consistency/types.ts @@ -2,8 +2,6 @@ import type { InconsistentGroup } from '@/api/inconsistent-group'; export interface ConsistencyStoreState { groups: InconsistentGroup[]; - progressPercent: number; - fetchInProgress: boolean; error: ConsistencyFetchError; } diff --git a/hermes-console/src/store/consistency/useConsistencyStore.spec.ts b/hermes-console/src/store/consistency/useConsistencyStore.spec.ts index bb5e1b73d1..bde821ea66 100644 --- a/hermes-console/src/store/consistency/useConsistencyStore.spec.ts +++ b/hermes-console/src/store/consistency/useConsistencyStore.spec.ts @@ -24,8 +24,6 @@ describe('useConsistencyStore', () => { // then expect(consistencyStore.groups).toEqual([]); - expect(consistencyStore.progressPercent).toEqual(0); - expect(consistencyStore.fetchInProgress).toBeFalsy(); }); it('should fetch group consistency', async () => { @@ -66,15 +64,6 @@ describe('useConsistencyStore', () => { expect(consistencyStore.topic('whatever', 'topic')).toBeUndefined(); }); - it('should set error when fetching consistency groups fails', async () => { - server.use(fetchConsistencyGroupsErrorHandler({})); - server.listen(); - const consistencyStore = useConsistencyStore(); - await consistencyStore.fetch(); - - expect(consistencyStore.error.fetchError).not.toBeNull(); - }); - it('should set error when fetching group inconsistencies fails', async () => { server.use( fetchConsistencyGroupsHandler({ groups: dummyInconsistentGroups }), diff --git a/hermes-console/src/store/consistency/useConsistencyStore.ts b/hermes-console/src/store/consistency/useConsistencyStore.ts index 1d18182c20..13cd036ad4 100644 --- a/hermes-console/src/store/consistency/useConsistencyStore.ts +++ b/hermes-console/src/store/consistency/useConsistencyStore.ts @@ -1,6 +1,5 @@ import { defineStore } from 'pinia'; import { - fetchConsistencyGroups, fetchInconsistentGroups, } from '@/api/hermes-client'; import type { ConsistencyStoreState } from '@/store/consistency/types'; @@ -9,22 +8,11 @@ import type { InconsistentTopic, } from '@/api/inconsistent-group'; -const partition = (array: string[], batch_size: number): string[][] => { - const output: string[][] = []; - for (let i = 0; i < array.length; i += batch_size) { - output[output.length] = array.slice(i, i + batch_size); - } - return output; -}; - -const batch_size = 10; export const useConsistencyStore = defineStore('consistency', { state: (): ConsistencyStoreState => { return { groups: [], - progressPercent: 0, - fetchInProgress: false, error: { fetchError: null, }, @@ -33,23 +21,11 @@ export const useConsistencyStore = defineStore('consistency', { actions: { async fetch() { this.groups = []; - this.progressPercent = 0; - this.fetchInProgress = true; this.error.fetchError = null; try { - const groups = (await fetchConsistencyGroups()).data; - const batches = partition(groups, batch_size); - let processed = 0; - for (const batch of batches) { - const partialResult = (await fetchInconsistentGroups(batch)).data; - processed += batch.length; - this.groups = this.groups.concat(partialResult); - this.progressPercent = Math.floor((processed / groups.length) * 100); - } + this.groups = (await fetchInconsistentGroups()).data; } catch (e) { this.error.fetchError = e as Error; - } finally { - this.fetchInProgress = false; } }, }, diff --git a/hermes-console/src/views/admin/consistency/ConsistencyView.spec.ts b/hermes-console/src/views/admin/consistency/ConsistencyView.spec.ts index 08b4a208f2..eb7cfb91d8 100644 --- a/hermes-console/src/views/admin/consistency/ConsistencyView.spec.ts +++ b/hermes-console/src/views/admin/consistency/ConsistencyView.spec.ts @@ -105,48 +105,6 @@ describe('ConsistencyView', () => { ).not.toBeInTheDocument(); }); - it('should show progress bar when fetching consistency data', () => { - // when - vi.mocked(useInconsistentTopics).mockReturnValueOnce( - useInconsistentTopicsStub, - ); - const { queryByTestId } = render(ConsistencyView, { - testPinia: createTestingPinia({ - initialState: { - consistency: { - ...consistencyStoreState, - fetchInProgress: true, - }, - }, - stubActions: false, - }), - }); - - // then - expect(queryByTestId('consistency-progress-bar')).toBeVisible(); - }); - - it('should not show progress bar when fetching consistency data is not in progress', () => { - // when - vi.mocked(useInconsistentTopics).mockReturnValueOnce( - useInconsistentTopicsStub, - ); - const { queryByTestId } = render(ConsistencyView, { - testPinia: createTestingPinia({ - initialState: { - consistency: { - ...consistencyStoreState, - fetchInProgress: false, - }, - }, - stubActions: false, - }), - }); - - // then - expect(queryByTestId('consistency-progress-bar')).not.toBeInTheDocument(); - }); - it('should show error message when fetching consistency failed', () => { // given vi.mocked(useInconsistentTopics).mockReturnValueOnce( diff --git a/hermes-console/src/views/admin/consistency/ConsistencyView.vue b/hermes-console/src/views/admin/consistency/ConsistencyView.vue index 360ddcdaf8..99a6931f2b 100644 --- a/hermes-console/src/views/admin/consistency/ConsistencyView.vue +++ b/hermes-console/src/views/admin/consistency/ConsistencyView.vue @@ -105,16 +105,6 @@ - - - - -