Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add "Outdated" tooltip and "Update version" button in the Workspaces page#2322

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 7 commits intomainfrombq/add-outdated-tooltip
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionssite/src/components/GlobalSnackbar/GlobalSnackbar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ export const GlobalSnackbar: React.FC = () => {

return (
<EnterpriseSnackbar
key={notification.msg}
open={open}
variant={variantFromMsgType(notification.msgType)}
message={
Expand Down
77 changes: 69 additions & 8 deletionssite/src/components/HelpTooltip/HelpTooltip.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,35 +3,58 @@ import Popover from "@material-ui/core/Popover"
import { makeStyles } from "@material-ui/core/styles"
import HelpIcon from "@material-ui/icons/HelpOutline"
import OpenInNewIcon from "@material-ui/icons/OpenInNew"
import{ useState } from "react"
importReact, { createContext, useContext, useState } from "react"
import { Stack } from "../Stack/Stack"

type Icon = typeof HelpIcon

type Size = "small" | "medium"
export interface HelpTooltipProps {
// Useful to test on storybook
open?: boolean
size?: Size
}

const HelpTooltipContext = createContext<{ open: boolean; onClose: () => void } | undefined>(undefined)

const useHelpTooltip = () => {
const helpTooltipContext = useContext(HelpTooltipContext)

if (!helpTooltipContext) {
throw new Error("This hook should be used in side of the HelpTooltipContext.")
Copy link
Member

Choose a reason for hiding this comment

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

❤️

BrunoQuaresma reacted with heart emoji
}

return helpTooltipContext
}

export const HelpTooltip: React.FC<HelpTooltipProps> = ({ children, open, size = "medium" }) => {
const styles = useStyles({ size })
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null)
open = open ?? Boolean(anchorEl)
const id = open ? "help-popover" : undefined

const onClose = () => {
setAnchorEl(null)
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems like when I click to escape the tooltip, regardless of where I click, I am automatically routed to the workspace page. Sometimes I just want to close the tooltip without leaving the list. Could we suppress navigation on close?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

I think it is because you are clicking on a workspace row when you click outside of the tooltip.

Copy link
Member

@Kira-PilotKira-PilotJun 15, 2022
edited
Loading

Choose a reason for hiding this comment

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

It does it even if I click somewhere else on the page. I think it is using the initial click into the tooltip to navigate.


return (
<>
<button aria-describedby={id} className={styles.button} onClick={(event) => setAnchorEl(event.currentTarget)}>
<button
aria-describedby={id}
className={styles.button}
onClick={(event) => {
event.stopPropagation()
setAnchorEl(event.currentTarget)
}}
>
<HelpIcon className={styles.icon} />
</button>
<Popover
classes={{ paper: styles.popoverPaper }}
id={id}
open={open}
anchorEl={anchorEl}
onClose={() => {
setAnchorEl(null)
}}
onClose={onClose}
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
Expand All@@ -41,7 +64,7 @@ export const HelpTooltip: React.FC<HelpTooltipProps> = ({ children, open, size =
horizontal: "left",
}}
>
{children}
<HelpTooltipContext.Provider value={{ open, onClose }}>{children}</HelpTooltipContext.Provider>
</Popover>
</>
)
Expand DownExpand Up@@ -70,6 +93,25 @@ export const HelpTooltipLink: React.FC<{ href: string }> = ({ children, href })
)
}

export const HelpTooltipAction: React.FC<{ icon: Icon; onClick: () => void }> = ({ children, icon: Icon, onClick }) => {
const styles = useStyles()
const tooltip = useHelpTooltip()

return (
<button
className={styles.action}
onClick={(event) => {
event.stopPropagation()
onClick()
tooltip.onClose()
}}
>
<Icon className={styles.actionIcon} />
{children}
</button>
)
}

export const HelpTooltipLinksGroup: React.FC = ({ children }) => {
const styles = useStyles()

Expand DownExpand Up@@ -110,11 +152,12 @@ const useStyles = makeStyles((theme) => ({
padding: 0,
border: 0,
background: "transparent",
color: theme.palette.text.secondary,
color: theme.palette.text.primary,
opacity: 0.5,
cursor: "pointer",

"&:hover": {
color: theme.palette.text.primary,
opacity: 0.75,
},
},

Expand DownExpand Up@@ -156,4 +199,22 @@ const useStyles = makeStyles((theme) => ({
linksGroup: {
marginTop: theme.spacing(2),
},

action: {
display: "flex",
alignItems: "center",
background: "none",
border: 0,
color: theme.palette.primary.light,
padding: 0,
cursor: "pointer",
fontSize: 14,
},

actionIcon: {
color: "inherit",
width: 14,
height: 14,
marginRight: theme.spacing(1),
},
}))
5 changes: 3 additions & 2 deletionssite/src/pages/WorkspacesPage/WorkspacesPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,13 +10,14 @@ import { WorkspacesPageView } from "./WorkspacesPageView"
const WorkspacesPage: FC = () => {
const [workspacesState, send] = useMachine(workspacesMachine)
const [searchParams, setSearchParams] = useSearchParams()
const { workspaceRefs } = workspacesState.context

useEffect(() => {
const filter = searchParams.get("filter")
const query = filter !== null ? filter : workspaceFilterQuery.me

send({
type: "SET_FILTER",
type: "GET_WORKSPACES",
query,
})
}, [searchParams, send])
Expand All@@ -30,7 +31,7 @@ const WorkspacesPage: FC = () => {
<WorkspacesPageView
filter={workspacesState.context.filter}
loading={workspacesState.hasTag("loading")}
workspaces={workspacesState.context.workspaces}
workspaceRefs={workspaceRefs}
onFilter={(query) => {
searchParams.set("filter", query)
setSearchParams(searchParams)
Expand Down
19 changes: 15 additions & 4 deletionssite/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
import { ComponentMeta, Story } from "@storybook/react"
import { spawn } from "xstate"
import { ProvisionerJobStatus, Workspace, WorkspaceTransition } from "../../api/typesGenerated"
import { MockWorkspace } from "../../testHelpers/entities"
import { workspaceFilterQuery } from "../../util/workspace"
import { workspaceItemMachine } from "../../xServices/workspaces/workspacesXService"
import { WorkspacesPageView, WorkspacesPageViewProps } from "./WorkspacesPageView"

export default {
Expand All@@ -14,9 +16,11 @@ const Template: Story<WorkspacesPageViewProps> = (args) => <WorkspacesPageView {
const createWorkspaceWithStatus = (
status: ProvisionerJobStatus,
transition: WorkspaceTransition = "start",
outdated = false,
): Workspace => {
return {
...MockWorkspace,
outdated,
latest_build: {
...MockWorkspace.latest_build,
transition,
Expand All@@ -41,22 +45,29 @@ const workspaces: { [key in ProvisionerJobStatus]: Workspace } = {

export const AllStates = Template.bind({})
AllStates.args = {
workspaces: [
workspaceRefs: [
...Object.values(workspaces),
createWorkspaceWithStatus("running", "stop"),
createWorkspaceWithStatus("succeeded", "stop"),
createWorkspaceWithStatus("running", "delete"),
],
].map((data) => spawn(workspaceItemMachine.withContext({ data }))),
}

export const Outdated = Template.bind({})
Outdated.args = {
workspaceRefs: [createWorkspaceWithStatus("running", "stop", true)].map((data) =>
spawn(workspaceItemMachine.withContext({ data })),
),
}

export const OwnerHasNoWorkspaces = Template.bind({})
OwnerHasNoWorkspaces.args = {
workspaces: [],
workspaceRefs: [],
filter: workspaceFilterQuery.me,
}

export const NoResults = Template.bind({})
NoResults.args = {
workspaces: [],
workspaceRefs: [],
filter: "searchtearmwithnoresults",
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp