Skip to content
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

feat: date range selector #8991

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

feat: date range selector #8991

wants to merge 4 commits into from

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Dec 17, 2024

About the changes

Adding a new capability to select date ranges. It allows to select a date range preset from the from/to dates. This is already available in the Insights sections and in the Event Log search.

presets_final.mov

Details:

  • from and to dates are preselected and can never be dismissed
  • by default to date is today and from date is a month ago
  • you can choose individual days as before or choose the presets

Important files

Discussion points

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 1:18pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Dec 17, 2024 1:18pm

Copy link
Contributor

github-actions bot commented Dec 17, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

},
{
label: 'Date To',
icon: 'today',
options: [],
filterKey: 'to',
dateOperators: ['IS'],
fromFilterKey: 'from',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the from/to filter keys are present then the date selection component automatically gets presets working

@@ -41,6 +41,8 @@ type ITextFilterItem = IBaseFilterItem & {

type IDateFilterItem = IBaseFilterItem & {
dateOperators: [string, ...string[]];
fromFilterKey?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

range presents are optional

| 'thisYear'
| 'previousYear';

export const calculateDateRange = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted for testability

@@ -32,10 +34,20 @@ export const Insights: FC<InsightsProps> = ({ withCharts = true }) => {

const stateConfig = {
project: FilterItemParam,
from: FilterItemParam,
to: FilterItemParam,
from: withDefault(FilterItemParam, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preselected dates always show a current day minus one month

};
const [state, setState] = usePersistentTableState('insights', stateConfig);
const [state, setState] = usePersistentTableState('insights', stateConfig, [
'from',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want o persist from and to to local storage and prefer to always use the moving last month window

operators={filter.dateOperators}
onChipClose={() => deselectFilter(filter.label)}
onChipClose={
filter.persistent
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

persistent filters don't allow to close with a chip click

@@ -31,6 +31,7 @@ const StyledLabel = styled('div')(({ theme }) => ({
alignItems: 'center',
justifyContent: 'space-between',
fontWeight: theme.typography.fontWeightBold,
minHeight: theme.spacing(3.5),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to make sure that filters with chip and without a chip have the same height

Copy link
Member

@Tymek Tymek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird not having the "default" unselected option. Time selector stands a lot.

I think calendar and presets are too fair apart. Also title "Presets" doesn't look correct to me. Maybe "Choose date range"?
image

"This year" could be "This year to date"?

Just nitpicking, because code looks good. UX is a bit of a compromise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Approved PRs
Development

Successfully merging this pull request may close these issues.

2 participants