-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add requested copy changes #26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import React, { | |
useContext, | ||
useState, | ||
} from 'react'; | ||
|
||
import { makeStyles } from '@material-ui/core'; | ||
import { useId } from '../../hooks/hookPolyfills'; | ||
import { UseQueryResult } from '@tanstack/react-query'; | ||
import { | ||
|
@@ -16,6 +16,7 @@ import type { Workspace } from '../../typesConstants'; | |
import { useCoderWorkspaces } from '../../hooks/useCoderWorkspaces'; | ||
import { Card } from '../Card'; | ||
import { CoderAuthWrapper } from '../CoderAuthWrapper'; | ||
import { VisuallyHidden } from '../VisuallyHidden'; | ||
import { type CoderWorkspaceConfig, useCoderAppConfig } from '../CoderProvider'; | ||
|
||
type WorkspacesCardContext = Readonly<{ | ||
|
@@ -29,6 +30,22 @@ type WorkspacesCardContext = Readonly<{ | |
|
||
const CardContext = createContext<WorkspacesCardContext | null>(null); | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
button: { | ||
color: theme.palette.type, | ||
backgroundColor: theme.palette.background.paper, | ||
border: 'none', | ||
paddingTop: theme.spacing(2), | ||
fontSize: theme.typography.body2.fontSize, | ||
cursor: 'pointer', | ||
}, | ||
|
||
snippet: { | ||
backgroundColor: theme.palette.grey[100], | ||
borderRadius: '0.4em', | ||
}, | ||
})); | ||
|
||
export type WorkspacesCardProps = Readonly< | ||
Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'aria-labelledby'> & { | ||
queryFilter?: string; | ||
|
@@ -47,15 +64,23 @@ export const Root = ({ | |
readEntityData = false, | ||
...delegatedProps | ||
}: WorkspacesCardProps) => { | ||
const styles = useStyles(); | ||
const hookId = useId(); | ||
const appConfig = useCoderAppConfig(); | ||
const [innerFilter, setInnerFilter] = useState(defaultQueryFilter); | ||
const activeFilter = outerFilter ?? innerFilter; | ||
|
||
const [isExpanded, setIsExpanded] = useState(false); | ||
const toggleExpansion = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
const dynamicConfig = useDynamicEntityConfig(readEntityData); | ||
const workspacesQuery = useCoderWorkspaces(activeFilter, { | ||
repoConfig: dynamicConfig, | ||
}); | ||
const showEntityDataReminder = | ||
workspacesQuery.data && dynamicConfig && !dynamicConfig.repoUrl; | ||
|
||
const headerId = `${hookId}-header`; | ||
const activeConfig = { | ||
|
@@ -94,6 +119,36 @@ export const Root = ({ | |
cases around keyboard input and button children that native <form> | ||
elements automatically introduce */} | ||
<div role="form">{children}</div> | ||
{showEntityDataReminder && ( | ||
<div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can fine-tune the markup after launch, but I think we do want to structure this as a disclosure component, using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting - happy to come back to this! |
||
<button | ||
onClick={toggleExpansion} | ||
type="button" | ||
className={styles.button} | ||
> | ||
{isExpanded ? '▼' : '►'}{' '} | ||
{isExpanded ? 'Hide text' : 'Why am I seeing all workspaces?'} | ||
</button> | ||
{isExpanded && ( | ||
<p> | ||
This component displays all workspaces when the entity has no | ||
repo URL to filter by. Consider disabling{' '} | ||
<code className={styles.snippet}>readEntityData</code>; | ||
details in our{' '} | ||
<a | ||
href="https://github.com/coder/backstage-plugins/blob/main/plugins/backstage-plugin-coder/docs/components.md#notes-4" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
style={{ textDecoration: 'underline', color: 'inherit' }} | ||
> | ||
docs | ||
<VisuallyHidden> (link opens in new tab)</VisuallyHidden> | ||
</a> | ||
. | ||
</p> | ||
)} | ||
</div> | ||
)} | ||
</Card> | ||
</CardContext.Provider> | ||
</CoderAuthWrapper> | ||
|
Uh oh!
There was an error while loading. Please reload this page.