Add option to disable panels
This commit is contained in:
parent
89fe0f305b
commit
e5148d4086
@ -90,6 +90,7 @@ func (d *multiPanelMessageData) send(ctx *botcontext.BotContext, panels []databa
|
||||
CustomId: panel.CustomId,
|
||||
Style: component.ButtonStyle(panel.ButtonStyle),
|
||||
Emoji: emoji,
|
||||
Disabled: panel.Disabled,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -45,21 +45,23 @@ type panelBody struct {
|
||||
ButtonLabel string `json:"button_label"`
|
||||
FormId *int `json:"form_id"`
|
||||
NamingScheme *string `json:"naming_scheme"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
|
||||
func (p *panelBody) IntoPanelMessageData(customId string, isPremium bool) panelMessageData {
|
||||
return panelMessageData{
|
||||
ChannelId: p.ChannelId,
|
||||
Title: p.Title,
|
||||
Content: p.Content,
|
||||
CustomId: customId,
|
||||
Colour: int(p.Colour),
|
||||
ImageUrl: p.ImageUrl,
|
||||
ThumbnailUrl: p.ThumbnailUrl,
|
||||
Emoji: p.getEmoji(),
|
||||
ButtonStyle: p.ButtonStyle,
|
||||
ButtonLabel: p.ButtonLabel,
|
||||
IsPremium: isPremium,
|
||||
ChannelId: p.ChannelId,
|
||||
Title: p.Title,
|
||||
Content: p.Content,
|
||||
CustomId: customId,
|
||||
Colour: int(p.Colour),
|
||||
ImageUrl: p.ImageUrl,
|
||||
ThumbnailUrl: p.ThumbnailUrl,
|
||||
Emoji: p.getEmoji(),
|
||||
ButtonStyle: p.ButtonStyle,
|
||||
ButtonLabel: p.ButtonLabel,
|
||||
ButtonDisabled: p.Disabled,
|
||||
IsPremium: isPremium,
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,6 +173,7 @@ func CreatePanel(ctx *gin.Context) {
|
||||
ButtonLabel: data.ButtonLabel,
|
||||
FormId: data.FormId,
|
||||
NamingScheme: data.NamingScheme,
|
||||
Disabled: data.Disabled,
|
||||
}
|
||||
|
||||
panelId, err := dbclient.Client.Panel.Create(panel)
|
||||
|
@ -19,6 +19,7 @@ type panelMessageData struct {
|
||||
Emoji *emoji.Emoji
|
||||
ButtonStyle component.ButtonStyle
|
||||
ButtonLabel string
|
||||
ButtonDisabled bool
|
||||
IsPremium bool
|
||||
}
|
||||
|
||||
@ -38,17 +39,18 @@ func panelIntoMessageData(panel database.Panel, isPremium bool) panelMessageData
|
||||
}
|
||||
|
||||
return panelMessageData{
|
||||
ChannelId: panel.ChannelId,
|
||||
Title: panel.Title,
|
||||
Content: panel.Content,
|
||||
CustomId: panel.CustomId,
|
||||
Colour: int(panel.Colour),
|
||||
ImageUrl: panel.ImageUrl,
|
||||
ThumbnailUrl: panel.ThumbnailUrl,
|
||||
Emoji: emote,
|
||||
ButtonStyle: component.ButtonStyle(panel.ButtonStyle),
|
||||
ButtonLabel: panel.ButtonLabel,
|
||||
IsPremium: isPremium,
|
||||
ChannelId: panel.ChannelId,
|
||||
Title: panel.Title,
|
||||
Content: panel.Content,
|
||||
CustomId: panel.CustomId,
|
||||
Colour: int(panel.Colour),
|
||||
ImageUrl: panel.ImageUrl,
|
||||
ThumbnailUrl: panel.ThumbnailUrl,
|
||||
Emoji: emote,
|
||||
ButtonStyle: component.ButtonStyle(panel.ButtonStyle),
|
||||
ButtonLabel: panel.ButtonLabel,
|
||||
ButtonDisabled: panel.Disabled,
|
||||
IsPremium: isPremium,
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +81,7 @@ func (p *panelMessageData) send(ctx *botcontext.BotContext) (uint64, error) {
|
||||
Style: p.ButtonStyle,
|
||||
Emoji: p.Emoji,
|
||||
Url: nil,
|
||||
Disabled: false,
|
||||
Disabled: p.ButtonDisabled,
|
||||
})),
|
||||
},
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ func UpdatePanel(ctx *gin.Context) {
|
||||
existing.ImageUrl != data.ImageUrl ||
|
||||
existing.ThumbnailUrl != data.ThumbnailUrl ||
|
||||
component.ButtonStyle(existing.ButtonStyle) != data.ButtonStyle ||
|
||||
existing.ButtonLabel != data.ButtonLabel
|
||||
existing.ButtonLabel != data.ButtonLabel ||
|
||||
existing.Disabled != data.Disabled
|
||||
|
||||
newMessageId := existing.MessageId
|
||||
|
||||
@ -168,6 +169,7 @@ func UpdatePanel(ctx *gin.Context) {
|
||||
FormId: data.FormId,
|
||||
NamingScheme: data.NamingScheme,
|
||||
ForceDisabled: existing.ForceDisabled,
|
||||
Disabled: data.Disabled,
|
||||
}
|
||||
|
||||
if err = dbclient.Client.Panel.Update(panel); err != nil {
|
||||
|
@ -136,6 +136,18 @@
|
||||
<Input col2={true} label="Large Image URL" bind:value={data.image_url} placeholder="https://example.com/image.png" />
|
||||
<Input col2={true} label="Small Image URL" bind:value={data.thumbnail_url} placeholder="https://example.com/image.png" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<div class="row" style="justify-content: flex-start; gap: 10px">
|
||||
<div style="white-space: nowrap">
|
||||
<Checkbox label="Disable Panel" bind:value={data.disabled}></Checkbox>
|
||||
</div>
|
||||
{#if data.disabled}
|
||||
<b style="display: flex; align-self: center">You will be unable to open any tickets with this panel</b>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -156,6 +168,7 @@
|
||||
import Select from 'svelte-select';
|
||||
import Dropdown from "../form/Dropdown.svelte";
|
||||
import Toggle from "svelte-toggle";
|
||||
import Checkbox from "../form/Checkbox.svelte";
|
||||
|
||||
export let guildId;
|
||||
export let seedDefault = true;
|
||||
|
@ -75,6 +75,7 @@
|
||||
display: flex;
|
||||
width: 75%;
|
||||
margin: 10% auto auto auto;
|
||||
padding-bottom: 5%;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1280px) {
|
||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
|
||||
github.com/TicketsBot/common v0.0.0-20220703211704-f792aa9f0c42
|
||||
github.com/TicketsBot/database v0.0.0-20221213140509-14ca97c65cbf
|
||||
github.com/TicketsBot/database v0.0.0-20221223231047-b0d3d36c563b
|
||||
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
|
||||
github.com/TicketsBot/worker v0.0.0-20220830131837-12d85aca5c71
|
||||
github.com/apex/log v1.1.2
|
||||
|
2
go.sum
2
go.sum
@ -43,6 +43,8 @@ github.com/TicketsBot/database v0.0.0-20220830131231-b5540b57f6cb h1:mXBn09KBzbV
|
||||
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/database v0.0.0-20221223231047-b0d3d36c563b h1:ZlPTCuJVEjvt6Rdz1mUgkJUVMj8XrLOwrbh05vcl1KI=
|
||||
github.com/TicketsBot/database v0.0.0-20221223231047-b0d3d36c563b/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/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
|
||||
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
|
||||
|
Loading…
x
Reference in New Issue
Block a user