Skip to content

Commit

Permalink
Merge pull request #1018 from OpenFn/975-fix-dataclip-notice
Browse files Browse the repository at this point in the history
Fix dropped dataclip type pill and state assembler notice
  • Loading branch information
stuartc authored Aug 14, 2023
2 parents dc5a7df + ca48906 commit 45d0c4c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to

- Tooltip for credential select in Job Edit form is cut off
[#972](https://github.com/OpenFn/Lightning/issues/972)
- Dataclip type and state assembly notice for creating new dataclip dropped
during refactor [#975](https://github.com/OpenFn/Lightning/issues/975)

## [v0.7.2] - 2023-08-10

Expand Down
8 changes: 6 additions & 2 deletions lib/lightning_web/live/components/common.ex
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,18 @@ defmodule LightningWeb.Components.Common do
)
end

attr :type, :atom,
required: true,
values: [:run_result, :http_request, :global, :saved_input]

def dataclip_type_pill(assigns) do
base_classes = ~w[
px-2 py-1 rounded-full inline-block text-sm font-mono
]

class =
base_classes ++
case assigns[:dataclip].type do
case assigns[:type] do
:run_result -> ~w[bg-purple-500 text-purple-900]
:http_request -> ~w[bg-green-500 text-green-900]
:global -> ~w[bg-blue-500 text-blue-900]
Expand All @@ -305,7 +309,7 @@ defmodule LightningWeb.Components.Common do

~H"""
<div class={@class}>
<%= @dataclip.type %>
<%= @type %>
</div>
"""
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lightning_web/live/dataclip_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<.td>
<%= dataclip.inserted_at |> Calendar.strftime("%c %Z") %>
</.td>
<.td><Common.dataclip_type_pill dataclip={dataclip} /></.td>
<.td><Common.dataclip_type_pill type={dataclip.type} /></.td>
<.td>
<code>
<%= dataclip.body
Expand Down
19 changes: 11 additions & 8 deletions lib/lightning_web/live/job_live/manual_run_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,24 @@ defmodule LightningWeb.JobLive.ManualRunComponent do
phx-submit="run"
>
<.dataclip_selector form={f} phx-target={@myself} dataclips={@dataclips} />
<div :if={is_nil(@selected_dataclip)} class="flex-1 flex flex-col">
<Form.text_area form={f} field={:body} phx-debounce="300" />
</div>
<div :if={@selected_dataclip} class="flex-1 flex flex-col gap-4">
<div class="flex-1 flex flex-col gap-4">
<div>
<div class="flex flex-row">
<div class="basis-1/2 font-semibold text-secondary-700">
Dataclip Type
</div>
<div class="basis-1/2 text-right">
<Common.dataclip_type_pill dataclip={@selected_dataclip} />
<Common.dataclip_type_pill type={
(@selected_dataclip && @selected_dataclip.type) || :saved_input
} />
</div>
</div>
<div class="flex flex-row mt-4">
<div class="basis-1/2 font-semibold text-secondary-700">
State Assembly
</div>
<div class="text-right text-sm">
<%= if(@selected_dataclip.type == :http_request) do %>
<%= if(not is_nil(@selected_dataclip) and @selected_dataclip.type == :http_request) do %>
The JSON shown here is the <em>body</em>
of an HTTP request. The state assembler will place this payload into
<code>state.data</code>
Expand All @@ -91,11 +90,14 @@ defmodule LightningWeb.JobLive.ManualRunComponent do
</div>
</div>
</div>
<div class="h-32 overflow-y-auto">
<div :if={@selected_dataclip} class="h-32 overflow-y-auto">
<LightningWeb.RunLive.Components.log_view log={
format_dataclip_body(@selected_dataclip)
} />
</div>
<div :if={is_nil(@selected_dataclip)}>
<Form.text_area form={f} field={:body} phx-debounce="300" />
</div>
</div>
<div class="flex-none flex place-content-end">
<Form.submit_button
Expand Down Expand Up @@ -289,6 +291,7 @@ defmodule LightningWeb.JobLive.ManualRunComponent do
dataclip
end

socket |> assign(selected_dataclip: selected_dataclip)
socket
|> assign(selected_dataclip: selected_dataclip)
end
end

0 comments on commit 45d0c4c

Please sign in to comment.