-
Notifications
You must be signed in to change notification settings - Fork 894
feat(site): add support for weekly data on template insights #9997
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a27af59
Add weekly control
BrunoQuaresma ad8a4ae
Interval menu position
BrunoQuaresma 41cc638
Add weekly controls
BrunoQuaresma 86fab98
Fix title and description
BrunoQuaresma 78e6db0
Modify DAUChart to be agnostic to interval
BrunoQuaresma 6b4e763
Update chart to support weekly data
BrunoQuaresma 56b9484
Make default interval as week
BrunoQuaresma f1ea361
If template is created less than 5 weeks, show daily
BrunoQuaresma 0c1ea95
Merge branch 'main' of https://github.com/coder/coder into bq/support…
BrunoQuaresma 4cfba45
Update copy
BrunoQuaresma 53c282d
Move queries to queries folder
BrunoQuaresma cf79978
Move weekly and interval to search params
BrunoQuaresma 6d33f90
Move date range to search params
BrunoQuaresma 2cf5fc2
Merge branch 'main' of https://github.com/coder/coder into bq/support…
BrunoQuaresma 68b1067
Update site/src/pages/TemplatePage/TemplateInsightsPage/IntervalMenu.tsx
BrunoQuaresma 8a8453c
Update site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsig…
BrunoQuaresma 44f640b
Update site/src/pages/TemplatePage/TemplateInsightsPage/WeeklyPresets…
BrunoQuaresma 579b093
Apply Kayla improvement
BrunoQuaresma 0fe704e
Improve destructuring
BrunoQuaresma 932672a
Centralize date range value
BrunoQuaresma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add weekly control
- Loading branch information
commit a27af594196ac98648295bfeab0d8744ffa0072b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
site/src/pages/TemplatePage/TemplateInsightsPage/IntervalMenu.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import CheckOutlined from "@mui/icons-material/CheckOutlined"; | ||
import ExpandMoreOutlined from "@mui/icons-material/ExpandMoreOutlined"; | ||
import Box from "@mui/material/Box"; | ||
import Button from "@mui/material/Button"; | ||
import Menu from "@mui/material/Menu"; | ||
import MenuItem from "@mui/material/MenuItem"; | ||
import { useState, MouseEvent } from "react"; | ||
|
||
export const insightsIntervals = { | ||
day: { | ||
label: "Daily", | ||
}, | ||
week: { | ||
label: "Weekly", | ||
}, | ||
} as const; | ||
|
||
export type InsightsInterval = keyof typeof insightsIntervals; | ||
|
||
export const IntervalMenu = ({ | ||
value, | ||
onChange, | ||
}: { | ||
value: InsightsInterval; | ||
onChange: (value: InsightsInterval) => void; | ||
}) => { | ||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); | ||
const open = Boolean(anchorEl); | ||
const handleClick = (event: MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Button | ||
id="interval-button" | ||
Parkreiner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
aria-controls={open ? "interval-menu" : undefined} | ||
aria-haspopup="true" | ||
aria-expanded={open ? "true" : undefined} | ||
onClick={handleClick} | ||
endIcon={<ExpandMoreOutlined />} | ||
> | ||
{insightsIntervals[value].label} | ||
</Button> | ||
<Menu | ||
id="interval-menu" | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
MenuListProps={{ | ||
"aria-labelledby": "interval-button", | ||
}} | ||
> | ||
{Object.keys(insightsIntervals).map((interval) => { | ||
Parkreiner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { label } = insightsIntervals[interval as InsightsInterval]; | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<MenuItem | ||
css={{ fontSize: 14, justifyContent: "space-between" }} | ||
key={interval} | ||
onClick={() => { | ||
onChange(interval as InsightsInterval); | ||
handleClose(); | ||
}} | ||
> | ||
{label} | ||
<Box css={{ width: 16, height: 16 }}> | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{value === interval && ( | ||
<CheckOutlined css={{ width: 16, height: 16 }} /> | ||
)} | ||
</Box> | ||
</MenuItem> | ||
); | ||
})} | ||
</Menu> | ||
</div> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.