Skip to content

Commit

Permalink
feat(*): add pagination for consumers/<id>/consumer_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
raoxiaoyan committed Sep 6, 2023
1 parent add9e24 commit aaffa1b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ describe('<ConsumerGroupList />', () => {
method: 'GET',
url: `${baseConfigKM.apiBaseUrl}/${baseConfigKM.workspace}/consumer_groups*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getConsumerGroups')
}
Expand All @@ -70,12 +72,14 @@ describe('<ConsumerGroupList />', () => {
method: 'GET',
url: `${baseConfigKM.apiBaseUrl}/${configConsumerKM.workspace}/consumers/${configConsumerKM.consumerId}/consumer_groups*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getGroups')
}
Expand Down Expand Up @@ -674,12 +678,14 @@ describe('<ConsumerGroupList />', () => {
method: 'GET',
url: `${baseConfigKonnect.apiBaseUrl}/api/runtime_groups/${baseConfigKonnect.controlPlaneId}/consumer_groups*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getConsumerGroups')
}
Expand All @@ -692,12 +698,14 @@ describe('<ConsumerGroupList />', () => {
method: 'GET',
url: `${configConsumerKonnect.apiBaseUrl}/api/runtime_groups/${configConsumerKonnect.controlPlaneId}/consumers/${configConsumerKonnect.consumerId}/consumer_groups*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getGroups')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ const filterConfig = computed<InstanceType<typeof EntityFilter>['$props']['confi
} as FuzzyMatchFilterConfig
})
const dataKeyName = computed((): string | undefined => isConsumerPage.value ? 'consumer_groups' : undefined)
const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value, dataKeyName.value)
const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value)
const clearFilter = (): void => {
filterQuery.value = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ describe('<ConsumerList />', () => {
method: 'GET',
url: `${baseConfigKM.apiBaseUrl}/${baseConfigKM.workspace}/consumers*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getConsumers')
}
Expand All @@ -70,12 +72,14 @@ describe('<ConsumerList />', () => {
method: 'GET',
url: `${baseConfigKM.apiBaseUrl}/${configGroupKM.workspace}/consumer_groups/${configGroupKM.consumerGroupId}/consumers*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getGroupConsumers')
}
Expand Down Expand Up @@ -674,12 +678,14 @@ describe('<ConsumerList />', () => {
method: 'GET',
url: `${baseConfigKonnect.apiBaseUrl}/api/runtime_groups/${baseConfigKonnect.controlPlaneId}/consumers*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getConsumers')
}
Expand All @@ -692,12 +698,14 @@ describe('<ConsumerList />', () => {
method: 'GET',
url: `${configGroupKonnect.apiBaseUrl}/api/runtime_groups/${configGroupKonnect.controlPlaneId}/consumer_groups/${configGroupKonnect.consumerGroupId}/consumers*`,
},
{
statusCode: 200,
body: {
data: params?.mockData ?? [],
total: params?.mockData?.length ?? 0,
},
(req) => {
const size = req.query.size ? Number(req.query.size) : 30
const offset = req.query.offset ? Number(req.query.offset) : 0

req.reply({
statusCode: 200,
body: paginate(params?.mockData ?? [], size, offset),
})
},
).as(params?.alias ?? 'getGroupConsumers')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ const filterConfig = computed<InstanceType<typeof EntityFilter>['$props']['confi
schema: props.config.filterSchema,
} as FuzzyMatchFilterConfig
})
const dataKeyName = computed((): string | undefined => isConsumerGroupPage.value ? 'consumers' : undefined)
const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value, dataKeyName.value)
const { fetcher, fetcherState } = useFetcher(props.config, fetcherBaseUrl.value)
const clearFilter = (): void => {
filterQuery.value = ''
Expand Down

0 comments on commit aaffa1b

Please sign in to comment.