diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex index 1d2a62b06..f5f0d5be4 100644 --- a/lib/plausible_web/components/generic.ex +++ b/lib/plausible_web/components/generic.ex @@ -71,13 +71,21 @@ defmodule PlausibleWeb.Components.Generic do def button_link(assigns) do theme_class = if assigns.disabled do - "bg-gray-400 text-white dark:text-white dark:text-gray-400 dark:bg-gray-700 pointer-events-none cursor-default" + "bg-gray-400 text-white dark:text-white dark:text-gray-400 dark:bg-gray-700 cursor-not-allowed" else @button_themes[assigns.theme] end + onclick = + if assigns.disabled do + "return false;" + else + assigns[:onclick] + end + assigns = assign(assigns, + onclick: onclick, button_base_class: @button_base_class, theme_class: theme_class ) @@ -85,6 +93,7 @@ defmodule PlausibleWeb.Components.Generic do ~H""" <.link href={@href} + onclick={@onclick} class={[ @button_base_class, @theme_class, diff --git a/lib/plausible_web/live/imports_exports_settings.ex b/lib/plausible_web/live/imports_exports_settings.ex index 56e5fa7b8..4e0851a75 100644 --- a/lib/plausible_web/live/imports_exports_settings.ex +++ b/lib/plausible_web/live/imports_exports_settings.ex @@ -48,35 +48,59 @@ defmodule PlausibleWeb.Live.ImportsExportsSettings do &(&1.live_status in [SiteImport.pending(), SiteImport.importing()]) ) - assigns = assign(assigns, :import_in_progress?, import_in_progress?) + at_maximum? = length(assigns.site_imports) >= assigns.max_imports + + csv_imports_exports_enabled? = FunWithFlags.enabled?(:csv_imports_exports, for: assigns.site) + + import_warning = + cond do + import_in_progress? -> + "No new imports can be started until the import in progress is completed or cancelled." + + at_maximum? -> + "Maximum of #{assigns.max_imports} imports is reached. " <> + "Delete or cancel an existing import to start a new one." + + true -> + nil + end + + assigns = + assign(assigns, + import_in_progress?: import_in_progress?, + at_maximum?: at_maximum?, + import_warning: import_warning, + csv_imports_exports_enabled?: csv_imports_exports_enabled? + ) ~H"""
- No new imports can be started until the import in progress is completed or cancelled. +
+ <%= @import_warning %>
@@ -94,12 +118,6 @@ defmodule PlausibleWeb.Live.ImportsExportsSettings do
- <%= Plausible.Imported.SiteImport.label(entry.site_import) %>
-
- (<%= PlausibleWeb.StatsView.large_number_format(
- Map.get(@pageview_counts, entry.site_import.id, 0)
- ) %> page views)
-
From <%= format_date(entry.site_import.start_date) %> to <%= format_date( diff --git a/lib/plausible_web/templates/google_analytics/confirm.html.heex b/lib/plausible_web/templates/google_analytics/confirm.html.heex index cf128d901..c3d37d8db 100644 --- a/lib/plausible_web/templates/google_analytics/confirm.html.heex +++ b/lib/plausible_web/templates/google_analytics/confirm.html.heex @@ -1,4 +1,4 @@ -<%= form_for @conn, Routes.google_analytics_path(@conn, :import, @site.domain), [class: "max-w-md w-full mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %> +<%= form_for @conn, Routes.google_analytics_path(@conn, :import, @site.domain), [onsubmit: "confirmButton.disabled = true; return true;", class: "max-w-md w-full mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %>
+ + Go back + +
+ + <%= submit(name: "confirmButton", class: "button sm:w-auto w-full [&>span.label-enabled]:block [&>span.label-disabled]:hidden [&[disabled]>span.label-enabled]:hidden [&[disabled]>span.label-disabled]:block") do %> + + Confirm import + + + ++ + Go back + +
+ + <%= submit(name: "continueButton", class: "button sm:w-auto w-full [&>span.label-enabled]:block [&>span.label-disabled]:hidden [&[disabled]>span.label-enabled]:hidden [&[disabled]>span.label-disabled]:block") do %> + + Continue -> + + + ++ + Go back + +
+ + <%= link("Continue ->", + to: + Routes.google_analytics_path(@conn, :confirm, @site.domain, + property_or_view: @property_or_view, + access_token: @access_token, + refresh_token: @refresh_token, + expires_at: @expires_at, + start_date: @start_date, + end_date: @end_date, + legacy: @legacy + ), + class: "button sm:w-auto w-full" + ) %> +- Export all your data into CSV format. -
-+ Export all your data into CSV format. +
+