From c30f571d739585406edcd86feac4dcbc17bbd4eb Mon Sep 17 00:00:00 2001 From: Jamil Date: Tue, 23 May 2023 09:10:28 -0700 Subject: [PATCH] Fix minor bugs and tidy up existing work on new views (#1628) Just fixing some bugs and inconsistencies I found while going through the new views. --- .codespellrc | 2 +- .../test/domain/config/validator_test.exs | 2 +- .../web/lib/web/components/core_components.ex | 19 +- apps/web/lib/web/live/devices_live/show.ex | 16 +- apps/web/lib/web/live/gateways_live/edit.ex | 46 ++++ apps/web/lib/web/live/gateways_live/index.ex | 2 +- apps/web/lib/web/live/gateways_live/new.ex | 23 +- apps/web/lib/web/live/gateways_live/show.ex | 213 +++++++++++++++++- apps/web/lib/web/live/groups_live/edit.ex | 18 +- apps/web/lib/web/live/groups_live/show.ex | 29 +-- apps/web/lib/web/live/resources_live/index.ex | 17 +- apps/web/lib/web/live/resources_live/new.ex | 13 +- apps/web/lib/web/live/users_live/edit.ex | 18 +- apps/web/lib/web/live/users_live/new.ex | 15 +- apps/web/lib/web/live/users_live/show.ex | 36 +-- apps/web/lib/web/router.ex | 1 + .../web/controllers/page_controller_test.exs | 8 +- config/test.exs | 4 +- 18 files changed, 396 insertions(+), 86 deletions(-) create mode 100644 apps/web/lib/web/live/gateways_live/edit.ex diff --git a/.codespellrc b/.codespellrc index 7a2c37253..52e89eb8c 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,3 +1,3 @@ [codespell] -skip = ./www/docs/reference/api/*.mdx,./erl_crash.dump,./apps/*/erl_crash.dump,./cover,./vendor,*.json,yarn.lock,seeds.exs,./**/node_modules,./deps,./priv/static,./priv/plts,./**/priv/static,./.git,./www/build,./_build +skip = ./rust/target,Cargo.lock,./www/docs/reference/api/*.mdx,./erl_crash.dump,./apps/*/erl_crash.dump,./cover,./vendor,*.json,yarn.lock,seeds.exs,./**/node_modules,./deps,./priv/static,./priv/plts,./**/priv/static,./.git,./www/build,./_build ignore-words-list = crate,keypair,keypairs,iif,statics,wee,anull diff --git a/apps/domain/test/domain/config/validator_test.exs b/apps/domain/test/domain/config/validator_test.exs index c241234d4..38f23c2da 100644 --- a/apps/domain/test/domain/config/validator_test.exs +++ b/apps/domain/test/domain/config/validator_test.exs @@ -69,7 +69,7 @@ defmodule Domain.Config.ValidatorTest do # [ # %Domain.Config.Configuration.SAMLIdentityProvider{ # auto_create_users: attrs["auto_create_users"], - # base_url: "http://localhost:13000/auth/saml", + # base_url: "http://localhost:14000/auth/saml", # id: attrs["id"], # label: attrs["label"], # metadata: attrs["metadata"] diff --git a/apps/web/lib/web/components/core_components.ex b/apps/web/lib/web/components/core_components.ex index 7094e1619..b6642ff08 100644 --- a/apps/web/lib/web/components/core_components.ex +++ b/apps/web/lib/web/components/core_components.ex @@ -15,6 +15,21 @@ defmodule Web.CoreComponents do alias Phoenix.LiveView.JS import Web.Gettext + @doc """ + Renders a generic

tag using our color scheme. + + ## Examples + + <.p> + Hello world + + """ + def p(assigns) do + ~H""" +

<%= render_slot(@inner_block) %>

+ """ + end + @doc """ Render a monospace code block suitable for copying and pasting content. @@ -26,7 +41,7 @@ defmodule Web.CoreComponents do """ def code_block(assigns) do ~H""" -
+    
       <%= render_slot(@inner_block) %>
     
""" @@ -384,7 +399,7 @@ defmodule Web.CoreComponents do <%= entry.label %> <% else %> -
+
<.icon name="hero-chevron-right-solid" class="w-6 h-6" /> <.link navigate={entry.path} diff --git a/apps/web/lib/web/live/devices_live/show.ex b/apps/web/lib/web/live/devices_live/show.ex index 0e6054fa4..f66332159 100644 --- a/apps/web/lib/web/live/devices_live/show.ex +++ b/apps/web/lib/web/live/devices_live/show.ex @@ -14,11 +14,6 @@ defmodule Web.DevicesLive.Show do <:title> Device details - <:actions> - <.delete_button> - Archive - -
@@ -142,6 +137,17 @@ defmodule Web.DevicesLive.Show do
+ + <.section_header> + <:title> + Danger zone + + <:actions> + <.delete_button> + Archive + + + """ end end diff --git a/apps/web/lib/web/live/gateways_live/edit.ex b/apps/web/lib/web/live/gateways_live/edit.ex new file mode 100644 index 000000000..808852b41 --- /dev/null +++ b/apps/web/lib/web/live/gateways_live/edit.ex @@ -0,0 +1,46 @@ +defmodule Web.GatewaysLive.Edit do + use Web, :live_view + + def render(assigns) do + ~H""" + <.section_header> + <:breadcrumbs> + <.breadcrumbs entries={[ + %{label: "Home", path: ~p"/"}, + %{label: "Gateways", path: ~p"/gateways"}, + %{label: "gcp-primary", path: ~p"/gateways/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"}, + %{label: "Edit", path: ~p"/gateways/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"} + ]} /> + + <:title> + Editing Gateway gcp-primary + + + +
+
+

Gateway details

+
+
+
+ <.label for="gateway-name"> + Name + + +
+
+ <.submit_button> + Save + +
+
+
+ """ + end +end diff --git a/apps/web/lib/web/live/gateways_live/index.ex b/apps/web/lib/web/live/gateways_live/index.ex index c2ab24655..82b8a9973 100644 --- a/apps/web/lib/web/live/gateways_live/index.ex +++ b/apps/web/lib/web/live/gateways_live/index.ex @@ -15,7 +15,7 @@ defmodule Web.GatewaysLive.Index do <:actions> <.add_button navigate={~p"/gateways/new"}> - Add a new gateway + Add Gateway diff --git a/apps/web/lib/web/live/gateways_live/new.ex b/apps/web/lib/web/live/gateways_live/new.ex index 385099272..8f1c8e03d 100644 --- a/apps/web/lib/web/live/gateways_live/new.ex +++ b/apps/web/lib/web/live/gateways_live/new.ex @@ -12,7 +12,7 @@ defmodule Web.GatewaysLive.New do ]} /> <:title> - Add a new gateway + Add a new Gateway @@ -22,13 +22,13 @@ defmodule Web.GatewaysLive.New do
- <.label for="first-name"> + <.label for="gateway-name"> Name @@ -68,9 +68,18 @@ defmodule Web.GatewaysLive.New do
- <.submit_button> - Create - + + +
+ <.p> + Waiting for gateway connection... + +
diff --git a/apps/web/lib/web/live/gateways_live/show.ex b/apps/web/lib/web/live/gateways_live/show.ex index 2e9a36ee3..1f03cbeef 100644 --- a/apps/web/lib/web/live/gateways_live/show.ex +++ b/apps/web/lib/web/live/gateways_live/show.ex @@ -3,7 +3,218 @@ defmodule Web.GatewaysLive.Show do def render(assigns) do ~H""" - Viewing Gateway + <.section_header> + <:breadcrumbs> + <.breadcrumbs entries={[ + %{label: "Home", path: ~p"/"}, + %{label: "Gateways", path: ~p"/gateways"}, + %{label: "gcp-primary", path: ~p"/gateways/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"} + ]} /> + + <:title> + Viewing Gateway gcp-primary + + <:actions> + <.edit_button navigate={~p"/gateways/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"}> + Edit Gateway + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Name + + gcp-primary +
+ Connectivity + + Peer to Peer +
+ Status + + Online +
+ Location + + San Jose, CA +
+ Last seen + + 1 hour ago in San Francisco, CA +
+ Remote IPv4 + + 69.100.123.11 +
+ Remote IPv6 + + 2001:0db8:85a3:0000:0000:8a2e:0370:7334 +
+ Transfer + + 4.43 GB up, 1.23 GB down +
+ Gateway version + + v1.01 for Linux/x86_64 +
+ OS version + + Linux 5.10.25-1-MANJARO x86_64 +
+ Deployment method + + Docker +
+
+ +
+
+

+ Linked Resources +

+
+
+
+ + + + + + + + + + + + + + + + + +
+ Label + + Address +
+ <.link + navigate={~p"/resources/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"} + class="font-medium text-blue-600 dark:text-blue-500 hover:underline" + > + Engineering GitLab + + + gitlab.company.com +
+ <.link + navigate={~p"/resources/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"} + class="font-medium text-blue-600 dark:text-blue-500 hover:underline" + > + SJC VPC-1 + + + 172.16.45.0/24 +
+
+ + <.section_header> + <:title> + Danger zone + + <:actions> + <.delete_button> + Delete gateway + + + """ end end diff --git a/apps/web/lib/web/live/groups_live/edit.ex b/apps/web/lib/web/live/groups_live/edit.ex index ec6177125..1580d9780 100644 --- a/apps/web/lib/web/live/groups_live/edit.ex +++ b/apps/web/lib/web/live/groups_live/edit.ex @@ -3,20 +3,19 @@ defmodule Web.GroupsLive.Edit do def render(assigns) do ~H""" -
-
- + <.section_header> + <:breadcrumbs> <.breadcrumbs entries={[ %{label: "Home", path: ~p"/"}, %{label: "Groups", path: ~p"/groups"}, %{label: "Engineering", path: ~p"/groups/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"}, %{label: "Edit", path: ~p"/groups/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"} ]} /> -

- Updating group Engineering -

-
-
+ + <:title> + Editing group Engineering + +
@@ -64,9 +63,6 @@ defmodule Web.GroupsLive.Edit do > Save - <.delete_button> - Delete -
diff --git a/apps/web/lib/web/live/groups_live/show.ex b/apps/web/lib/web/live/groups_live/show.ex index 40dc2cc4f..de339fb4c 100644 --- a/apps/web/lib/web/live/groups_live/show.ex +++ b/apps/web/lib/web/live/groups_live/show.ex @@ -3,29 +3,25 @@ defmodule Web.GroupsLive.Show do def render(assigns) do ~H""" -
-
- + <.section_header> + <:breadcrumbs> <.breadcrumbs entries={[ %{label: "Home", path: ~p"/"}, %{label: "Groups", path: ~p"/groups"}, %{label: "Engineering", path: ~p"/groups/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"} ]} /> -

