Skip to content

Commit

Permalink
adjust ui
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky committed Aug 2, 2024
1 parent cf39297 commit 41ce755
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 138 deletions.
26 changes: 7 additions & 19 deletions hermes-console/json-server/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -60,9 +50,7 @@
]
}
]
}
],
"inconsistentGroups2": [
},
{
"name": "pl.allegro.public.group2",
"inconsistentMetadata": [
Expand Down
4 changes: 1 addition & 3 deletions hermes-console/json-server/routes.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 1 addition & 13 deletions hermes-console/src/api/hermes-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,9 @@ export function fetchConsumerGroups(
);
}

export function fetchConsistencyGroups(): ResponsePromise<string[]> {
return axios.get<string[]>('/consistency/groups');
}

export function fetchInconsistentGroups(

Check failure on line 209 in hermes-console/src/api/hermes-client/index.ts

View workflow job for this annotation

GitHub Actions / build

Replace `⏎):·ResponsePromise<InconsistentGroup[]` with `):·ResponsePromise<⏎··InconsistentGroup[]⏎`
groups: string[],
): ResponsePromise<InconsistentGroup[]> {
return axios.get<InconsistentGroup[]>('/consistency/inconsistencies/groups', {
params: {
groupNames: groups,
},
paramsSerializer: {
indexes: null,
},
});
return axios.get<InconsistentGroup[]>('/consistency/inconsistencies/groups');
}

export function fetchInconsistentTopics(): ResponsePromise<string[]> {
Expand Down
2 changes: 0 additions & 2 deletions hermes-console/src/dummy/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const authStoreState: AuthStoreState = {
};

export const consistencyStoreState: ConsistencyStoreState = {
fetchInProgress: false,
progressPercent: 0,
error: {
fetchError: null,
},
Expand Down
11 changes: 0 additions & 11 deletions hermes-console/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}: {
Expand Down
2 changes: 0 additions & 2 deletions hermes-console/src/store/consistency/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { InconsistentGroup } from '@/api/inconsistent-group';

export interface ConsistencyStoreState {
groups: InconsistentGroup[];
progressPercent: number;
fetchInProgress: boolean;
error: ConsistencyFetchError;
}

Expand Down
11 changes: 0 additions & 11 deletions hermes-console/src/store/consistency/useConsistencyStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 }),
Expand Down
26 changes: 1 addition & 25 deletions hermes-console/src/store/consistency/useConsistencyStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineStore } from 'pinia';
import {

Check failure on line 2 in hermes-console/src/store/consistency/useConsistencyStore.ts

View workflow job for this annotation

GitHub Actions / build

Replace `⏎··fetchInconsistentGroups,⏎` with `·fetchInconsistentGroups·`
fetchConsistencyGroups,
fetchInconsistentGroups,
} from '@/api/hermes-client';
import type { ConsistencyStoreState } from '@/store/consistency/types';
Expand All @@ -9,22 +8,11 @@ import type {
InconsistentTopic,
} from '@/api/inconsistent-group';

Check failure on line 9 in hermes-console/src/store/consistency/useConsistencyStore.ts

View workflow job for this annotation

GitHub Actions / build

Delete `⏎`

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,
},
Expand All @@ -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;
}
},
},
Expand Down
42 changes: 0 additions & 42 deletions hermes-console/src/views/admin/consistency/ConsistencyView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 0 additions & 10 deletions hermes-console/src/views/admin/consistency/ConsistencyView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@
</v-btn>
</v-col>
</v-row>
<v-row>
<v-col md="12" v-if="consistencyStore.fetchInProgress">
<v-progress-linear
:model-value="consistencyStore.progressPercent"
:buffer-value="100"
color="blue"
data-testid="consistency-progress-bar"
></v-progress-linear>
</v-col>
</v-row>
<v-row dense>
<v-col md="12">
<v-text-field
Expand Down

0 comments on commit 41ce755

Please sign in to comment.