Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
mix docs

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.7.6
uses: JamesIves/github-pages-deploy-action@v4.8.0
with:
branch: gh-pages # The branch the action should deploy to.
folder: doc # The folder the action should deploy.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ RUN mix lightning.install_adaptor_icons
RUN mix lightning.install_schemas
RUN npm install --prefix assets

# compile assets
RUN mix assets.deploy

# Compile the release
RUN mix compile

# compile assets
RUN mix assets.deploy

# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/

Expand Down
2 changes: 2 additions & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import * as Sentry from '@sentry/react';
import { enableMapSet } from 'immer';
import { Socket } from 'phoenix';
import { LiveSocket } from 'phoenix_live_view';
import { hooks as colocatedHooks } from 'phoenix-colocated/lightning';

import topbar from '../vendor/topbar.cjs';

Expand Down Expand Up @@ -55,6 +56,7 @@ window.sentry = sentry;
const hooks = {
LogViewer,
...Hooks,
...colocatedHooks,
};

// @ts-ignore
Expand Down
8 changes: 5 additions & 3 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ config :hammer,
config :lightning, LightningWeb.Endpoint,
url: [host: "localhost"],
render_errors: [
view: LightningWeb.ErrorView,
accepts: ~w(html json),
formats: [html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON],
layout: false
],
pubsub_server: Lightning.PubSub,
Expand Down Expand Up @@ -101,6 +100,7 @@ config :esbuild,
--external:path
--external:/fonts/*
--external:/images/*
--alias:@=.
js/app.js
js/storybook.js
js/editor/Editor.tsx
Expand Down Expand Up @@ -131,7 +131,9 @@ config :esbuild,
end
end),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
env: %{
"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]
}
]

# https://fly.io/phoenix-files/tailwind-standalone/
Expand Down
5 changes: 5 additions & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

config :phoenix_live_view,
debug_heex_annotations: true,
debug_attributes: true,
enable_expensive_runtime_checks: true

config :lightning, :is_resettable_demo, true

config :lightning, :apollo, endpoint: "http://localhost:3000", timeout: 30_000
Expand Down
35 changes: 1 addition & 34 deletions lib/lightning_web/components/viewers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule LightningWeb.Components.Viewers do
import React

alias Lightning.Invocation.Dataclip
alias LightningWeb.Components.Icon
# alias LightningWeb.Components.Icon
alias Phoenix.LiveView.JS

require Lightning.Run
Expand Down Expand Up @@ -340,39 +340,6 @@ defmodule LightningWeb.Components.Viewers do
"""
end

attr :id, :string, required: true

attr :type, :atom,
default: nil,
values: [nil | Dataclip.source_types()]

defp dataclip_type(assigns) do
assigns =
assign(assigns,
icon: Icon.dataclip_icon_class(assigns.type),
color: Icon.dataclip_icon_color(assigns.type)
)

~H"""
<div
id={@id}
class={[
"absolute top-0 right-0 flex items-center gap-2 group z-10"
]}
>
<div class="hidden group-hover:block font-mono text-white text-xs">
type: {@type}
</div>
<div class={[
"rounded-bl-md rounded-tr-md p-1 pt-0 opacity-70 group-hover:opacity-100 content-center",
@color
]}>
<.icon :if={@icon} name={@icon} class="h-4 w-4 inline-block align-middle" />
</div>
</div>
"""
end

defp step_finished?(%{finished_at: %_{}}), do: true

defp step_finished?(_other), do: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ defmodule LightningWeb.API.ProvisioningController do
{:error, error} ->
conn
|> put_status(:forbidden)
|> put_view(LightningWeb.ErrorView)
|> put_view(json: LightningWeb.ErrorJSON)
|> render(:"403",
error:
case error do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
defmodule LightningWeb.ErrorView do
defmodule LightningWeb.ErrorHTML do
@moduledoc false

# This module needs to be changed to use Layouts
use LightningWeb, :view

use Phoenix.Component
use LightningWeb, :html

def render("404.html", assigns) do
~H"""
<.logo_bar conn={@conn} />
<.logo_bar />
<div class="min-h-[25em] flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full space-y-6 p-12 rounded-md shadow-md border bg-white">
<div>
Expand All @@ -26,7 +23,7 @@ defmodule LightningWeb.ErrorView do

def render("401.html", assigns) do
~H"""
<.logo_bar conn={@conn} />
<.logo_bar />
<div class="min-h-[25em] flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full space-y-6 p-12 rounded-md shadow-md border bg-white">
<div>
Expand All @@ -37,7 +34,7 @@ defmodule LightningWeb.ErrorView do
:if={assigns[:error]}
class="mt-4 p-4 text-xs font-mono text-gray-600 border rounded-md bg-gray-200 grid grid-cols-2 gap-2"
>
<%= for {k,v} <- @error do %>
<%= for {k, v} <- @error do %>
<div class="text-right font-bold">{k}</div>
<div>{v}</div>
<% end %>
Expand All @@ -48,40 +45,23 @@ defmodule LightningWeb.ErrorView do
"""
end

def render(template, _assigns) do
Phoenix.Controller.status_message_from_template(template)
end

defp logo_bar(assigns) do
~H"""
<nav class="bg-secondary-800">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0">
<img
class="h-8 w-8"
src={Routes.static_path(@conn, "/images/square-logo.png")}
alt="OpenFn"
/>
<img class="h-8 w-8" src={~p"/images/square-logo.png"} alt="OpenFn" />
</div>
</div>
</div>
</div>
</nav>
"""
end

# By default, Phoenix returns the status message from
# the template name. For example, "404.html" becomes
# "Not Found".
def template_not_found(template, assigns) do
if String.match?(template, ~r/.json$/) do
%{
"error" =>
case assigns do
%{error: error} -> error
_ -> Phoenix.Controller.status_message_from_template(template)
end
}
else
Phoenix.Controller.status_message_from_template(template)
end
end
end
11 changes: 11 additions & 0 deletions lib/lightning_web/controllers/error_json.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule LightningWeb.ErrorJSON do
@moduledoc false

def render(_template, %{error: error}) do
%{"error" => error}
end

def render(template, _assigns) do
%{"error" => Phoenix.Controller.status_message_from_template(template)}
end
end
10 changes: 5 additions & 5 deletions lib/lightning_web/controllers/fallback_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ defmodule LightningWeb.FallbackController do
def call(conn, {:error, :not_found}) do
conn
|> put_status(:not_found)
|> put_view(LightningWeb.ErrorView)
|> put_view(html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON)
|> render(:"404")
end

def call(conn, {:error, :bad_request}) do
conn
|> put_status(:bad_request)
|> put_view(LightningWeb.ErrorView)
|> put_view(html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON)
|> render(:"400")
end

def call(conn, {:error, :unauthorized}) do
conn
|> put_status(:unauthorized)
|> put_view(LightningWeb.ErrorView)
|> put_view(html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON)
|> render(:"401")
end

def call(conn, {:error, :forbidden}) do
conn
|> put_status(:forbidden)
|> put_view(LightningWeb.ErrorView)
|> put_view(html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON)
|> render(:"403")
end

Expand Down Expand Up @@ -61,7 +61,7 @@ defmodule LightningWeb.FallbackController do
def call(conn, {:error, error}) when is_map(error) do
conn
|> put_status(:unauthorized)
|> put_view(LightningWeb.ErrorView)
|> put_view(html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON)
|> render(:"401", error: error)
end
end
12 changes: 9 additions & 3 deletions lib/lightning_web/controllers/user_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ defmodule LightningWeb.UserAuth do
"json" ->
conn
|> put_status(:unauthorized)
|> put_view(LightningWeb.ErrorView)
|> put_view(
html: LightningWeb.ErrorHTML,
json: LightningWeb.ErrorJSON
)
|> render(:"401")
|> halt()

Expand Down Expand Up @@ -263,7 +266,7 @@ defmodule LightningWeb.UserAuth do
if is_nil(conn.assigns[:current_resource]) do
conn
|> put_status(:unauthorized)
|> put_view(LightningWeb.ErrorView)
|> put_view(html: LightningWeb.ErrorHTML, json: LightningWeb.ErrorJSON)
|> render(:"401")
|> halt()
else
Expand Down Expand Up @@ -313,7 +316,10 @@ defmodule LightningWeb.UserAuth do
"json" ->
conn
|> put_status(:forbidden)
|> put_view(LightningWeb.ErrorView)
|> put_view(
html: LightningWeb.ErrorHTML,
json: LightningWeb.ErrorJSON
)
|> render(:"403")
|> halt()

Expand Down
2 changes: 1 addition & 1 deletion lib/lightning_web/controllers/webhooks_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule LightningWeb.WebhooksController do
%Plug.Conn.Unfetched{} ->
conn
|> put_status(415)
|> put_view(LightningWeb.ErrorView)
|> put_view(json: LightningWeb.ErrorJSON)
|> render(:"415")
|> halt()

Expand Down
10 changes: 9 additions & 1 deletion lib/lightning_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,13 @@ defmodule LightningWeb.Endpoint do

LightningWeb.Utils.add_dynamic_plugs(@post_session_plugs)

plug LightningWeb.Router
@routing_config Application.compile_env(
:lightning,
Lightning.Extensions.Routing,
[]
)
@app_router Keyword.get(@routing_config, :router, LightningWeb.Router)
plug @app_router

# plug LightningWeb.Router
end
20 changes: 0 additions & 20 deletions lib/lightning_web/live/dashboard_live/components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,4 @@ defmodule LightningWeb.DashboardLive.Components do
<% end %>
"""
end

attr :current_sort_key, :string, required: true
attr :current_sort_direction, :string, required: true
attr :target, :any, required: true
attr :target_sort_key, :string, required: true
slot :inner_block, required: true

defp sortable_table_header(assigns) do
~H"""
<Common.sortable_table_header
phx-click="sort"
phx-value-by={@target_sort_key}
phx-target={@target}
active={@current_sort_key == @target_sort_key}
sort_direction={@current_sort_direction}
>
{render_slot(@inner_block)}
</Common.sortable_table_header>
"""
end
end
18 changes: 0 additions & 18 deletions lib/lightning_web/live/workflow_live/dashboard_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -279,24 +279,6 @@ defmodule LightningWeb.WorkflowLive.DashboardComponents do
"""
end

attr :current_sort_key, :string, required: true
attr :current_sort_direction, :string, required: true
attr :target_sort_key, :string, required: true
slot :inner_block, required: true

defp sortable_table_header(assigns) do
~H"""
<Common.sortable_table_header
phx-click="sort"
phx-value-by={@target_sort_key}
active={@current_sort_key == @target_sort_key}
sort_direction={@current_sort_direction}
>
{render_slot(@inner_block)}
</Common.sortable_table_header>
"""
end

attr :project, :map, required: true
attr :workflow, :map, required: true
attr :trigger_enabled, :boolean
Expand Down
Loading