Skip to content

Commit 9515881

Browse files
authored
[Bugfix]修复消费组Offset重置后,提示重置成功,但是前端不刷新数据,Offset无变化的问题 (#1090)
请不要在没有先创建Issue的情况下创建Pull Request。 ## 变更的目的是什么 修复消费组Offset重置后,提示重置成功,但是前端不刷新数据,Offset无变化的问题 ## 简短的更新日志 使用pubsub-js解决问题 ## 验证这一变化 ### 重置前: ![7c90f21063995e7a155d30a24f70c82](https://github.com/didi/KnowStreaming/assets/43955116/db10a87d-2353-48f6-bd29-71b6eb47dab9) ### 重置指定分区 ![039cf8a01ced8783ea957ab72187d83](https://github.com/didi/KnowStreaming/assets/43955116/f8cd4ac0-d093-4df2-aab3-915571bdd8de) ![84580ab27f725b68456793a47e0ad72](https://github.com/didi/KnowStreaming/assets/43955116/5ce85211-95a0-4809-accd-d57b141b4132) ### 重置最新offset ![image](https://github.com/didi/KnowStreaming/assets/43955116/227b7939-40ac-4c6c-8e92-03fc16413dce) ### 重置最旧offset ![image](https://github.com/didi/KnowStreaming/assets/43955116/56d08648-ac58-43c9-86cd-f88a2a8ae8dd) 请遵循此清单,以帮助我们快速轻松地整合您的贡献: * [x] 一个 PR(Pull Request的简写)只解决一个问题,禁止一个 PR 解决多个问题; * [x] 确保 PR 有对应的 Issue(通常在您开始处理之前创建),除非是书写错误之类的琐碎更改不需要 Issue ; * [x] 格式化 PR 及 Commit-Log 的标题及内容,例如 #861 。PS:Commit-Log 需要在 Git Commit 代码时进行填写,在 GitHub 上修改不了; * [x] 编写足够详细的 PR 描述,以了解 PR 的作用、方式和原因; * [x] 编写必要的单元测试来验证您的逻辑更正。如果提交了新功能或重大更改,请记住在 test 模块中添加 integration-test; * [x] 确保编译通过,集成测试通过;
1 parent 59e8a41 commit 9515881

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

km-console/packages/layout-clusters-fe/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"@types/lodash": "^4.14.171",
8383
"@types/node": "^12.12.25",
8484
"@types/pubsub-js": "^1.5.18",
85+
"pubsub-js": "^1.5.18",
8586
"@typescript-eslint/eslint-plugin": "4.13.0",
8687
"@typescript-eslint/parser": "4.13.0",
8788
"babel-eslint": "10.1.0",

km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ExpandedRow.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IconFont } from '@knowdesign/icons';
88
import API from '@src/api/index';
99
import { hashDataParse } from '@src/constants/common';
1010
const { Option } = Select;
11+
import PubSub from 'pubsub-js'
1112

1213
export interface MetricLine {
1314
createTime?: number;
@@ -214,6 +215,11 @@ export const ExpandedRow: any = ({ record, groupName }: any) => {
214215
// getTopicGroupMetric();
215216
// }, [sortObj]);
216217

218+
// 订阅重置offset成功的消息
219+
PubSub.subscribe('ConsumerGroup-ResetOffset', function(data){
220+
getTopicGroupMetric({});
221+
})
222+
217223
useEffect(() => {
218224
const hashData = hashDataParse(location.hash);
219225
// if (!hashData.groupName) return;

km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/ResetOffsetDrawer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
44
import EditTable from '../TestingProduce/component/EditTable';
55
import Api from '@src/api/index';
66
import moment from 'moment';
7+
import PubSub from 'pubsub-js'
78

89
const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number | String) => void }) => {
910
const { value, onChange } = props;
@@ -106,6 +107,8 @@ export default (props: any) => {
106107
message: '重置offset成功',
107108
});
108109
setVisible(false);
110+
// 发布重置offset成功的消息
111+
PubSub.publish('ConsumerGroup-ResetOffset', '1');
109112
} else {
110113
notification.error({
111114
message: '重置offset失败',

km-console/packages/layout-clusters-fe/src/pages/TopicDetail/ConsumerGroupDetail.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ClustersPermissionMap } from '../CommonConfig';
1010
import ResetOffsetDrawer from './ResetOffsetDrawer';
1111
import SwitchTab from '@src/components/SwitchTab';
1212
import ContentWithCopy from '@src/components/CopyContent';
13+
import PubSub from "pubsub-js";
1314

1415
const { Option } = Select;
1516

@@ -335,6 +336,11 @@ export default (props: any) => {
335336
});
336337
}, [visible]);
337338

339+
// 订阅重置offset成功的消息
340+
PubSub.subscribe('TopicDetail-ResetOffset', function(message, data){
341+
getTopicGroupMetric({hashData: data});
342+
})
343+
338344
useEffect(() => {
339345
if (partitionList.length === 0) return;
340346
getTopicGroupMetricHistory(partitionList, hashData);

km-console/packages/layout-clusters-fe/src/pages/TopicDetail/ResetOffsetDrawer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
44
import EditTable from '../TestingProduce/component/EditTable';
55
import Api from '@src/api/index';
66
import moment from 'moment';
7+
import PubSub from "pubsub-js";
78

89
const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number | String) => void }) => {
910
const { value, onChange } = props;
@@ -106,6 +107,13 @@ export default (props: any) => {
106107
message: '重置offset成功',
107108
});
108109
setResetOffsetVisible(false);
110+
// 发布重置offset成功的消息
111+
PubSub.publish('TopicDetail-ResetOffset',
112+
{
113+
groupName: record.groupName,
114+
topicName: record.topicName
115+
}
116+
);
109117
} else {
110118
notification.error({
111119
message: '重置offset失败',

0 commit comments

Comments
 (0)