Direct help button on provider pages to dnscontrol
This commit is contained in:
parent
299de072d0
commit
6dc213191e
|
@ -35,6 +35,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/providers"
|
||||
"github.com/miekg/dns"
|
||||
|
@ -52,6 +53,9 @@ type ProviderInfos struct {
|
|||
|
||||
// Capabilites is a list of special ability of the provider (automatically filled).
|
||||
Capabilities []string `json:"capabilities,omitempty"`
|
||||
|
||||
// HelpLink is the link to the documentation of the provider configuration.
|
||||
HelpLink string `json:"helplink,omitempty"`
|
||||
}
|
||||
|
||||
// ProviderCreator abstract the instanciation of a Provider
|
||||
|
@ -68,11 +72,13 @@ var providersList map[string]Provider = map[string]Provider{}
|
|||
|
||||
// RegisterProvider declares the existence of the given Provider.
|
||||
func RegisterProvider(creator ProviderCreator, infos ProviderInfos) {
|
||||
baseType := reflect.Indirect(reflect.ValueOf(creator())).Type()
|
||||
prvInstance := creator()
|
||||
baseType := reflect.Indirect(reflect.ValueOf(prvInstance)).Type()
|
||||
name := baseType.Name()
|
||||
log.Println("Registering new provider:", name)
|
||||
|
||||
infos.Capabilities = GetProviderCapabilities(creator())
|
||||
infos.Capabilities = GetProviderCapabilities(prvInstance)
|
||||
infos.HelpLink = "https://stackexchange.github.io/dnscontrol/providers/" + strings.ToLower(prvInstance.DNSControlName())
|
||||
|
||||
providersList[name] = Provider{
|
||||
creator,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import { logout as APILogout } from '$lib/api/user';
|
||||
import HelpButton from '$lib/components/Help.svelte';
|
||||
import Logo from '$lib/components/Logo.svelte';
|
||||
import { providersSpecs } from '$lib/stores/providers';
|
||||
import { userSession, refreshUserSession } from '$lib/stores/usersession';
|
||||
import { toasts } from '$lib/stores/toasts';
|
||||
import { t, locales, locale } from '$lib/translations';
|
||||
|
@ -27,7 +28,19 @@
|
|||
export let routeId: string | null;
|
||||
export let sw_state: boolean;
|
||||
let helpLink = "";
|
||||
$: helpLink = 'https://help.happydomain.org/' + encodeURIComponent($locale) + getHelpPathFromRoute(routeId);
|
||||
$: if (routeId.startsWith("/providers/new/[ptype]")) {
|
||||
helpLink = getHelpPathFromProvider($page.url.pathname.split("/")[3]);
|
||||
} else {
|
||||
helpLink = 'https://help.happydomain.org/' + encodeURIComponent($locale) + getHelpPathFromRoute(routeId);
|
||||
}
|
||||
|
||||
function getHelpPathFromProvider(ptype: string): string {
|
||||
if ($providersSpecs && $providersSpecs[ptype]) {
|
||||
return $providersSpecs[ptype].helplink;
|
||||
} else {
|
||||
return 'https://help.happydomain.org/';
|
||||
}
|
||||
}
|
||||
|
||||
function getHelpPathFromRoute(routeId: string | null) {
|
||||
if (routeId === null) return "/";
|
||||
|
|
Loading…
Reference in New Issue