-
-
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
Changes from all commits
ab66ff8
8fc4804
f398aaf
1c4804e
655f474
a06ef3f
5b46862
49f3565
f2bfbbf
0ac2776
79042bb
594ef0a
3d5ed50
86b7acb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency's sake, we could adjust the module name as well. Or even change that to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed! 3d5ed50 |
| 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.{Dashboard, 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 Dashboard.QuerySerializer.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 | ||
| 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 |
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.