Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/http/endpoints/api/panel/panelcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type panelBody struct {
UseThreads bool `json:"use_threads"`
TicketNotificationChannel *uint64 `json:"ticket_notification_channel,string"`
CooldownSeconds int `json:"cooldown_seconds"`
TicketLimit *uint8 `json:"ticket_limit"`
}

func (p *panelBody) IntoPanelMessageData(customId string, isPremium bool) panelMessageData {
Expand Down Expand Up @@ -216,6 +217,11 @@ func CreatePanel(c *gin.Context) {
welcomeMessageEmbed = &id
}

// If ticket limit is 0, treat it as use global setting
if data.TicketLimit == utils.Ptr(uint8(0)) {
data.TicketLimit = nil
}

// Store in DB
panel := database.Panel{
MessageId: msgId,
Expand Down Expand Up @@ -245,6 +251,7 @@ func CreatePanel(c *gin.Context) {
UseThreads: data.UseThreads,
TicketNotificationChannel: data.TicketNotificationChannel,
CooldownSeconds: data.CooldownSeconds,
TicketLimit: data.TicketLimit,
}

createOptions := panelCreateOptions{
Expand Down
6 changes: 6 additions & 0 deletions app/http/endpoints/api/panel/panelupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ func UpdatePanel(c *gin.Context) {
}
}

// If ticket limit is 0, treat it as use global setting
if data.TicketLimit == utils.Ptr(uint8(0)) {
data.TicketLimit = nil
}

// Store in DB
panel := database.Panel{
PanelId: panelId,
Expand Down Expand Up @@ -243,6 +248,7 @@ func UpdatePanel(c *gin.Context) {
UseThreads: data.UseThreads,
TicketNotificationChannel: data.TicketNotificationChannel,
CooldownSeconds: data.CooldownSeconds,
TicketLimit: data.TicketLimit,
}

// insert mention data
Expand Down
15 changes: 15 additions & 0 deletions app/http/endpoints/api/panel/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func panelValidators() []validation.Validator[PanelValidationContext] {
validatePendingCategory,
validateTicketNotificationChannel,
validateCooldownSeconds,
validateTicketLimit,
}
}

Expand Down Expand Up @@ -450,3 +451,17 @@ func validateTicketNotificationChannel(ctx PanelValidationContext) validation.Va
return nil
}
}

func validateTicketLimit(ctx PanelValidationContext) validation.ValidationFunc {
return func() error {
if ctx.Data.TicketLimit == nil {
return nil
}

if *ctx.Data.TicketLimit > 10 {
return validation.NewInvalidInputError("Ticket limit must be at most 11")
}

return nil
}
}
44 changes: 43 additions & 1 deletion frontend/src/components/form/Number.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<script>
import Tooltip from "svelte-tooltip";
import { labelHash } from "../../js/labelHash";

export let value;
export let label;
export let min;
export let max;

export let tooltipText = undefined;
export let tooltipLink = undefined;

export let col1 = false;
export let col2 = false;
export let col3 = false;
Expand Down Expand Up @@ -34,7 +38,28 @@
class:col-3={col3}
class:col-4={col4}
>
<label for={numberId} class="form-label">{label}</label>
<div class="label-wrapper" class:no-margin={tooltipText !== undefined}>
<label for={numberId} class="form-label" style="margin-bottom: 0"
>{label}</label
>
{#if tooltipText !== undefined}
<div>
<Tooltip tip={tooltipText} top color="#121212">
{#if tooltipLink !== undefined}
<a href={tooltipLink} target="_blank">
<i
class="fas fa-circle-info form-label tooltip-icon"
></i>
</a>
{:else}
<i
class="fas fa-circle-info form-label tooltip-icon"
></i>
{/if}
</Tooltip>
</div>
{/if}
</div>
<input
id={numberId}
class="form-input"
Expand All @@ -51,4 +76,21 @@
input {
width: 100%;
}

.label-wrapper {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
margin-bottom: 5px;
}

.no-margin {
margin-bottom: 0 !important;
}

.tooltip-icon {
cursor: pointer;
}

</style>
14 changes: 14 additions & 0 deletions frontend/src/components/manage/PanelCreationForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@
data.colour = 0x2ecc71;
}

if (!data.ticket_limit) {
data.ticket_limit = 0;
}

tempColour = intToColour(data.colour);
}

