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

[dashboard] usage view allows for flexible time range #14515

Merged
merged 1 commit into from
Nov 10, 2022
Merged

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Nov 8, 2022

Description

This change allows to set custom date ranges on the usage view.
Screenshot 2022-11-08 at 20 49 27

Related Issue(s)

See #14463, #13288

How to test

Release Notes

Usage view allows for arbitrary date ranges

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-se-usage-view.42 because the annotations in the pull request description changed
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-se-usage-view.43 because the annotations in the pull request description changed
(with .werft/ from main)

@svenefftinge svenefftinge changed the title tbd [dashboard] usage view allows for flexible time range Nov 8, 2022
@svenefftinge
Copy link
Member Author

svenefftinge commented Nov 8, 2022

/werft run with-clean-slate-deployment

👍 started the job as gitpod-build-se-usage-view.44
(with .werft/ from main)

@easyCZ
Copy link
Member

easyCZ commented Nov 8, 2022

Nice improvement!

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Tested and works nicely. 💖

/hold in case you want to handle this here, now.

@gtsiolis
Copy link
Contributor

gtsiolis commented Nov 9, 2022

Looking at this now! 👀

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Thanks @svenefftinge for adding this and hanging here while I was collecting some all around thoughts around the hot 🔥 topic of a date picker component.

Left some first-round comments below to keep the conversations going.

