Skip to content

Commit

Permalink
Reduce coupling of a dataclip an the type component
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartc committed Aug 14, 2023
1 parent 89b0123 commit ca48906
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 2 additions & 3 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 All @@ -30,9 +32,6 @@ and this project adheres to

### Fixed

- Dataclip type and state assembly notice for creating new dataclip dropped
during refactor [#975](https://github.com/OpenFn/Lightning/issues/975)

## [v0.7.1] - 2023-08-04

### Added
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
4 changes: 2 additions & 2 deletions lib/lightning_web/live/job_live/manual_run_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ defmodule LightningWeb.JobLive.ManualRunComponent do
Dataclip Type
</div>
<div class="basis-1/2 text-right">
<Common.dataclip_type_pill dataclip={
@selected_dataclip || %{id: "", body: [], type: :saved_input}
<Common.dataclip_type_pill type={
(@selected_dataclip && @selected_dataclip.type) || :saved_input
} />
</div>
</div>
Expand Down

0 comments on commit ca48906

Please sign in to comment.