Skip to content

Commit 9717ec8

Browse files
committed
TimeFilter: reduced options and fixed dates
1 parent def811d commit 9717ec8

File tree

1 file changed

+8
-55
lines changed

1 file changed

+8
-55
lines changed

apps/webapp/app/components/runs/v3/SharedFilters.tsx

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ const timePeriods = [
9595
label: "3 days",
9696
value: "3d",
9797
},
98+
{
99+
label: "5 days",
100+
value: "5d",
101+
},
98102
{
99103
label: "7 days",
100104
value: "7d",
@@ -106,11 +110,7 @@ const timePeriods = [
106110
{
107111
label: "30 days",
108112
value: "30d",
109-
},
110-
{
111-
label: "90 days",
112-
value: "90d",
113-
},
113+
}
114114
];
115115

116116
const timeUnits = [
@@ -702,7 +702,7 @@ export function TimeDropdown({
702702
onClick={() => {
703703
const today = new Date();
704704
setFromValue(startOfDay(today));
705-
setToValue(today);
705+
setToValue(endOfDay(today));
706706
setActiveSection("dateRange");
707707
setValidationError(null);
708708
setSelectedQuickDate("today");
@@ -714,33 +714,12 @@ export function TimeDropdown({
714714
onClick={() => {
715715
const now = new Date();
716716
setFromValue(startOfWeek(now, { weekStartsOn: 1 }));
717-
setToValue(now);
717+
setToValue(endOfWeek(now, { weekStartsOn: 1 }));
718718
setActiveSection("dateRange");
719719
setValidationError(null);
720720
setSelectedQuickDate("thisWeek");
721721
}}
722722
/>
723-
<QuickDateButton
724-
label="Last weekend"
725-
isActive={selectedQuickDate === "lastWeekend"}
726-
onClick={() => {
727-
const now = new Date();
728-
let saturday: Date;
729-
if (isSaturday(now)) {
730-
saturday = subDays(now, 7);
731-
} else if (isSunday(now)) {
732-
saturday = subDays(now, 8);
733-
} else {
734-
saturday = previousSaturday(now);
735-
}
736-
const sunday = endOfDay(subDays(saturday, -1));
737-
setFromValue(startOfDay(saturday));
738-
setToValue(sunday);
739-
setActiveSection("dateRange");
740-
setValidationError(null);
741-
setSelectedQuickDate("lastWeekend");
742-
}}
743-
/>
744723
<QuickDateButton
745724
label="Last week"
746725
isActive={selectedQuickDate === "lastWeek"}
@@ -753,20 +732,6 @@ export function TimeDropdown({
753732
setSelectedQuickDate("lastWeek");
754733
}}
755734
/>
756-
<QuickDateButton
757-
label="Last weekdays"
758-
isActive={selectedQuickDate === "lastWeekdays"}
759-
onClick={() => {
760-
const lastWeek = subWeeks(new Date(), 1);
761-
const monday = startOfWeek(lastWeek, { weekStartsOn: 1 });
762-
const friday = endOfDay(subDays(monday, -4)); // Monday + 4 days = Friday
763-
setFromValue(startOfDay(monday));
764-
setToValue(friday);
765-
setActiveSection("dateRange");
766-
setValidationError(null);
767-
setSelectedQuickDate("lastWeekdays");
768-
}}
769-
/>
770735
<QuickDateButton
771736
label="Last month"
772737
isActive={selectedQuickDate === "lastMonth"}
@@ -785,24 +750,12 @@ export function TimeDropdown({
785750
onClick={() => {
786751
const now = new Date();
787752
setFromValue(startOfMonth(now));
788-
setToValue(now);
753+
setToValue(endOfMonth(now));
789754
setActiveSection("dateRange");
790755
setValidationError(null);
791756
setSelectedQuickDate("thisMonth");
792757
}}
793758
/>
794-
<QuickDateButton
795-
label="Year to date"
796-
isActive={selectedQuickDate === "yearToDate"}
797-
onClick={() => {
798-
const now = new Date();
799-
setFromValue(startOfYear(now));
800-
setToValue(now);
801-
setActiveSection("dateRange");
802-
setValidationError(null);
803-
setSelectedQuickDate("yearToDate");
804-
}}
805-
/>
806759
</div>
807760
{validationError && activeSection === "dateRange" && (
808761
<Paragraph variant="extra-small" className="mt-2 text-error">

0 commit comments

Comments
 (0)