[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] 确保编译通过,集成测试通过;
This commit is contained in:
爱喝药的大郎
2023-10-20 09:34:29 +08:00
committed by GitHub
parent 59e8a416b5
commit 95158813b9
5 changed files with 24 additions and 0 deletions

View File

@@ -82,6 +82,7 @@
"@types/lodash": "^4.14.171",
"@types/node": "^12.12.25",
"@types/pubsub-js": "^1.5.18",
"pubsub-js": "^1.5.18",
"@typescript-eslint/eslint-plugin": "4.13.0",
"@typescript-eslint/parser": "4.13.0",
"babel-eslint": "10.1.0",

View File

@@ -8,6 +8,7 @@ import { IconFont } from '@knowdesign/icons';
import API from '@src/api/index';
import { hashDataParse } from '@src/constants/common';
const { Option } = Select;
import PubSub from 'pubsub-js'
export interface MetricLine {
createTime?: number;
@@ -214,6 +215,11 @@ export const ExpandedRow: any = ({ record, groupName }: any) => {
// getTopicGroupMetric();
// }, [sortObj]);
// 订阅重置offset成功的消息
PubSub.subscribe('ConsumerGroup-ResetOffset', function(data){
getTopicGroupMetric({});
})
useEffect(() => {
const hashData = hashDataParse(location.hash);
// if (!hashData.groupName) return;

View File

@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
import EditTable from '../TestingProduce/component/EditTable';
import Api from '@src/api/index';
import moment from 'moment';
import PubSub from 'pubsub-js'
const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number | String) => void }) => {
const { value, onChange } = props;
@@ -106,6 +107,8 @@ export default (props: any) => {
message: '重置offset成功',
});
setVisible(false);
// 发布重置offset成功的消息
PubSub.publish('ConsumerGroup-ResetOffset', '1');
} else {
notification.error({
message: '重置offset失败',

View File

@@ -10,6 +10,7 @@ import { ClustersPermissionMap } from '../CommonConfig';
import ResetOffsetDrawer from './ResetOffsetDrawer';
import SwitchTab from '@src/components/SwitchTab';
import ContentWithCopy from '@src/components/CopyContent';
import PubSub from "pubsub-js";
const { Option } = Select;
@@ -335,6 +336,11 @@ export default (props: any) => {
});
}, [visible]);
// 订阅重置offset成功的消息
PubSub.subscribe('TopicDetail-ResetOffset', function(message, data){
getTopicGroupMetric({hashData: data});
})
useEffect(() => {
if (partitionList.length === 0) return;
getTopicGroupMetricHistory(partitionList, hashData);

View File

@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
import EditTable from '../TestingProduce/component/EditTable';
import Api from '@src/api/index';
import moment from 'moment';
import PubSub from "pubsub-js";
const CustomSelectResetTime = (props: { value?: string; onChange?: (val: Number | String) => void }) => {
const { value, onChange } = props;
@@ -106,6 +107,13 @@ export default (props: any) => {
message: '重置offset成功',
});
setResetOffsetVisible(false);
// 发布重置offset成功的消息
PubSub.publish('TopicDetail-ResetOffset',
{
groupName: record.groupName,
topicName: record.topicName
}
);
} else {
notification.error({
message: '重置offset失败',