Group details

-
-
+ + <:title> + Viewing Group Engineering + + <:actions> + <.edit_button navigate={~p"/groups/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"}> + Edit Group + + +
-
-
- <.link - navigate={~p"/groups/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"} - class="flex items-center justify-center text-white bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-primary-600 dark:hover:bg-primary-700 focus:outline-none dark:focus:ring-primary-800" - > - <.icon name="hero-pencil-solid" class="w-3.5 h-3.5 mr-2" /> Edit group - -
-
@@ -77,7 +73,6 @@ defmodule Web.GroupsLive.Show do

Users

-
diff --git a/apps/web/lib/web/live/resources_live/index.ex b/apps/web/lib/web/live/resources_live/index.ex index cc2456524..1731cb30a 100644 --- a/apps/web/lib/web/live/resources_live/index.ex +++ b/apps/web/lib/web/live/resources_live/index.ex @@ -3,7 +3,22 @@ defmodule Web.ResourcesLive.Index do def render(assigns) do ~H""" - Listing Resources + <.section_header> + <:breadcrumbs> + <.breadcrumbs entries={[ + %{label: "Home", path: ~p"/"}, + %{label: "Resources", path: ~p"/resources"} + ]} /> + + <:title> + All Resources + + <:actions> + <.add_button navigate={~p"/resources/new"}> + Add a new Resource + + + """ end end diff --git a/apps/web/lib/web/live/resources_live/new.ex b/apps/web/lib/web/live/resources_live/new.ex index e3e768046..5eb8d47b9 100644 --- a/apps/web/lib/web/live/resources_live/new.ex +++ b/apps/web/lib/web/live/resources_live/new.ex @@ -3,7 +3,18 @@ defmodule Web.ResourcesLive.New do def render(assigns) do ~H""" - New Resource + <.section_header> + <:breadcrumbs> + <.breadcrumbs entries={[ + %{label: "Home", path: ~p"/"}, + %{label: "Resources", path: ~p"/resources"}, + %{label: "Add resource", path: ~p"/resources/new"} + ]} /> + + <:title> + Add a new Resource + + """ end end diff --git a/apps/web/lib/web/live/users_live/edit.ex b/apps/web/lib/web/live/users_live/edit.ex index 526c0dc69..e725b251c 100644 --- a/apps/web/lib/web/live/users_live/edit.ex +++ b/apps/web/lib/web/live/users_live/edit.ex @@ -3,20 +3,19 @@ defmodule Web.UsersLive.Edit do def render(assigns) do ~H""" -
-
- + <.section_header> + <:breadcrumbs> <.breadcrumbs entries={[ %{label: "Home", path: ~p"/"}, %{label: "Users", path: ~p"/users"}, %{label: "Bou Kheir, Jamil", path: ~p"/users/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"}, %{label: "Edit", path: ~p"/users/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"} ]} /> -

- Updating user Bou Kheir, Jamil -

-
-
+ + <:title> + Editing user Bou Kheir, Jamil + +
@@ -119,9 +118,6 @@ defmodule Web.UsersLive.Edit do > Save - <.delete_button> - Delete -
diff --git a/apps/web/lib/web/live/users_live/new.ex b/apps/web/lib/web/live/users_live/new.ex index d639c3dbf..037641b74 100644 --- a/apps/web/lib/web/live/users_live/new.ex +++ b/apps/web/lib/web/live/users_live/new.ex @@ -3,19 +3,18 @@ defmodule Web.UsersLive.New do def render(assigns) do ~H""" -
-
- + <.section_header> + <:breadcrumbs> <.breadcrumbs entries={[ %{label: "Home", path: ~p"/"}, %{label: "Users", path: ~p"/users"}, %{label: "Add user", path: ~p"/users/new"} ]} /> -

- Add a new user -

-
-
+ + <:title> + Add a new user + +
diff --git a/apps/web/lib/web/live/users_live/show.ex b/apps/web/lib/web/live/users_live/show.ex index c73dfe4ad..b0bb71530 100644 --- a/apps/web/lib/web/live/users_live/show.ex +++ b/apps/web/lib/web/live/users_live/show.ex @@ -3,26 +3,25 @@ defmodule Web.UsersLive.Show do def render(assigns) do ~H""" -
-
- + <.section_header> + <:breadcrumbs> <.breadcrumbs entries={[ %{label: "Home", path: ~p"/"}, %{label: "Users", path: ~p"/users"}, %{label: "Bou Kheir, Jamil", path: ~p"/users/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89"} ]} /> -

User details

-
-
+ + <:title> + Viewing User Bou Kheir, Jamil + + <:actions> + <.edit_button navigate={~p"/users/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"}> + Edit user + + +
-
-
- <.edit_button navigate={~p"/users/DF43E951-7DFB-4921-8F7F-BF0F8D31FA89/edit"}> - Edit user - -
-
@@ -112,6 +111,17 @@ defmodule Web.UsersLive.Show do
+ + <.section_header> + <:title> + Danger zone + + <:actions> + <.delete_button> + Delete user + + + """ end end diff --git a/apps/web/lib/web/router.ex b/apps/web/lib/web/router.ex index 0b6db13aa..29a3bc4b8 100644 --- a/apps/web/lib/web/router.ex +++ b/apps/web/lib/web/router.ex @@ -44,6 +44,7 @@ defmodule Web.Router do # Gateways live "/gateways", GatewaysLive.Index live "/gateways/new", GatewaysLive.New + live "/gateways/:id/edit", GatewaysLive.Edit live "/gateways/:id", GatewaysLive.Show # Resources diff --git a/apps/web/test/web/controllers/page_controller_test.exs b/apps/web/test/web/controllers/page_controller_test.exs index aed8bec9b..e04bd6981 100644 --- a/apps/web/test/web/controllers/page_controller_test.exs +++ b/apps/web/test/web/controllers/page_controller_test.exs @@ -1,8 +1,8 @@ defmodule Web.PageControllerTest do use Web.ConnCase - test "GET /", %{conn: conn} do - conn = get(conn, ~p"/") - assert html_response(conn, 200) =~ "Peace of mind from prototype to production" - end + # test "GET /", %{conn: conn} do + # conn = get(conn, ~p"/") + # assert html_response(conn, 200) =~ "Peace of mind from prototype to production" + # end end diff --git a/config/test.exs b/config/test.exs index 1d728b594..78db5437f 100644 --- a/config/test.exs +++ b/config/test.exs @@ -27,7 +27,7 @@ config :domain, Domain.ConnectivityChecks, enabled: false ############################### config :web, Web.Endpoint, - http: [port: 13000], + http: [port: 14_000], server: true ############################### @@ -35,7 +35,7 @@ config :web, Web.Endpoint, ############################### config :api, API.Endpoint, - http: [port: 13001], + http: [port: 14_001], server: true ###############################