Integration descriptions
This commit is contained in:
parent
c9c9b2eb02
commit
45c5c82905
@ -20,7 +20,8 @@ type integrationCreateBody struct {
|
|||||||
WebhookUrl string `json:"webhook_url" validate:"required,webhook,max=255"`
|
WebhookUrl string `json:"webhook_url" validate:"required,webhook,max=255"`
|
||||||
|
|
||||||
Secrets []struct {
|
Secrets []struct {
|
||||||
Name string `json:"name" validate:"required,min=1,max=32,excludesall=% "`
|
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"`
|
} `json:"secrets" validate:"dive,omitempty,min=0,max=5"`
|
||||||
|
|
||||||
Headers []struct {
|
Headers []struct {
|
||||||
@ -84,7 +85,8 @@ func CreateIntegrationHandler(ctx *gin.Context) {
|
|||||||
secrets := make([]database.CustomIntegrationSecret, len(data.Secrets))
|
secrets := make([]database.CustomIntegrationSecret, len(data.Secrets))
|
||||||
for i, secret := range data.Secrets {
|
for i, secret := range data.Secrets {
|
||||||
secrets[i] = database.CustomIntegrationSecret{
|
secrets[i] = database.CustomIntegrationSecret{
|
||||||
Name: secret.Name,
|
Name: secret.Name,
|
||||||
|
Description: secret.Description,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ func GetIntegrationHandler(ctx *gin.Context) {
|
|||||||
ctx.JSON(200, integrationResponse{
|
ctx.JSON(200, integrationResponse{
|
||||||
Id: integration.Id,
|
Id: integration.Id,
|
||||||
OwnerId: integration.OwnerId,
|
OwnerId: integration.OwnerId,
|
||||||
WebhookHost: utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", "")),
|
WebhookHost: utils.SecondLevelDomain(utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", ""))),
|
||||||
Name: integration.Name,
|
Name: integration.Name,
|
||||||
Description: integration.Description,
|
Description: integration.Description,
|
||||||
ImageUrl: integration.ImageUrl,
|
ImageUrl: integration.ImageUrl,
|
||||||
|
@ -56,7 +56,7 @@ func ListIntegrationsHandler(ctx *gin.Context) {
|
|||||||
integrationResponse: integrationResponse{
|
integrationResponse: integrationResponse{
|
||||||
Id: integration.Id,
|
Id: integration.Id,
|
||||||
OwnerId: integration.OwnerId,
|
OwnerId: integration.OwnerId,
|
||||||
WebhookHost: utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", "")),
|
WebhookHost: utils.SecondLevelDomain(utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", ""))),
|
||||||
Name: integration.Name,
|
Name: integration.Name,
|
||||||
Description: integration.Description,
|
Description: integration.Description,
|
||||||
ImageUrl: integration.ImageUrl,
|
ImageUrl: integration.ImageUrl,
|
||||||
|
@ -57,7 +57,7 @@ func GetOwnedIntegrationsHandler(ctx *gin.Context) {
|
|||||||
integrationResponse: integrationResponse{
|
integrationResponse: integrationResponse{
|
||||||
Id: integration.Id,
|
Id: integration.Id,
|
||||||
OwnerId: integration.OwnerId,
|
OwnerId: integration.OwnerId,
|
||||||
WebhookHost: utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", "")),
|
WebhookHost: utils.SecondLevelDomain(utils.GetUrlHost(strings.ReplaceAll(integration.WebhookUrl, "%", ""))),
|
||||||
Name: integration.Name,
|
Name: integration.Name,
|
||||||
Description: integration.Description,
|
Description: integration.Description,
|
||||||
ImageUrl: integration.ImageUrl,
|
ImageUrl: integration.ImageUrl,
|
||||||
|
@ -21,8 +21,9 @@ type integrationUpdateBody struct {
|
|||||||
WebhookUrl string `json:"webhook_url" validate:"required,webhook,max=255"`
|
WebhookUrl string `json:"webhook_url" validate:"required,webhook,max=255"`
|
||||||
|
|
||||||
Secrets []struct {
|
Secrets []struct {
|
||||||
Id int `json:"id" validate:"omitempty,min=1"`
|
Id int `json:"id" validate:"omitempty,min=1"`
|
||||||
Name string `json:"name" validate:"required,min=1,max=32,excludesall=% "`
|
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"`
|
} `json:"secrets" validate:"dive,omitempty,min=0,max=5"`
|
||||||
|
|
||||||
Headers []struct {
|
Headers []struct {
|
||||||
@ -254,8 +255,9 @@ func (b *integrationUpdateBody) updateSecrets(ctx *gin.Context, integrationId in
|
|||||||
secrets := make([]database.CustomIntegrationSecret, len(b.Secrets))
|
secrets := make([]database.CustomIntegrationSecret, len(b.Secrets))
|
||||||
for i, secret := range b.Secrets {
|
for i, secret := range b.Secrets {
|
||||||
secrets[i] = database.CustomIntegrationSecret{
|
secrets[i] = database.CustomIntegrationSecret{
|
||||||
Id: secret.Id,
|
Id: secret.Id,
|
||||||
Name: secret.Name,
|
Name: secret.Name,
|
||||||
|
Description: secret.Description,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,17 +105,26 @@
|
|||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{#each data.secrets as secret, i}
|
{#each data.secrets as secret, i}
|
||||||
<div class="row">
|
<div class="col">
|
||||||
{#if i === 0}
|
<div class="row">
|
||||||
<Input col1 label="Secret Name" placeholder="api_key" bind:value={secret.name}/>
|
{#if i === 0}
|
||||||
<div class="button-anchor">
|
<Input col1 label="Secret Name" placeholder="api_key" bind:value={secret.name}/>
|
||||||
<Button danger iconOnly icon="fas fa-trash-can" on:click={() => deleteSecret(i)}/>
|
{:else}
|
||||||
</div>
|
<Input col1 placeholder="api_key" bind:value={secret.name}/>
|
||||||
{:else}
|
{/if}
|
||||||
<Input col1 placeholder="api_key" bind:value={secret.name}/>
|
|
||||||
<div class="button-anchor">
|
<div class="button-anchor">
|
||||||
<Button danger iconOnly icon="fas fa-trash-can" on:click={() => deleteSecret(i)}/>
|
<Button danger iconOnly icon="fas fa-trash-can" on:click={() => deleteSecret(i)}/>
|
||||||
</div>
|
</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}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
@ -488,6 +497,14 @@
|
|||||||
row-gap: 1vh;
|
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) {
|
@media only screen and (max-width: 950px) {
|
||||||
.outer-row {
|
.outer-row {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
<div class="secret-container">
|
<div class="secret-container">
|
||||||
{#each integration.secrets as secret}
|
{#each integration.secrets as secret}
|
||||||
<div class="secret-input">
|
<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>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
<div class="secret-container">
|
<div class="secret-container">
|
||||||
{#each integration.secrets as secret}
|
{#each integration.secrets as secret}
|
||||||
<div class="secret-input">
|
<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>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
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-20220712212403-61804b8beb18
|
github.com/TicketsBot/database v0.0.0-20220721214509-131e86b1a06c
|
||||||
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-20220710121124-cd5ec72739f9
|
github.com/TicketsBot/worker v0.0.0-20220710121124-cd5ec72739f9
|
||||||
github.com/apex/log v1.1.2
|
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/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 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-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 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=
|
||||||
|
@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetUrlHost(rawUrl string) string {
|
func GetUrlHost(rawUrl string) string {
|
||||||
@ -12,3 +13,12 @@ func GetUrlHost(rawUrl string) string {
|
|||||||
|
|
||||||
return parsed.Hostname()
|
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