Files

61 lines
3.4 KiB
HTML

{{ define "pull-command-switcher" }}
{{/*
Pull command with inline OCI client switcher.
Expects dict with: RegistryURL, OwnerHandle, RepoName, Tag, ArtifactType, OciClient, IsLoggedIn
For helm charts, shows helm command only (no switcher).
For container images, shows a client dropdown that updates the command.
Logged-in users: saves to profile via HTMX POST.
Anonymous users: saves to localStorage.
*/}}
{{ if eq .ArtifactType "helm-chart" }}
{{/* Helm chart: small install/pull toggle. JS in app.js wires the
switcher and persists the choice in localStorage. Default = install. */}}
{{ $versionFlag := "" }}
{{ if .Tag }}{{ $versionFlag = print " --version " .Tag }}{{ end }}
{{ $ociRef := print "oci://" .RegistryURL "/" .OwnerHandle "/" .RepoName }}
<div class="space-y-2" id="helm-cmd-container"
data-registry-url="{{ .RegistryURL }}"
data-owner-handle="{{ .OwnerHandle }}"
data-repo-name="{{ .RepoName }}"
data-tag="{{ if .Tag }}{{ .Tag }}{{ end }}">
<label for="helm-cmd-switcher" class="text-sm font-medium text-base-content/70">Use this chart</label>
<div class="flex items-center gap-2">
<select id="helm-cmd-switcher" class="select select-xs select-bordered w-auto">
<option value="install" selected>helm install</option>
<option value="pull">helm pull</option>
</select>
<div id="helm-cmd-display" class="flex-1 min-w-0" aria-live="polite">
{{ template "docker-command" (print "helm install " .RepoName " " $ociRef $versionFlag) }}
</div>
</div>
</div>
{{ else }}
<div class="space-y-2" id="pull-cmd-container"
data-registry-url="{{ .RegistryURL }}"
data-owner-handle="{{ .OwnerHandle }}"
data-repo-name="{{ .RepoName }}"
data-tag="{{ if .Tag }}{{ .Tag }}{{ else }}latest{{ end }}"
data-is-logged-in="{{ .IsLoggedIn }}">
<label for="oci-client-switcher" class="text-sm font-medium text-base-content/70">Pull this image</label>
<div class="flex items-center gap-2">
<select id="oci-client-switcher" class="select select-xs select-bordered w-auto">
<option value="docker"{{ if or (eq .OciClient "") (eq .OciClient "docker") }} selected{{ end }}>docker</option>
<option value="podman"{{ if eq .OciClient "podman" }} selected{{ end }}>podman</option>
<option value="nerdctl"{{ if eq .OciClient "nerdctl" }} selected{{ end }}>nerdctl</option>
<option value="buildah"{{ if eq .OciClient "buildah" }} selected{{ end }}>buildah</option>
<option value="crane"{{ if eq .OciClient "crane" }} selected{{ end }}>crane</option>
<option value="none"{{ if eq .OciClient "none" }} selected{{ end }}>image ref only</option>
</select>
<div id="pull-cmd-display" class="flex-1 min-w-0" aria-live="polite">
{{ if .Tag }}
{{ template "docker-command" (print (pullPrefix .OciClient) .RegistryURL "/" .OwnerHandle "/" .RepoName ":" .Tag) }}
{{ else }}
{{ template "docker-command" (print (pullPrefix .OciClient) .RegistryURL "/" .OwnerHandle "/" .RepoName ":latest") }}
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}