From 02e5880f8c0724d245156b7247ab5328f810b3a0 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Mon, 2 Dec 2024 15:50:13 +0800 Subject: [PATCH] fix(monitor): clone alert dashboard --- pkg/monitor/models/alertdashboard.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/monitor/models/alertdashboard.go b/pkg/monitor/models/alertdashboard.go index fb27df05f11..5b2c76447da 100644 --- a/pkg/monitor/models/alertdashboard.go +++ b/pkg/monitor/models/alertdashboard.go @@ -313,18 +313,15 @@ func (dash *SAlertDashBoard) PerformCloneDashboard(ctx context.Context, userCred return nil, errors.Wrapf(err, "dashboard:%s getAttachPanels err", dash.Id) } for _, panel := range alertPanels { - err := panel.attachDashboard(ctx, iModel.(*SAlertDashBoard).Id) + newDashId := iModel.(*SAlertDashBoard).GetId() + _, err := panel.ClonePanel(ctx, newDashId, monitor.AlertClonePanelInput{}) if err != nil { - err := iModel.Delete(ctx, userCred) - if err != nil { - log.Errorf("delete cloneDashboard:%s err when panel attachDashboard err:%v", input.CloneName, err) - } - return nil, errors.Wrapf(err, "panel:%s attachCloneDashboard:%s err", panel.Name, input.CloneName) + return nil, errors.Wrapf(err, "ClonePanel %s for dashboard %s", panel.GetId(), newDashId) } } boardDetails, err := iModel.(*SAlertDashBoard).GetMoreDetails(monitor.AlertDashBoardDetails{}) if err != nil { - return nil, errors.Wrap(err, "cloneDashboard getDetails err") + return nil, errors.Wrap(err, "GetMoreDetails of dashboard") } output := jsonutils.Marshal(iModel) output.(*jsonutils.JSONDict).Update((jsonutils.Marshal(&boardDetails)))