-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Another iteration of Dashboard.Live.Pages #5986
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 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ab66ff8
move DashboardQueryParser and serializer to subfolder
RobertJoonas 8fc4804
add external link construction logic
RobertJoonas f398aaf
default include.imports_meta to false
RobertJoonas 1c4804e
imported warning with tests (no tooltip yet)
RobertJoonas 655f474
switch to new styling
RobertJoonas a06ef3f
query the right conversion rate
RobertJoonas 5b46862
fix external link display on hover
RobertJoonas 49f3565
replicate initial loading state in React
RobertJoonas f2bfbbf
add missing class
RobertJoonas 0ac2776
remove TODO comments
RobertJoonas 79042bb
fix tests
RobertJoonas 594ef0a
fix ce_test
RobertJoonas 3d5ed50
rename modules
RobertJoonas 86b7acb
use storage util
RobertJoonas 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
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
File renamed without changes.
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,47 @@ | ||
| defmodule Plausible.Stats.Dashboard.Utils do | ||
| @moduledoc """ | ||
| Shared utilities by different dashboard reports. | ||
| """ | ||
|
|
||
| alias Plausible.Site | ||
| alias Plausible.Stats.{DashboardQuerySerializer, ParsedQueryParams} | ||
|
|
||
| def page_external_link_fn_for(site) do | ||
| with true <- Plausible.Sites.regular?(site), | ||
| [domain | _] <- String.split(site.domain, "/"), | ||
| {:ok, domain} <- idna_encode(domain), | ||
RobertJoonas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {:ok, uri} <- URI.new("https://#{domain}/") do | ||
| fn item -> | ||
| "https://#{uri.host}#{hd(item.dimensions)}" | ||
| end | ||
| else | ||
| _ -> nil | ||
RobertJoonas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
|
|
||
| def dashboard_route(%Site{} = site, %ParsedQueryParams{} = params, opts) do | ||
| path = Keyword.get(opts, :path, "") | ||
|
|
||
| params = | ||
| case Keyword.get(opts, :filter) do | ||
| nil -> params | ||
| filter -> ParsedQueryParams.add_or_replace_filter(params, filter) | ||
| end | ||
|
|
||
| query_string = | ||
| case DashboardQuerySerializer.serialize(params) do | ||
| "" -> "" | ||
| query_string -> "?" <> query_string | ||
| end | ||
|
|
||
| "/" <> site.domain <> path <> query_string | ||
| end | ||
|
|
||
| defp idna_encode(domain) do | ||
| try do | ||
| {:ok, domain |> String.to_charlist() |> :idna.encode() |> IO.iodata_to_binary()} | ||
| catch | ||
| _ -> {:error, :invalid_domain} | ||
| end | ||
| 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
29 changes: 29 additions & 0 deletions
29
lib/plausible_web/live/components/dashboard/imported_data_warnings.ex
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,29 @@ | ||
| defmodule PlausibleWeb.Components.Dashboard.ImportedDataWarnings do | ||
| @moduledoc false | ||
|
|
||
| use PlausibleWeb, :component | ||
| alias Phoenix.LiveView.AsyncResult | ||
| alias Plausible.Stats.QueryResult | ||
|
|
||
| def unsupported_filters(assigns) do | ||
| show? = | ||
| case assigns.query_result do | ||
| %AsyncResult{result: %QueryResult{meta: meta}} -> | ||
| meta[:imports_skip_reason] == :unsupported_query | ||
|
|
||
| _ -> | ||
| false | ||
| end | ||
|
|
||
| assigns = assign(assigns, :show?, show?) | ||
|
|
||
| ~H""" | ||
| <div :if={@show?} data-test-id="unsupported-filters-warning"> | ||
| <span class="hidden"> | ||
| Imported data is excluded due to the applied filters | ||
| </span> | ||
| <Heroicons.exclamation_circle class="mb-1 size-4.5 text-gray-500 dark:text-gray-400" /> | ||
| </div> | ||
| """ | ||
| 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice improvement in UX ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this gets a bit tricky when we want to replace "Top Pages" -> "Conversion Pages" when filtering by a goal. As soon as the navigation event (let's say applying the goal filter) happens, the component instantly starts to load (optimistically, relying on the
phx-navigation-loadingclass). During that optimistic loading we don't know whether the report title should be Conversion/Top pages. It requires a round-trip to the server to know whether a goal filter is applied or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the green light to revert the dynamic report title change and keep it static as it was before a couple of days ago. Before we do that though, let's make sure there's a plan to overcome the issue with hooks in a deadview. Not a blocker to this PR anyways.