Merge pull request #81 from OliveTin/feature-input-description

feature: #61 - Descriptions in arguments
This commit is contained in:
James Read 2022-10-21 15:47:12 +01:00 committed by GitHub
commit 65afdeca36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,8 @@ message ActionArgument {
string defaultValue = 4;
repeated ActionArgumentChoice choices = 5;
string description = 6;
}
message ActionArgumentChoice {

View File

@ -25,11 +25,13 @@ actions:
title: host
type: ascii_identifier
default: example.com
description: The host that you want to ping
- name: count
title: Count
type: int
default: 1
description: How many times to do you want to ping?
# Restart lightdm on host "server1"
# Docs: https://docs.olivetin.app/action-ping.html

View File

@ -17,6 +17,7 @@ type Action struct {
type ActionArgument struct {
Name string
Title string
Description string
Type string
Default string
Choices []ActionArgumentChoice

View File

@ -36,6 +36,7 @@ func actionCfgToPb(action config.Action, user *acl.AuthenticatedUser) *pb.Action
Name: cfgArg.Name,
Title: cfgArg.Title,
Type: cfgArg.Type,
Description: cfgArg.Description,
DefaultValue: cfgArg.Default,
Choices: buildChoices(cfgArg.Choices),
}

View File

@ -64,6 +64,7 @@ class ArgumentForm extends window.HTMLElement {
domFieldWrapper.appendChild(this.createDomLabel(arg))
domFieldWrapper.appendChild(this.createDomInput(arg))
domFieldWrapper.appendChild(this.createDomDescription(arg))
this.domArgs.appendChild(domFieldWrapper)
}
@ -130,6 +131,14 @@ class ArgumentForm extends window.HTMLElement {
return domEl
}
createDomDescription (arg) {
const domArgumentDescription = document.createElement('span')
domArgumentDescription.classList.add('argument-description')
domArgumentDescription.innerText = arg.description
return domArgumentDescription
}
createSelectOption (choice) {
const domEl = document.createElement('option')

View File

@ -282,6 +282,10 @@ input[name="start"]:hover {
background-color: #aceaac;
}
span.argument-description {
margin-left: 1em;
}
form div.buttons {
text-align: right;
}