components/dashboard/src/components/UsageView.tsx Outdated Show resolved Hide resolved
}
subtitle={
<h2 className="tracking-wide flex mt-3">
<h2 className="mr-2">Period: </h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: The main issue with adding the range picker here is that this introduces another point for selecting a period, see 🅰️ and 🅱️ in the screenshot below.

Entry points for selecting a period
Frame 1134

}
subtitle={
<h2 className="tracking-wide flex mt-3">
<h2 className="mr-2">Period: </h2>
Copy link
Contributor

@gtsiolis gtsiolis Nov 9, 2022

Choose a reason for hiding this comment

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

thought: The idea of having the period selection on the top of the left sidebar is to update all usage entries on the main content as well as all aggregated data on the left sidebar based on the period selection. We could use the heading subtitle for hijacking this action and filtering in a similar way also other views like workpaces per team, etc.

Idea of the top-left control for period selection
Frame 1135

}
subtitle={
<h2 className="tracking-wide flex mt-3">
<h2 className="mr-2">Period: </h2>
Copy link
Contributor

@gtsiolis gtsiolis Nov 9, 2022

Choose a reason for hiding this comment

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

question: While the goal long term is to replace the primitive navigation between months with more flexible options (Last 7 days, 30 days, etc) with a flexible dropdown (see #11685 (comment)) and possibly move the tabs below the header (#10976), to keep the scope small here, what do you think of moving the period elements below inside the left sidebar? Alternatively, we could keep the custom filtering on the heading subtitle, which feels nice.

Early design for period selection Selection on the sidebar Selection on the heading
180983560-cdf7fcf7-5352-486f-98dd-66761a736044 Screenshot 2022-11-09 at 9 22 57 PM Screenshot 2022-11-09 at 9 27 59 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

If you let me pick, I'd go with the "Selection on the heading" version. Looks slickest to me.
Would be great if you could take a general look at how we want to do the range selection out of the scope of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

The selection on the heading looks slick indeed, and I've been wanting to make this heading component more useful so that form follows function (internal), see #10138 and #6764. Let's try that regardless of any updates that will take place in the left sidebar. 🤝

onChange={(date) => date && setEndDate(date.getTime())}
selectsEnd
startDate={new Date(startDate)}
endDate={new Date(endDate)}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Could we show the last day of a month for each month selection? Currently, for example, when selecting October 2022, the range changes to 01/10/2022 - 01/11/2022, and would be more accurate if this would change to 01/10/2022 - 31/10/2022.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

subtitle={
<h2 className="tracking-wide flex mt-3">
<h2 className="mr-2">Period: </h2>
{startDateError}
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Probably not the same error as in the screenshot, and maybe out of the scope of the changes, but we should probably impose a limit on the the max date range gap like 180 days or something, right? A good MVC could be to surface a danger alert with the error message instead of breaking the page.

Screenshot 2022-11-09 at 9 39 34 PM

components/dashboard/package.json Show resolved Hide resolved
components/dashboard/package.json Show resolved Hide resolved
components/dashboard/src/components/react-datepicker.css Outdated Show resolved Hide resolved
}
subtitle={
<h2 className="tracking-wide flex mt-3">
<h2 className="mr-2">Period: </h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: Ideally, the custom period selection should be as close as possible with the fixed period selections.

@svenefftinge svenefftinge force-pushed the se/usage-view branch 2 times, most recently from b1f7e52 to 959e374 Compare November 10, 2022 16:44
Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Alright, almost there! Thanks for addressing all design-related feedback, @svenefftinge!

Left one more round of comments.

Other than that, looks great! Leave anything that looks insignificant to block from merging for a follow up PR. I can make most of the style changes in a separate PR. 🏀

}
subtitle={
<h2 className="tracking-wide flex mt-3">
<h2 className="mr-2">Period: </h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

The selection on the heading looks slick indeed, and I've been wanting to make this heading component more useful so that form follows function (internal), see #10138 and #6764. Let's try that regardless of any updates that will take place in the left sidebar. 🤝

onChange={(date) => date && setEndDate(date.getTime())}
selectsEnd
startDate={new Date(startDate)}
endDate={new Date(endDate)}
Copy link
Contributor

Choose a reason for hiding this comment

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

ok

selected={new Date(endDate)}
onChange={(date) => date && setEndDate(date.getTime())}
selectsEnd
startDate={new Date(startDate)}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks one hundred times better. 💯

Screenshot 2022-11-10 at 7 57 29 PM

title={
<div className="flex items-baseline">
<h1 className="tracking-wide">{headerTitle}</h1>
<h2 className="ml-3">(updated every 15 minutes).</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

question: We dropped this information, but I can open a follow up PR to add this back. Would you say it's not as useful to include in the page? If you think it's ok to include, here's the SVG. Using one gray color could suffice for the first iteration on light and dark theme.

<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  <path fill="#0F172A" d="M12.75 6c0-.41421-.3358-.75-.75-.75s-.75.33579-.75.75h1.5ZM12 12h-.75c0 .4142.3358.75.75.75V12Zm4.5.75c.4142 0 .75-.3358.75-.75s-.3358-.75-.75-.75v1.5Zm3.75-.75c0 4.5563-3.6937 8.25-8.25 8.25v1.5c5.3848 0 9.75-4.3652 9.75-9.75h-1.5ZM12 20.25c-4.55635 0-8.25-3.6937-8.25-8.25h-1.5c0 5.3848 4.36522 9.75 9.75 9.75v-1.5ZM3.75 12c0-4.55635 3.69365-8.25 8.25-8.25v-1.5c-5.38478 0-9.75 4.36522-9.75 9.75h1.5ZM12 3.75c4.5563 0 8.25 3.69365 8.25 8.25h1.5c0-5.38478-4.3652-9.75-9.75-9.75v1.5ZM11.25 6v6h1.5V6h-1.5Zm5.25 5.25H12v1.5h4.5v-1.5Z"/>
</svg>

@@ -160,13 +175,67 @@ function UsageView({ attributionId }: UsageViewProps) {

const headerTitle = attributionId.kind === "team" ? "Team Usage" : "Personal Usage";

const DateDisplay = forwardRef((arg: any, ref: any) => (
<div
className="px-2 p-1 text-gray-500 bg-gray-100 dark:text-gray-400 dark:bg-gray-800 rounded-md cursor-pointer flex items-center"
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Minor hover state fix.

Suggested change
className="px-2 p-1 text-gray-500 bg-gray-100 dark:text-gray-400 dark:bg-gray-800 rounded-md cursor-pointer flex items-center"
className="px-2 p-1 text-gray-500 bg-gray-50 dark:text-gray-400 dark:bg-gray-800 rounded-md cursor-pointer flex items-center hover:bg-gray-100 dark:hover:bg-gray-700"

customInput={<DateDisplay />}
dateFormat={"MMM d, yyyy"}
/>
<h2 className="mx-2">to</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Minor spacing fix.

Suggested change
<h2 className="mx-2">to</h2>
<h2 className="mx-1">to</h2>

@@ -160,13 +175,67 @@ function UsageView({ attributionId }: UsageViewProps) {

const headerTitle = attributionId.kind === "team" ? "Team Usage" : "Personal Usage";

const DateDisplay = forwardRef((arg: any, ref: any) => (
<div
className="px-2 p-1 text-gray-500 bg-gray-100 dark:text-gray-400 dark:bg-gray-800 rounded-md cursor-pointer flex items-center"
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Minor line height fix.

Suggested change
className="px-2 p-1 text-gray-500 bg-gray-100 dark:text-gray-400 dark:bg-gray-800 rounded-md cursor-pointer flex items-center"
className="px-2 py-0.5 text-gray-500 bg-gray-100 dark:text-gray-400 dark:bg-gray-800 rounded-md cursor-pointer flex items-center"

</div>
}
subtitle={
<div className="tracking-wide flex mt-3 items-center">
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Minor spacing issue, breaking line height.

Suggested change
<div className="tracking-wide flex mt-3 items-center">
<div className="tracking-wide flex items-center">

Copy link
Member Author

Choose a reason for hiding this comment

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

Removing this looks bad. Are you sure? If so please fix in a follow up.

</div>
}
subtitle={
<div className="tracking-wide flex mt-3 items-center">
Copy link
Contributor

Choose a reason for hiding this comment

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

issue(non-blocking): This structure breaks slightly the heigh of the header but let's fix this in #6764 unless you'd like to move this element in the div above, see subtitle and bottom border.

Frame 1136

@svenefftinge
Copy link
Member Author

/unhold

@roboquat roboquat merged commit f4eb948 into main Nov 10, 2022
@roboquat roboquat deleted the se/usage-view branch November 10, 2022 19:40
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production needs visual design release-note size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants