-
Notifications
You must be signed in to change notification settings - Fork 24
Feature: add settings panel #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e93f2a3
Added settings button
kraleppa 926f7dd
Basic settings view
kraleppa 0cec247
Added navbar and stuff
kraleppa 6bdf940
Added appearance select
kraleppa 862984b
Removed comment
kraleppa 5cb499a
All buttons added
kraleppa e6d176f
Added description of deadview
kraleppa 60e32fa
Added clicks
kraleppa 0498788
Added tests with checks for settings button
kraleppa b6a8f76
Merge branch 'main' into 427-add-settings-button-to-navbar
kraleppa f34eb5f
Post merge fix
kraleppa 38cb3f0
Removed obsolete margin from callback traces
kraleppa 79773fe
Added margins for load more button
kraleppa 4db8347
Simplified html
kraleppa 6494450
Refactored settings
kraleppa 6e23e5d
Removed phx-click
kraleppa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| defmodule LiveDebuggerWeb.SettingsLive do | ||
| @moduledoc """ | ||
| LiveView for the settings page. | ||
| """ | ||
|
|
||
| use LiveDebuggerWeb, :live_view | ||
|
|
||
| alias LiveDebuggerWeb.Components.Navbar | ||
| alias LiveDebuggerWeb.Helpers.RoutesHelper | ||
|
|
||
| @impl true | ||
| def render(assigns) do | ||
| ~H""" | ||
| <div class="flex-1 min-w-[25rem] grid grid-rows-[auto_1fr]"> | ||
| <Navbar.navbar class="flex"> | ||
| <Navbar.return_link return_link={RoutesHelper.live_views_dashboard()} /> | ||
| <Navbar.live_debugger_logo /> | ||
| </Navbar.navbar> | ||
| <div class="flex-1 max-lg:p-8 pt-8 lg:w-[60rem] lg:m-auto"> | ||
| <div class="flex items-center justify-between"> | ||
| <.h1>Settings</.h1> | ||
| </div> | ||
|
|
||
| <%!-- Upper section --%> | ||
| <div class="mt-6 bg-surface-0-bg rounded shadow-custom border border-default-border"> | ||
| <%!-- Appearance --%> | ||
| <div class="p-6"> | ||
| <p class="font-semibold mb-3">Appearance</p> | ||
| <div class="flex gap-2"> | ||
| <.dark_mode_button /> | ||
| <.light_mode_button /> | ||
| </div> | ||
| </div> | ||
| <%!-- Checkboxes --%> | ||
| <div class="p-6 border-t border-default-border flex flex-col gap-3"> | ||
| <.settings_switch | ||
| label="Enable DeadView mode" | ||
| description="When enabled, LiveDebugger won't redirect to new LiveView after page redirect or reload, allowing you to browse assigns and traces of dead LiveViews." | ||
| checked={false} | ||
| phx-click="update" | ||
| phx-value-setting="deadview_mode" | ||
| /> | ||
|
|
||
| <.settings_switch | ||
| label="Enable global tracing" | ||
| description="Enabling this feature may have a negative impact on application performance." | ||
| checked={false} | ||
| phx-click="update" | ||
| phx-value-setting="global_tracing" | ||
| /> | ||
|
|
||
| <.settings_switch | ||
| label="Refresh tracing on reload" | ||
| description="Enabling this feature may have a negative impact on application performance." | ||
| checked={false} | ||
| phx-click="update" | ||
| phx-value-setting="refresh_tracing_on_reload" | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <%!-- Lower section --%> | ||
| <div class="mt-6 bg-surface-0-bg rounded shadow-custom border border-default-border"> | ||
| <%!-- Restart button --%> | ||
| <div class="p-6 flex flex-col md:flex-row justify-between md:items-center gap-4"> | ||
| <div class="flex flex-col gap-1"> | ||
| <p class="font-semibold">Restart LiveDebugger</p> | ||
| <p class="text-secondary-text"> | ||
| Use this option if LiveDebugger appears to stop responding or not working properly. | ||
| </p> | ||
| </div> | ||
| <.button variant="secondary" phx-click="restart">Restart LiveDebugger</.button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| """ | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_event("update", %{"setting" => _setting}, socket) do | ||
| {:noreply, socket} | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_event("restart", _, socket) do | ||
| {:noreply, socket} | ||
| end | ||
|
|
||
| attr(:label, :string, required: true) | ||
| attr(:description, :string, required: true) | ||
| attr(:checked, :boolean, default: false) | ||
| attr(:rest, :global) | ||
|
|
||
| defp settings_switch(assigns) do | ||
| ~H""" | ||
| <div class="flex items-center"> | ||
| <.toggle_switch checked={@checked} wrapper_class="pr-3 py-0" {@rest} /> | ||
| <div class="flex flex-col gap-0.5"> | ||
| <p class="font-semibold"><%= @label %></p> | ||
| <p class="text-secondary-text"><%= @description %></p> | ||
| </div> | ||
| </div> | ||
| """ | ||
| end | ||
|
|
||
| defp dark_mode_button(assigns) do | ||
| ~H""" | ||
| <.mode_button | ||
| id="dark-mode-switch" | ||
| icon="icon-moon" | ||
| text="Dark" | ||
| class="dark:hidden text-button-secondary-content bg-button-secondary-bg hover:bg-button-secondary-bg-hover border border-default-border" | ||
| phx-hook="ToggleTheme" | ||
| /> | ||
| <.mode_button | ||
| icon="icon-moon" | ||
| text="Dark" | ||
| class="hidden dark:flex text-button-primary-content bg-button-primary-bg" | ||
| /> | ||
| """ | ||
| end | ||
|
|
||
| defp light_mode_button(assigns) do | ||
| ~H""" | ||
| <.mode_button | ||
| id="light-mode-switch" | ||
| icon="icon-sun" | ||
| text="Light" | ||
| class="hidden dark:flex text-button-secondary-content bg-button-secondary-bg hover:bg-button-secondary-bg-hover border border-default-border" | ||
| phx-hook="ToggleTheme" | ||
| /> | ||
| <.mode_button | ||
| icon="icon-sun" | ||
| text="Light" | ||
| class="dark:hidden text-button-primary-content bg-button-primary-bg" | ||
| /> | ||
| """ | ||
| end | ||
|
|
||
| attr(:icon, :string, required: true) | ||
| attr(:text, :string, required: true) | ||
| attr(:class, :string, default: "") | ||
| attr(:rest, :global) | ||
|
|
||
| defp mode_button(assigns) do | ||
| ~H""" | ||
| <button | ||
| class={[ | ||
| "flex items-center justify-center gap-2 py-2 px-4 rounded", | ||
| @class | ||
| ]} | ||
| {@rest} | ||
| > | ||
| <.icon name={@icon} class="w-5 h-5" /> | ||
| <p><%= @text %></p> | ||
| </button> | ||
| """ | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.