check panel already exist
Signed-off-by: Ben Hall <ben@benh.codes>
This commit is contained in:
parent
214324d155
commit
276d1f47ca
@ -502,39 +502,41 @@ func ImportHandler(ctx *gin.Context) {
|
|||||||
panelCount := len(existingPanels)
|
panelCount := len(existingPanels)
|
||||||
|
|
||||||
for _, panel := range data.Panels {
|
for _, panel := range data.Panels {
|
||||||
if premiumTier < premium.Premium && panelCount > 2 {
|
if _, ok := panelIdMap[panel.PanelId]; ok {
|
||||||
panel.ForceDisabled = true
|
if premiumTier < premium.Premium && panelCount > 2 {
|
||||||
panel.Disabled = true
|
panel.ForceDisabled = true
|
||||||
|
panel.Disabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if panel.FormId != nil {
|
||||||
|
newFormId := formIdMap[*panel.FormId]
|
||||||
|
panel.FormId = &newFormId
|
||||||
|
}
|
||||||
|
|
||||||
|
if panel.ExitSurveyFormId != nil {
|
||||||
|
newFormId := formIdMap[*panel.ExitSurveyFormId]
|
||||||
|
panel.ExitSurveyFormId = &newFormId
|
||||||
|
}
|
||||||
|
|
||||||
|
if panel.WelcomeMessageEmbed != nil {
|
||||||
|
newEmbedId := embedMap[*panel.WelcomeMessageEmbed]
|
||||||
|
panel.WelcomeMessageEmbed = &newEmbedId
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Fix this permanently
|
||||||
|
panel.MessageId = panel.MessageId - 1
|
||||||
|
|
||||||
|
panelId, err := dbclient.Client.Panel.CreateWithTx(queryCtx, panelTx, panel)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
ctx.JSON(500, utils.ErrorJson(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panelIdMap[panel.PanelId] = panelId
|
||||||
|
|
||||||
|
panelCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
if panel.FormId != nil {
|
|
||||||
newFormId := formIdMap[*panel.FormId]
|
|
||||||
panel.FormId = &newFormId
|
|
||||||
}
|
|
||||||
|
|
||||||
if panel.ExitSurveyFormId != nil {
|
|
||||||
newFormId := formIdMap[*panel.ExitSurveyFormId]
|
|
||||||
panel.ExitSurveyFormId = &newFormId
|
|
||||||
}
|
|
||||||
|
|
||||||
if panel.WelcomeMessageEmbed != nil {
|
|
||||||
newEmbedId := embedMap[*panel.WelcomeMessageEmbed]
|
|
||||||
panel.WelcomeMessageEmbed = &newEmbedId
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Fix this permanently
|
|
||||||
panel.MessageId = panel.MessageId - 1
|
|
||||||
|
|
||||||
panelId, err := dbclient.Client.Panel.CreateWithTx(queryCtx, panelTx, panel)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
ctx.JSON(500, utils.ErrorJson(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
panelIdMap[panel.PanelId] = panelId
|
|
||||||
|
|
||||||
panelCount++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import Panel Access Control Rules
|
// Import Panel Access Control Rules
|
||||||
|
Loading…
x
Reference in New Issue
Block a user