Integration descriptions
This commit is contained in:
parent
c9c9b2eb02
commit
45c5c82905
@ -21,6 +21,7 @@ type integrationCreateBody struct {
|
||||
|
||||
Secrets []struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=32,excludesall=% "`
|
||||
Description *string `json:"description" validate:"omitempty,max=255"`
|
||||
} `json:"secrets" validate:"dive,omitempty,min=0,max=5"`
|
||||
|
||||
Headers []struct {
|
||||
@ -85,6 +86,7 @@ func CreateIntegrationHandler(ctx *gin.Context) {
|
||||
for i, secret := range data.Secrets {
|
||||
secrets[i] = database.CustomIntegrationSecret{
|
||||
Name: secret.Name,
|
||||
Description: secret.Description,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ func GetIntegrationHandler(ctx *gin.Context) {
|
||||
ctx.JSON(200, integrationResponse{
|
||||
Id: integration.Id,
|
||||
OwnerId: integration.OwnerId,
|
||||
WebhookHost: utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", "")),
|
||||
WebhookHost: utils.SecondLevelDomain(utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", ""))),
|
||||
Name: integration.Name,
|
||||
Description: integration.Description,
|
||||
ImageUrl: integration.ImageUrl,
|
||||
|
@ -56,7 +56,7 @@ func ListIntegrationsHandler(ctx *gin.Context) {
|
||||
integrationResponse: integrationResponse{
|
||||
Id: integration.Id,
|
||||
OwnerId: integration.OwnerId,
|
||||
WebhookHost: utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", "")),
|
||||
WebhookHost: utils.SecondLevelDomain(utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", ""))),
|
||||
Name: integration.Name,
|
||||
Description: integration.Description,
|
||||
ImageUrl: integration.ImageUrl,
|
||||
|
@ -57,7 +57,7 @@ func GetOwnedIntegrationsHandler(ctx *gin.Context) {
|
||||
integrationResponse: integrationResponse{
|
||||
Id: integration.Id,
|
||||
OwnerId: integration.OwnerId,
|
||||
WebhookHost: utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", "")),
|
||||
WebhookHost: utils.SecondLevelDomain(utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", ""))),
|
||||
Name: integration.Name,
|
||||
Description: integration.Description,
|
||||
ImageUrl: integration.ImageUrl,
|
||||
|
@ -23,6 +23,7 @@ type integrationUpdateBody struct {
|
||||
Secrets []struct {
|
||||
Id int `json:"id" validate:"omitempty,min=1"`
|
||||
Name string `json:"name" validate:"required,min=1,max=32,excludesall=% "`
|
||||
Description *string `json:"description" validate:"omitempty,max=255"`
|
||||
} `json:"secrets" validate:"dive,omitempty,min=0,max=5"`
|
||||
|
||||
Headers []struct {
|
||||
@ -256,6 +257,7 @@ func (b *integrationUpdateBody) updateSecrets(ctx *gin.Context, integrationId in
|
||||
secrets[i] = database.CustomIntegrationSecret{
|
||||
Id: secret.Id,
|
||||
Name: secret.Name,
|
||||
Description: secret.Description,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,17 +105,26 @@
|
||||
|
||||
<div class="col">
|
||||
{#each data.secrets as secret, i}
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
{#if i === 0}
|
||||
<Input col1 label="Secret Name" placeholder="api_key" bind:value={secret.name}/>
|
||||
<div class="button-anchor">
|
||||
<Button danger iconOnly icon="fas fa-trash-can" on:click={() => deleteSecret(i)}/>
|
||||
</div>
|
||||
{:else}
|
||||
<Input col1 placeholder="api_key" bind:value={secret.name}/>
|
||||
{/if}
|
||||
|
||||
<div class="button-anchor">
|
||||
<Button danger iconOnly icon="fas fa-trash-can" on:click={() => deleteSecret(i)}/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<Textarea col1 minHeight="60px" label="Description" bind:value={secret.description}
|
||||
placeholder="Tell users what value to enter for this secret, in up to 255 characters"/>
|
||||
</div>
|
||||
|
||||
{#if i !== data.secrets.length - 1}
|
||||
<hr/>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
@ -488,6 +497,14 @@
|
||||
row-gap: 1vh;
|
||||
}
|
||||
|
||||
hr {
|
||||
border-top: 1px solid #777;
|
||||
border-bottom: 0;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 950px) {
|
||||
.outer-row {
|
||||
flex-direction: column;
|
||||
|
@ -16,7 +16,8 @@
|
||||
<div class="secret-container">
|
||||
{#each integration.secrets as secret}
|
||||
<div class="secret-input">
|
||||
<Input col1 label="{secret.name}" placeholder="{secret.name}" bind:value={secretValues[secret.name]}/>
|
||||
<Input label="{secret.name}" placeholder="{secret.name}" bind:value={secretValues[secret.name]}/>
|
||||
<p>{secret.description}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
@ -19,7 +19,8 @@
|
||||
<div class="secret-container">
|
||||
{#each integration.secrets as secret}
|
||||
<div class="secret-input">
|
||||
<Input col1 label="{secret.name}" placeholder="{secret.name}" bind:value={secretValues[secret.name]}/>
|
||||
<Input label="{secret.name}" placeholder="{secret.name}" bind:value={secretValues[secret.name]}/>
|
||||
<p>{secret.description}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
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-20220712212403-61804b8beb18
|
||||
github.com/TicketsBot/database v0.0.0-20220721214509-131e86b1a06c
|
||||
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
|
||||
github.com/TicketsBot/worker v0.0.0-20220710121124-cd5ec72739f9
|
||||
github.com/apex/log v1.1.2
|
||||
|
2
go.sum
2
go.sum
@ -7,6 +7,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/database v0.0.0-20220712212403-61804b8beb18 h1:p3rr325yK5CqWQMBML1SzkC+mXx+SSaBq4PnyxeBYXA=
|
||||
github.com/TicketsBot/database v0.0.0-20220712212403-61804b8beb18/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
|
||||
github.com/TicketsBot/database v0.0.0-20220721214509-131e86b1a06c h1:eyAFQuKihRkfkSNg1xeIm9nHQZ1z2Qg46kS7LcLZNxk=
|
||||
github.com/TicketsBot/database v0.0.0-20220721214509-131e86b1a06c/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/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
|
||||
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
|
||||
|
@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetUrlHost(rawUrl string) string {
|
||||
@ -12,3 +13,12 @@ func GetUrlHost(rawUrl string) string {
|
||||
|
||||
return parsed.Hostname()
|
||||
}
|
||||
|
||||
func SecondLevelDomain(domain string) string {
|
||||
split := strings.Split(strings.TrimRight(domain, "."), ".")
|
||||
if len(split) > 2 {
|
||||
return strings.Join(split[len(split)-2:len(split)], ".")
|
||||
} else {
|
||||
return strings.Join(split, ".")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user