Skip to content

Commit

Permalink
Add radio select for release channel
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jun 19, 2024
1 parent 26d4fbd commit 1497e32
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/polar/accounts/space/credential.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule Polar.Accounts.Space.Credential do
field :name, :string

field :token, :binary
field :type, :string
field :type, :string, default: "lxd"

field :expires_in, :integer, virtual: true
field :expires_at, :utc_datetime
Expand Down
6 changes: 6 additions & 0 deletions lib/polar/streams/version/transitions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ defmodule Polar.Streams.Version.Transitions do
fn changes -> transit(changes) end
)

Version
|> transition(
[from: "testing", to: "inactive", via: "deactivate"],
fn changes -> transit(changes) end
)

Version
|> transition(
[from: "testing", to: "active", via: "activate"],
Expand Down
40 changes: 38 additions & 2 deletions lib/polar_web/live/dashboard/credential/new_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ defmodule PolarWeb.Dashboard.Credential.NewLive do
alias Polar.Accounts
alias Polar.Accounts.Space

alias Polar.Streams.ReleaseChannel

def render(assigns) do
~H"""
<div class="space-y-10 divide-y divide-gray-900/10">
Expand Down Expand Up @@ -64,6 +66,40 @@ defmodule PolarWeb.Dashboard.Credential.NewLive do
</div>
</fieldset>
</div>
<div class="col-span-full">
<div class="flex items-center justify-between">
<h2 class="text-sm font-medium leading-6 text-gray-900">
<%= gettext("Release channel") %>
</h2>
</div>
<fieldset class="mt-2">
<legend class="sr-only"><%= gettext("Choose release channel") %></legend>
<input
type="hidden"
name={@credential_form[:release_channel].name}
value={@credential_form.source.changes[:release_channel]}
/>
<div class="grid grid-cols-3 gap-3 sm:grid-cols-6">
<label
:for={channel <- ReleaseChannel.valid_names()}
for={Phoenix.HTML.Form.input_id(:credential, :release_channel, channel)}
class={[
"flex items-center justify-center rounded-md py-3 px-3 text-sm font-semibold sm:flex-1 cursor-pointer focus:outline-none",
"#{if (@credential_form.source.changes[:release_channel] || @credential_form.data.release_channel) == channel, do: "bg-indigo-600 text-white hover:bg-indigo-500", else: "ring-1 ring-inset ring-slate-300 bg-white text-slate-900 hover:bg-slate-50"}"
]}
>
<.input
type="radio"
id={Phoenix.HTML.Form.input_id(:credential, :release_channel, channel)}
field={@credential_form[:release_channel]}
value={channel}
class="sr-only"
/>
<span><%= Phoenix.Naming.humanize(channel) %></span>
</label>
</div>
</fieldset>
</div>
<div class="col-span-full">
<div class="flex items-center justify-between">
<h2 class="text-sm font-medium leading-6 text-gray-900">
Expand All @@ -83,7 +119,7 @@ defmodule PolarWeb.Dashboard.Credential.NewLive do
for={Phoenix.HTML.Form.input_id(:credential, :type, type)}
class={[
"flex items-center justify-center rounded-md py-3 px-3 text-sm font-semibold sm:flex-1 cursor-pointer focus:outline-none",
"#{if @credential_form.source.changes[:type] == type, do: "bg-indigo-600 text-white hover:bg-indigo-500", else: "ring-1 ring-inset ring-slate-300 bg-white text-slate-900 hover:bg-slate-50"}"
"#{if (@credential_form.source.changes[:type] || @credential_form.data.type) == type, do: "bg-indigo-600 text-white hover:bg-indigo-500", else: "ring-1 ring-inset ring-slate-300 bg-white text-slate-900 hover:bg-slate-50"}"
]}
>
<.input
Expand All @@ -93,7 +129,7 @@ defmodule PolarWeb.Dashboard.Credential.NewLive do
value={type}
class="sr-only"
/>
<span><%= type %></span>
<span><%= Phoenix.Naming.humanize(type) %></span>
</label>
</div>
</fieldset>
Expand Down
6 changes: 6 additions & 0 deletions lib/polar_web/live/dashboard/credential_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ defmodule PolarWeb.Dashboard.CredentialLive do
<%= @credential.type %>
</dd>
</div>
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm font-medium text-gray-900"><%= gettext("Release Channel") %></dt>
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0">
<%= @credential.release_channel %>
</dd>
</div>
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm font-medium text-gray-900"><%= gettext("Expires At") %></dt>
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0">
Expand Down

0 comments on commit 1497e32

Please sign in to comment.