Handle disabled panels

This commit is contained in:
rxdn 2022-12-13 14:08:40 +00:00
parent 4488600229
commit 89fe0f305b
5 changed files with 16 additions and 3 deletions

View File

@ -46,6 +46,11 @@ func ResendPanel(ctx *gin.Context) {
return return
} }
if panel.ForceDisabled {
ctx.JSON(400, utils.ErrorStr("This panel is disabled and cannot be modified: please reactivate premium to re-enable it"))
return
}
// delete old message // delete old message
if err := rest.DeleteMessage(botContext.Token, botContext.RateLimiter, panel.ChannelId, panel.GuildId); err != nil { if err := rest.DeleteMessage(botContext.Token, botContext.RateLimiter, panel.ChannelId, panel.GuildId); err != nil {
var unwrapped request.RestError var unwrapped request.RestError

View File

@ -49,6 +49,11 @@ func UpdatePanel(ctx *gin.Context) {
return return
} }
if existing.ForceDisabled {
ctx.JSON(400, utils.ErrorStr("This panel is disabled and cannot be modified: please reactivate premium to re-enable it"))
return
}
if !data.doValidations(ctx, guildId) { if !data.doValidations(ctx, guildId) {
return return
} }
@ -162,6 +167,7 @@ func UpdatePanel(ctx *gin.Context) {
ButtonLabel: data.ButtonLabel, ButtonLabel: data.ButtonLabel,
FormId: data.FormId, FormId: data.FormId,
NamingScheme: data.NamingScheme, NamingScheme: data.NamingScheme,
ForceDisabled: existing.ForceDisabled,
} }
if err = dbclient.Client.Panel.Update(panel); err != nil { if err = dbclient.Client.Panel.Update(panel); err != nil {

View File

@ -50,10 +50,10 @@
<td>{panel.title}</td> <td>{panel.title}</td>
<td class="category-col">{channels.find((c) => c.id === panel.category_id)?.name ?? 'Unknown Category'}</td> <td class="category-col">{channels.find((c) => c.id === panel.category_id)?.name ?? 'Unknown Category'}</td>
<td> <td>
<Button on:click={() => resendPanel(panel.panel_id)}>Resend</Button> <Button disabled={panel.force_disabled} on:click={() => resendPanel(panel.panel_id)}>Resend</Button>
</td> </td>
<td> <td>
<Button on:click={() => openEditModal(panel.panel_id)}>Edit</Button> <Button disabled={panel.force_disabled} on:click={() => openEditModal(panel.panel_id)}>Edit</Button>
</td> </td>
<td> <td>
<Button on:click={() => panelToDelete = panel}>Delete</Button> <Button on:click={() => panelToDelete = panel}>Delete</Button>

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42 github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42
github.com/TicketsBot/database v0.0.0-20220830131231-b5540b57f6cb github.com/TicketsBot/database v0.0.0-20221213140509-14ca97c65cbf
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
github.com/TicketsBot/worker v0.0.0-20220830131837-12d85aca5c71 github.com/TicketsBot/worker v0.0.0-20220830131837-12d85aca5c71
github.com/apex/log v1.1.2 github.com/apex/log v1.1.2

2
go.sum
View File

@ -41,6 +41,8 @@ github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42 h1:3/qnbrEfL8gqS
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42/go.mod h1:WxHh6bY7KhIqdayeOp5f0Zj2NNi/7QqCQfMEqHnpdAM= github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42/go.mod h1:WxHh6bY7KhIqdayeOp5f0Zj2NNi/7QqCQfMEqHnpdAM=
github.com/TicketsBot/database v0.0.0-20220830131231-b5540b57f6cb h1:mXBn09KBzbVRmg+k1JC67DL8YXisCO74D9nIW/xi9Vg= github.com/TicketsBot/database v0.0.0-20220830131231-b5540b57f6cb h1:mXBn09KBzbVRmg+k1JC67DL8YXisCO74D9nIW/xi9Vg=
github.com/TicketsBot/database v0.0.0-20220830131231-b5540b57f6cb/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI= github.com/TicketsBot/database v0.0.0-20220830131231-b5540b57f6cb/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
github.com/TicketsBot/database v0.0.0-20221213140509-14ca97c65cbf h1:85dMD4l9KoOolfkCi32FYJ8A+rsCFJW1nls3ZNNFIaA=
github.com/TicketsBot/database v0.0.0-20221213140509-14ca97c65cbf/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s= github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c= github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM= github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=