Ticket permissions
This commit is contained in:
parent
19826368ff
commit
27e2fb6d25
@ -15,9 +15,10 @@ import (
|
|||||||
type (
|
type (
|
||||||
Settings struct {
|
Settings struct {
|
||||||
database.Settings
|
database.Settings
|
||||||
ClaimSettings database.ClaimSettings `json:"claim_settings"`
|
ClaimSettings database.ClaimSettings `json:"claim_settings"`
|
||||||
AutoCloseSettings AutoCloseData `json:"auto_close"`
|
AutoCloseSettings AutoCloseData `json:"auto_close"`
|
||||||
Colours ColourMap `json:"colours"`
|
TicketPermissions database.TicketPermissions `json:"ticket_permissions"`
|
||||||
|
Colours ColourMap `json:"colours"`
|
||||||
|
|
||||||
Prefix string `json:"prefix"`
|
Prefix string `json:"prefix"`
|
||||||
WelcomeMessage string `json:"welcome_message"`
|
WelcomeMessage string `json:"welcome_message"`
|
||||||
@ -72,6 +73,12 @@ func GetSettingsHandler(ctx *gin.Context) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ticket permissions
|
||||||
|
group.Go(func() (err error) {
|
||||||
|
settings.TicketPermissions, err = dbclient.Client.TicketPermissions.Get(guildId)
|
||||||
|
return
|
||||||
|
})
|
||||||
|
|
||||||
// colour map
|
// colour map
|
||||||
group.Go(func() (err error) {
|
group.Go(func() (err error) {
|
||||||
settings.Colours, err = getColourMap(guildId)
|
settings.Colours, err = getColourMap(guildId)
|
||||||
|
@ -59,6 +59,7 @@ func UpdateSettingsHandler(ctx *gin.Context) {
|
|||||||
return settings.updateClaimSettings(guildId)
|
return settings.updateClaimSettings(guildId)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addToWaitGroup(group, guildId, settings.updateTicketPermissions)
|
||||||
addToWaitGroup(group, guildId, settings.updateLanguage)
|
addToWaitGroup(group, guildId, settings.updateLanguage)
|
||||||
addToWaitGroup(group, guildId, settings.updateAutoClose)
|
addToWaitGroup(group, guildId, settings.updateAutoClose)
|
||||||
|
|
||||||
@ -339,6 +340,10 @@ func (s *Settings) updateLanguage(guildId uint64) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Settings) updateTicketPermissions(guildId uint64) error {
|
||||||
|
return dbclient.Client.TicketPermissions.Set(guildId, s.TicketPermissions) // No validation required
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Settings) updateColours(guildId uint64) error {
|
func (s *Settings) updateColours(guildId uint64) error {
|
||||||
// Convert ColourMap to primitives
|
// Convert ColourMap to primitives
|
||||||
converted := make(map[int16]int)
|
converted := make(map[int16]int)
|
||||||
|
@ -8,6 +8,14 @@
|
|||||||
|
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
|
|
||||||
|
{#if tooltip !== undefined}
|
||||||
|
<div style="">
|
||||||
|
<Tooltip tip={tooltip} top color="#121212">
|
||||||
|
<i class="fas fa-circle-info form-label tooltip-icon"></i>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -20,11 +28,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
|
import Tooltip from "svelte-tooltip";
|
||||||
|
|
||||||
export let retractIcon = "fas fa-minus";
|
export let retractIcon = "fas fa-minus";
|
||||||
export let expandIcon = "fas fa-plus";
|
export let expandIcon = "fas fa-plus";
|
||||||
|
|
||||||
export let defaultOpen = false;
|
export let defaultOpen = false;
|
||||||
|
export let tooltip;
|
||||||
|
|
||||||
let expanded = false;
|
let expanded = false;
|
||||||
let showOverflow = true;
|
let showOverflow = true;
|
||||||
|
19
frontend/src/components/form/Toggle.svelte
Normal file
19
frontend/src/components/form/Toggle.svelte
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<div>
|
||||||
|
{#if label !== undefined}
|
||||||
|
<label class="form-label" style="margin-bottom: 0 !important;">{label}</label>
|
||||||
|
{/if}
|
||||||
|
<Toggle hideLabel
|
||||||
|
toggledColor="{toggledColour}"
|
||||||
|
untoggledColor="{untoggledColour}"
|
||||||
|
bind:toggled={value}/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Toggle from "svelte-toggle";
|
||||||
|
|
||||||
|
export let value;
|
||||||
|
export let label;
|
||||||
|
|
||||||
|
export let toggledColour = "#66bb6a";
|
||||||
|
export let untoggledColour = "#ccc";
|
||||||
|
</script>
|
@ -93,7 +93,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<Checkbox label="SUPPORT REPS CAN VIEW CLAIMED TICKETS" bind:value={data.claim_settings.support_can_view}
|
<Checkbox label="SUPPORT REPS CAN VIEW CLAIMED TICKETS" bind:value={data.claim_settings.support_can_view}
|
||||||
on:change={validateView}/>
|
on:change={validateView}/>
|
||||||
<Checkbox label="SUPPORT REPS CAN TYPE IN CLAIMED TICKETS" bind:value={data.claim_settings.support_can_type}
|
<Checkbox label="SUPPORT REPS CAN TYPE IN CLAIMED TICKETS"
|
||||||
|
bind:value={data.claim_settings.support_can_type}
|
||||||
on:change={validateType}/>
|
on:change={validateType}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -104,12 +105,14 @@
|
|||||||
<div slot="content" class="col-1">
|
<div slot="content" class="col-1">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<Checkbox label="Enabled" bind:value={data.auto_close.enabled}/>
|
<Checkbox label="Enabled" bind:value={data.auto_close.enabled}/>
|
||||||
<Checkbox label="Close On User Leave" disabled={!data.auto_close.enabled} bind:value={data.auto_close.on_user_leave}/>
|
<Checkbox label="Close On User Leave" disabled={!data.auto_close.enabled}
|
||||||
|
bind:value={data.auto_close.on_user_leave}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" style="justify-content: space-between">
|
<div class="row" style="justify-content: space-between">
|
||||||
<div class="col-2" style="flex-direction: row">
|
<div class="col-2" style="flex-direction: row">
|
||||||
<Duration disabled={!isPremium || !data.auto_close.enabled} bind:days={sinceOpenDays} bind:hours={sinceOpenHours}
|
<Duration disabled={!isPremium || !data.auto_close.enabled} bind:days={sinceOpenDays}
|
||||||
|
bind:hours={sinceOpenHours}
|
||||||
bind:minutes={sinceOpenMinutes}>
|
bind:minutes={sinceOpenMinutes}>
|
||||||
<div slot="header" class="header">
|
<div slot="header" class="header">
|
||||||
<label class="form-label" style="margin-bottom: unset">Since Open With No Response</label>
|
<label class="form-label" style="margin-bottom: unset">Since Open With No Response</label>
|
||||||
@ -118,7 +121,8 @@
|
|||||||
</Duration>
|
</Duration>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-2" style="flex-direction: row">
|
<div class="col-2" style="flex-direction: row">
|
||||||
<Duration disabled={!isPremium || !data.auto_close.enabled} bind:days={sinceLastDays} bind:hours={sinceLastHours}
|
<Duration disabled={!isPremium || !data.auto_close.enabled} bind:days={sinceLastDays}
|
||||||
|
bind:hours={sinceLastHours}
|
||||||
bind:minutes={sinceLastMinutes}>
|
bind:minutes={sinceLastMinutes}>
|
||||||
<div slot="header" class="header">
|
<div slot="header" class="header">
|
||||||
<label class="form-label" style="margin-bottom: unset">Since Last Message</label>
|
<label class="form-label" style="margin-bottom: unset">Since Last Message</label>
|
||||||
@ -130,6 +134,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
|
|
||||||
|
<Collapsible tooltip="Define which permissions are given to users in ticket channels">
|
||||||
|
<span slot="header">Ticket Permissions</span>
|
||||||
|
<div slot="content" class="row">
|
||||||
|
<Toggle label="Attach Files" bind:value={data.ticket_permissions.attach_files}/>
|
||||||
|
<Toggle label="Embed Links" bind:value={data.ticket_permissions.embed_links}/>
|
||||||
|
<Toggle label="Add Reactions" bind:value={data.ticket_permissions.add_reactions}/>
|
||||||
|
</div>
|
||||||
|
</Collapsible>
|
||||||
|
|
||||||
<Collapsible>
|
<Collapsible>
|
||||||
<div slot="header" class="header">
|
<div slot="header" class="header">
|
||||||
<span>Colour Scheme</span>
|
<span>Colour Scheme</span>
|
||||||
@ -183,6 +196,7 @@
|
|||||||
import Colour from "../form/Colour.svelte";
|
import Colour from "../form/Colour.svelte";
|
||||||
import PremiumBadge from "../PremiumBadge.svelte";
|
import PremiumBadge from "../PremiumBadge.svelte";
|
||||||
import {toDays, toHours, toMinutes} from "../../js/timeutil";
|
import {toDays, toHours, toMinutes} from "../../js/timeutil";
|
||||||
|
import Toggle from "../form/Toggle.svelte";
|
||||||
|
|
||||||
export let guildId;
|
export let guildId;
|
||||||
|
|
||||||
|
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-20220726141552-4560095e37f7
|
github.com/TicketsBot/database v0.0.0-20220731213519-9fc9b34ab06f
|
||||||
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-20220726162721-eb8978799cd0
|
github.com/TicketsBot/worker v0.0.0-20220726162721-eb8978799cd0
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
|
2
go.sum
2
go.sum
@ -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-20220726141552-4560095e37f7 h1:fdGleu/242MMcdFyyVlhfBXbOWoKREjEXdRS62O42Ao=
|
github.com/TicketsBot/database v0.0.0-20220726141552-4560095e37f7 h1:fdGleu/242MMcdFyyVlhfBXbOWoKREjEXdRS62O42Ao=
|
||||||
github.com/TicketsBot/database v0.0.0-20220726141552-4560095e37f7/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
|
github.com/TicketsBot/database v0.0.0-20220726141552-4560095e37f7/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
|
||||||
|
github.com/TicketsBot/database v0.0.0-20220731213519-9fc9b34ab06f h1:5tpytvC/I1eOgLXhhWvg4RA+vu40oXXzLFwfLde37gY=
|
||||||
|
github.com/TicketsBot/database v0.0.0-20220731213519-9fc9b34ab06f/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
|
||||||
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