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,
|
CustomId: panel.CustomId,
|
||||||
Style: component.ButtonStyle(panel.ButtonStyle),
|
Style: component.ButtonStyle(panel.ButtonStyle),
|
||||||
Emoji: emoji,
|
Emoji: emoji,
|
||||||
|
Disabled: panel.Disabled,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,21 +45,23 @@ type panelBody struct {
|
|||||||
ButtonLabel string `json:"button_label"`
|
ButtonLabel string `json:"button_label"`
|
||||||
FormId *int `json:"form_id"`
|
FormId *int `json:"form_id"`
|
||||||
NamingScheme *string `json:"naming_scheme"`
|
NamingScheme *string `json:"naming_scheme"`
|
||||||
|
Disabled bool `json:"disabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *panelBody) IntoPanelMessageData(customId string, isPremium bool) panelMessageData {
|
func (p *panelBody) IntoPanelMessageData(customId string, isPremium bool) panelMessageData {
|
||||||
return panelMessageData{
|
return panelMessageData{
|
||||||
ChannelId: p.ChannelId,
|
ChannelId: p.ChannelId,
|
||||||
Title: p.Title,
|
Title: p.Title,
|
||||||
Content: p.Content,
|
Content: p.Content,
|
||||||
CustomId: customId,
|
CustomId: customId,
|
||||||
Colour: int(p.Colour),
|
Colour: int(p.Colour),
|
||||||
ImageUrl: p.ImageUrl,
|
ImageUrl: p.ImageUrl,
|
||||||
ThumbnailUrl: p.ThumbnailUrl,
|
ThumbnailUrl: p.ThumbnailUrl,
|
||||||
Emoji: p.getEmoji(),
|
Emoji: p.getEmoji(),
|
||||||
ButtonStyle: p.ButtonStyle,
|
ButtonStyle: p.ButtonStyle,
|
||||||
ButtonLabel: p.ButtonLabel,
|
ButtonLabel: p.ButtonLabel,
|
||||||
IsPremium: isPremium,
|
ButtonDisabled: p.Disabled,
|
||||||
|
IsPremium: isPremium,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +173,7 @@ func CreatePanel(ctx *gin.Context) {
|
|||||||
ButtonLabel: data.ButtonLabel,
|
ButtonLabel: data.ButtonLabel,
|
||||||
FormId: data.FormId,
|
FormId: data.FormId,
|
||||||
NamingScheme: data.NamingScheme,
|
NamingScheme: data.NamingScheme,
|
||||||
|
Disabled: data.Disabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
panelId, err := dbclient.Client.Panel.Create(panel)
|
panelId, err := dbclient.Client.Panel.Create(panel)
|
||||||
|
@ -19,6 +19,7 @@ type panelMessageData struct {
|
|||||||
Emoji *emoji.Emoji
|
Emoji *emoji.Emoji
|
||||||
ButtonStyle component.ButtonStyle
|
ButtonStyle component.ButtonStyle
|
||||||
ButtonLabel string
|
ButtonLabel string
|
||||||
|
ButtonDisabled bool
|
||||||
IsPremium bool
|
IsPremium bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,17 +39,18 @@ func panelIntoMessageData(panel database.Panel, isPremium bool) panelMessageData
|
|||||||
}
|
}
|
||||||
|
|
||||||
return panelMessageData{
|
return panelMessageData{
|
||||||
ChannelId: panel.ChannelId,
|
ChannelId: panel.ChannelId,
|
||||||
Title: panel.Title,
|
Title: panel.Title,
|
||||||
Content: panel.Content,
|
Content: panel.Content,
|
||||||
CustomId: panel.CustomId,
|
CustomId: panel.CustomId,
|
||||||
Colour: int(panel.Colour),
|
Colour: int(panel.Colour),
|
||||||
ImageUrl: panel.ImageUrl,
|
ImageUrl: panel.ImageUrl,
|
||||||
ThumbnailUrl: panel.ThumbnailUrl,
|
ThumbnailUrl: panel.ThumbnailUrl,
|
||||||
Emoji: emote,
|
Emoji: emote,
|
||||||
ButtonStyle: component.ButtonStyle(panel.ButtonStyle),
|
ButtonStyle: component.ButtonStyle(panel.ButtonStyle),
|
||||||
ButtonLabel: panel.ButtonLabel,
|
ButtonLabel: panel.ButtonLabel,
|
||||||
IsPremium: isPremium,
|
ButtonDisabled: panel.Disabled,
|
||||||
|
IsPremium: isPremium,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ func (p *panelMessageData) send(ctx *botcontext.BotContext) (uint64, error) {
|
|||||||
Style: p.ButtonStyle,
|
Style: p.ButtonStyle,
|
||||||
Emoji: p.Emoji,
|
Emoji: p.Emoji,
|
||||||
Url: nil,
|
Url: nil,
|
||||||
Disabled: false,
|
Disabled: p.ButtonDisabled,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,8 @@ func UpdatePanel(ctx *gin.Context) {
|
|||||||
existing.ImageUrl != data.ImageUrl ||
|
existing.ImageUrl != data.ImageUrl ||
|
||||||
existing.ThumbnailUrl != data.ThumbnailUrl ||
|
existing.ThumbnailUrl != data.ThumbnailUrl ||
|
||||||
component.ButtonStyle(existing.ButtonStyle) != data.ButtonStyle ||
|
component.ButtonStyle(existing.ButtonStyle) != data.ButtonStyle ||
|
||||||
existing.ButtonLabel != data.ButtonLabel
|
existing.ButtonLabel != data.ButtonLabel ||
|
||||||
|
existing.Disabled != data.Disabled
|
||||||
|
|
||||||
newMessageId := existing.MessageId
|
newMessageId := existing.MessageId
|
||||||
|
|
||||||
@ -168,6 +169,7 @@ func UpdatePanel(ctx *gin.Context) {
|
|||||||
FormId: data.FormId,
|
FormId: data.FormId,
|
||||||
NamingScheme: data.NamingScheme,
|
NamingScheme: data.NamingScheme,
|
||||||
ForceDisabled: existing.ForceDisabled,
|
ForceDisabled: existing.ForceDisabled,
|
||||||
|
Disabled: data.Disabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = dbclient.Client.Panel.Update(panel); err != nil {
|
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="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" />
|
<Input col2={true} label="Small Image URL" bind:value={data.thumbnail_url} placeholder="https://example.com/image.png" />
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -156,6 +168,7 @@
|
|||||||
import Select from 'svelte-select';
|
import Select from 'svelte-select';
|
||||||
import Dropdown from "../form/Dropdown.svelte";
|
import Dropdown from "../form/Dropdown.svelte";
|
||||||
import Toggle from "svelte-toggle";
|
import Toggle from "svelte-toggle";
|
||||||
|
import Checkbox from "../form/Checkbox.svelte";
|
||||||
|
|
||||||
export let guildId;
|
export let guildId;
|
||||||
export let seedDefault = true;
|
export let seedDefault = true;
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
width: 75%;
|
width: 75%;
|
||||||
margin: 10% auto auto auto;
|
margin: 10% auto auto auto;
|
||||||
|
padding-bottom: 5%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 1280px) {
|
@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/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-20221213140509-14ca97c65cbf
|
github.com/TicketsBot/database v0.0.0-20221223231047-b0d3d36c563b
|
||||||
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
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-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 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-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 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=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user