Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display groups in notification object(msp & cmp) #2023

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shell/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"allocation": "allocation",
"allocation component node": "allocation component node",
"analysis result": "analysis result",
"and {length} others": "and {length} others",
"announcement content": "content",
"announcement management": "announcement management",
"application used": "application used",
Expand Down
1 change: 1 addition & 0 deletions shell/app/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"allocation": "分配量",
"allocation component node": "分配组件节点",
"analysis result": "分析结果",
"and {length} others": "等 {length} 组在内",
"announcement content": "公告内容",
"announcement management": "公告管理",
"application used": "应用已使用",
Expand Down
24 changes: 11 additions & 13 deletions shell/app/modules/cmp/common/alarm-strategy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from 'react';
import { isEmpty } from 'lodash';
import { map } from 'lodash';
import moment from 'moment';
import { useMount, useUnmount } from 'react-use';
import { Modal, Button, Spin, Switch, Table, Tooltip } from 'antd';
Expand All @@ -25,7 +25,6 @@ import orgMemberStore from 'common/stores/org-member';
import projectMemberStore from 'common/stores/project-member';
import cmpAlarmStrategyStore from 'app/modules/cmp/stores/alarm-strategy';
import mspAlarmStrategyStore from 'app/modules/msp/alarm-manage/alarm-strategy/stores/alarm-strategy';
import { ListTargets } from 'application/pages/settings/components/app-notify/common-notify-group';
import orgStore from 'app/org-home/stores/org';
import routeInfoStore from 'core/stores/route';
import './index.scss';
Expand Down Expand Up @@ -53,10 +52,8 @@ interface IProps {
scopeId: string;
commonPayload?: Obj;
}

export default ({ scopeType, scopeId, commonPayload }: IProps) => {
const memberStore = memberStoreMap[scopeType];
const roleMap = memberStore.useStore((s) => s.roleMap);
const { getRoleMap } = memberStore.effects;
const alarmStrategyStore = alarmStrategyStoreMap[scopeType];
const [alertList, alarmPaging] = alarmStrategyStore.useStore((s) => [s.alertList, s.alarmPaging]);
Expand Down Expand Up @@ -130,21 +127,22 @@ export default ({ scopeType, scopeId, commonPayload }: IProps) => {
// ]),
{
title: i18n.t('default:notification target'),
dataIndex: ['notifies', '0', 'notifyGroup'],
dataIndex: 'notifies',
width: 400,
className: 'notify-info',
ellipsis: true,
render: (notifyGroup: COMMON_STRATEGY_NOTIFY.INotifyGroup) => {
render: (notifies: COMMON_STRATEGY_NOTIFY.INotifyGroupNotify[]) => {
const tips = i18n.t('cmp:Notification group does not exist or has been remove. Please change one.');
if (notifies?.length && notifies[0].notifyGroup?.name) {
const groupNames = map(notifies, (item) => item.notifyGroup?.name).join(', ');
const groupLength = notifies.length;
return `${groupNames} ${i18n.t('cmp:and {length} others', { length: groupLength })}`;
sherotree marked this conversation as resolved.
Show resolved Hide resolved
}
return (
<div className="flex-div flex">
{isEmpty(notifyGroup) ? (
<Tooltip title={tips}>
<span className="text-sub">{tips}</span>
</Tooltip>
) : (
<ListTargets targets={notifyGroup.targets} roleMap={roleMap} />
)}
<Tooltip title={tips}>
<span className="text-sub">{tips}</span>
</Tooltip>
</div>
);
},
Expand Down