From 9cf52bb7e4fd524ee70a2155404efc8930f3d98f Mon Sep 17 00:00:00 2001
From: sabaimran <65192171+sabaimran@users.noreply.github.com>
Date: Sat, 20 Jul 2024 23:52:23 -0700
Subject: [PATCH] Update automations UX for more consistency (#856)
* Update the automations UI to be a more suitable color distribution based on new designs
* Use accented colors for the metadata, update dark mode colors
* Update form to use icons as well and render more pretty inline form labels
---
.../app/automations/automations.module.css | 5 +
src/interface/web/app/automations/page.tsx | 498 +++++++++++-------
.../app/components/shareLink/shareLink.tsx | 3 +-
3 files changed, 318 insertions(+), 188 deletions(-)
diff --git a/src/interface/web/app/automations/automations.module.css b/src/interface/web/app/automations/automations.module.css
index 206d4c36..25b4b79f 100644
--- a/src/interface/web/app/automations/automations.module.css
+++ b/src/interface/web/app/automations/automations.module.css
@@ -4,6 +4,11 @@ div.automationsLayout {
gap: 1rem;
}
+div.automationCard {
+ display: grid;
+ grid-template-rows: auto 1fr auto;
+}
+
@media screen and (max-width: 768px) {
div.automationsLayout {
grid-template-columns: 1fr;
diff --git a/src/interface/web/app/automations/page.tsx b/src/interface/web/app/automations/page.tsx
index 85a0cb7d..52606781 100644
--- a/src/interface/web/app/automations/page.tsx
+++ b/src/interface/web/app/automations/page.tsx
@@ -47,8 +47,8 @@ import styles from './automations.module.css';
import ShareLink from '../components/shareLink/shareLink';
import { useSearchParams } from 'next/navigation';
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
-import { Clock, DotsThreeVertical, Envelope, Info, MapPinSimple, Pencil, Play, Plus, Trash } from '@phosphor-icons/react';
-import { useAuthenticatedData } from '../common/auth';
+import { CalendarCheck, CalendarDot, CalendarDots, Clock, ClockAfternoon, ClockCounterClockwise, DotsThreeVertical, Envelope, Info, Lightning, MapPinSimple, Pencil, Play, Plus, Trash } from '@phosphor-icons/react';
+import { useAuthenticatedData, UserProfile } from '../common/auth';
import LoginPrompt from '../components/loginPrompt/loginPrompt';
import { useToast } from '@/components/ui/use-toast';
import { ToastAction } from '@/components/ui/toast';
@@ -223,6 +223,7 @@ interface AutomationsCardProps {
setNewAutomationData?: (data: AutomationsData) => void;
isLoggedIn: boolean;
setShowLoginPrompt: (showLoginPrompt: boolean) => void;
+ authenticatedData: UserProfile | null;
}
@@ -235,6 +236,33 @@ function AutomationsCard(props: AutomationsCardProps) {
const automation = props.automation;
+ const [timeRecurrence, setTimeRecurrence] = useState('');
+
+ const [intervalString, setIntervalString] = useState('');
+
+ useEffect(() => {
+ // The updated automation data, if present, takes priority over the original automation data
+ const automationData = updatedAutomationData || automation;
+ setTimeRecurrence(getTimeRecurrenceFromCron(automationData.crontime));
+ const frequency = getEveryBlahFromCron(automationData.crontime);
+
+ console.log('frequency', frequency);
+ if (frequency === 'Day') {
+ setIntervalString('Daily');
+ } else if (frequency === 'Week') {
+ const dayOfWeek = getDayOfWeekFromCron(automationData.crontime);
+ if (dayOfWeek === undefined) {
+ setIntervalString('Weekly');
+ } else {
+ setIntervalString(`${weekDays[dayOfWeek]}`);
+ }
+ } else if (frequency === 'Month') {
+ const dayOfMonth = getDayOfMonthFromCron(automationData.crontime);
+ setIntervalString(`Monthly on the ${dayOfMonth}`);
+ }
+ }, [updatedAutomationData, props.automation]);
+
+
useEffect(() => {
const toastTitle = `Automation: ${updatedAutomationData?.subject || automation.subject}`;
if (toastMessage) {
@@ -254,117 +282,128 @@ function AutomationsCard(props: AutomationsCardProps) {
}
return (
-
-
-
-
- {updatedAutomationData?.subject || automation.subject}
-
-
-
-
-
-
- {
- !props.suggestedCard && (
-
- )
- }
- {
- !props.suggestedCard && (
-
- )
- }
-
-
-
-
-
- {updatedAutomationData?.schedule || cronToHumanReadableString(automation.crontime)}
-
-
-
- {updatedAutomationData?.query_to_run || automation.query_to_run}
-
-
- {
- props.suggestedCard && props.setNewAutomationData && (
-
- )
- }
- {
- navigator.clipboard.writeText(createShareLink(automation));
- }} />
-
-
-
+ )
+ }
+ {
+ navigator.clipboard.writeText(createShareLink(automation));
+ }} />
+
+
+
+
+
+ {updatedAutomationData?.query_to_run || automation.query_to_run}
+
+
+
+
+
+
+ {timeRecurrence}
+
+
+
+
+
+ {intervalString}
+
+
+
+ {
+ props.suggestedCard && props.setNewAutomationData && (
+
+ )
+ }
+
+
)
}
@@ -373,6 +412,7 @@ interface SharedAutomationCardProps {
setNewAutomationData: (data: AutomationsData) => void;
isLoggedIn: boolean;
setShowLoginPrompt: (showLoginPrompt: boolean) => void;
+ authenticatedData: UserProfile | null;
}
function SharedAutomationCard(props: SharedAutomationCardProps) {
@@ -407,8 +447,12 @@ function SharedAutomationCard(props: SharedAutomationCardProps) {
- Create Automation
+
+
+ Create Automation
+
void;
+ authenticatedData: UserProfile | null;
}
function EditCard(props: EditCardProps) {
@@ -524,7 +569,14 @@ function EditCard(props: EditCardProps) {
}
return (
-
+
)
}
@@ -535,6 +587,8 @@ interface AutomationModificationFormProps {
create?: boolean;
isLoggedIn: boolean;
setShowLoginPrompt: (showLoginPrompt: boolean) => void;
+ authenticatedData: UserProfile | null;
+ locationData: LocationData | null;
}
function AutomationModificationForm(props: AutomationModificationFormProps) {
@@ -547,7 +601,7 @@ function AutomationModificationForm(props: AutomationModificationFormProps) {
function recommendationPill(recommendationText: string, onChange: (value: any, event: React.MouseEvent) => void) {
return (
{
@@ -572,6 +626,16 @@ function AutomationModificationForm(props: AutomationModificationFormProps) {
props.onSubmit(values);
setIsSaving(true);
})} className="space-y-8">
+
+ Setup
+
+ Emails will be sent to this address. Timezone and location data will be used to schedule automations.
+ {
+ props.locationData &&
+ metadataMap(props.locationData, props.authenticatedData)
+ }
+
+
{
!props.create && (
- Frequency
+
+ Frequency
+
- How frequently should this automation run?
+ How often should this automation run?