Expand Down Expand Up @@ -236,6 +240,7 @@
exit_survey_form_id: "null",
pending_category: "null",
use_threads: false,
ticket_limit: 0,
ticket_notification_channel: "null",
cooldown_seconds: 0,
welcome_message: {
Expand Down Expand Up @@ -375,6 +380,15 @@
bind:value={data.category_id}
/>

<Number
col2
label="Max Open Tickets Per User"
min={0}
bind:value={data.ticket_limit}
tooltipText="Maximum tickets user can have open at once. Set to 0 to use global setting."
/>
</div>
<div class="incomplete-row">
<Dropdown col2 label="Form" bind:value={data.form_id}>
<option value="null">None</option>
{#each forms as form}
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ toolchain go1.24.2

//replace github.com/TicketsBot-cloud/database => ../database

//replace github.com/TicketsBot-cloud/common => ../common

//replace github.com/TicketsBot-cloud/gdl => ../gdl

//replace github.com/TicketsBot-cloud/logarchiver => ../logarchiver
Expand All @@ -20,7 +22,7 @@ require (
github.com/BurntSushi/toml v1.2.1
github.com/TicketsBot-cloud/archiverclient v0.0.0-20251015181023-f0b66a074704
github.com/TicketsBot-cloud/common v0.0.0-20260210203202-54154661338e
github.com/TicketsBot-cloud/database v0.0.0-20260215113825-54c67fb267fc
github.com/TicketsBot-cloud/database v0.0.0-20260217113520-9cc86e3b374b
github.com/TicketsBot-cloud/gdl v0.0.0-20260213180045-11af01c262ca
github.com/TicketsBot-cloud/logarchiver v0.0.0-20251018211319-7a7df5cacbdc
github.com/TicketsBot-cloud/worker v0.0.0-20251212162840-a9cc9bbf5692
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ github.com/TicketsBot-cloud/archiverclient v0.0.0-20251015181023-f0b66a074704 h1
github.com/TicketsBot-cloud/archiverclient v0.0.0-20251015181023-f0b66a074704/go.mod h1:Mux1bEPpOHwRw1wo6Fa6qJLJH9Erk9qv1yAIfLi1Wmw=
github.com/TicketsBot-cloud/common v0.0.0-20260210203202-54154661338e h1:nFKV7yEm8MWbCP7dtsJ88+agcxDUD0YKIotVHMVvytw=
github.com/TicketsBot-cloud/common v0.0.0-20260210203202-54154661338e/go.mod h1:tGrTHFz09OM3eDWF+62hIi9ELpT4igCFi868FKSvKBg=
github.com/TicketsBot-cloud/database v0.0.0-20260215113825-54c67fb267fc h1:9fQmqYQN7Hc85ds+uklaNU1ab199NAhpT5A3fQ3P8g8=
github.com/TicketsBot-cloud/database v0.0.0-20260215113825-54c67fb267fc/go.mod h1:HQXAgmNSm7/FmBYwcsa6qpZqMrDhbLoEl+AyqFQ+RwY=
github.com/TicketsBot-cloud/database v0.0.0-20260217113520-9cc86e3b374b h1:nE8VAv13rUPOSMTnULKsuCDHXlWnbst7DmocviUN6I8=
github.com/TicketsBot-cloud/database v0.0.0-20260217113520-9cc86e3b374b/go.mod h1:HQXAgmNSm7/FmBYwcsa6qpZqMrDhbLoEl+AyqFQ+RwY=
github.com/TicketsBot-cloud/gdl v0.0.0-20260213180045-11af01c262ca h1:/HRqcgOPfv6d9NzE6CqHXN4U1QgElyJ9DcxNNT8kV6g=
github.com/TicketsBot-cloud/gdl v0.0.0-20260213180045-11af01c262ca/go.mod h1:CdwBR2egPtxUXjD2CgC9ZwfuB8dz9HPePM8nuG6dt7Y=
github.com/TicketsBot-cloud/logarchiver v0.0.0-20251018211319-7a7df5cacbdc h1:qTLNpCvIqM7UwZ6MdWQ9EztcDsIJfHh+VJdG+ULLEaA=
Expand Down