Skip to content

Commit

Permalink
fix various react errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman committed Sep 18, 2024
1 parent 65eab4f commit 7d61b53
Show file tree
Hide file tree
Showing 12 changed files with 311 additions and 357 deletions.
14 changes: 7 additions & 7 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"@graphql-codegen/named-operations-object": "3.0.0",
"@jumpn/utils-graphql": "0.6.0",
"@markdoc/markdoc": "0.4.0",
"@nivo/core": "0.83.0",
"@nivo/geo": "0.83.0",
"@nivo/line": "0.83.0",
"@nivo/pie": "0.83.0",
"@nivo/radial-bar": "0.83.0",
"@nivo/tooltip": "0.83.0",
"@pluralsh/design-system": "3.67.1",
"@nivo/core": "0.87.0",
"@nivo/geo": "0.87.0",
"@nivo/line": "0.87.0",
"@nivo/pie": "0.87.0",
"@nivo/radial-bar": "0.87.0",
"@nivo/tooltip": "0.87.0",
"@pluralsh/design-system": "3.67.2",
"@react-hooks-library/core": "0.6.0",
"@saas-ui/use-hotkeys": "1.1.3",
"@tanstack/react-virtual": "3.0.1",
Expand Down
49 changes: 22 additions & 27 deletions assets/src/components/cd/cluster/node/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,33 +104,28 @@ export default function Node() {
})

return (
<TabPanel
stateRef={tabStateRef}
as={
<ResponsivePageFullWidth
scrollable={
(currentTab?.label ?? 'Info') === 'Info' ||
currentTab?.label === 'Metadata'
}
heading={name}
headingContent={
<HeadingTabList
tabStateRef={tabStateRef}
currentTab={currentTab}
/>
}
// eslint-disable-next-line react/no-children-prop
children={
<Outlet
context={{
node: data?.node,
nodeMetric: nodeMetricData?.nodeMetric,
refetch,
}}
/>
}
<TabPanel stateRef={tabStateRef}>
<ResponsivePageFullWidth
scrollable={
(currentTab?.label ?? 'Info') === 'Info' ||
currentTab?.label === 'Metadata'
}
heading={name}
headingContent={
<HeadingTabList
tabStateRef={tabStateRef}
currentTab={currentTab}
/>
}
>
<Outlet
context={{
node: data?.node,
nodeMetric: nodeMetricData?.nodeMetric,
refetch,
}}
/>
}
/>
</ResponsivePageFullWidth>
</TabPanel>
)
}
3 changes: 3 additions & 0 deletions assets/src/components/cd/utils/PermissionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export function PermissionsModal({
formProps={{ onSubmit }}
size="custom"
css={{ width: 1024, maxWidth: 1024 }}
onOpenAutoFocus={(e) => {
e.preventDefault()
}}
actions={
<div
css={{
Expand Down
37 changes: 17 additions & 20 deletions assets/src/components/cluster/nodes/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,22 @@ export default function Node() {
}, [name, setBreadcrumbs])

return (
<TabPanel
stateRef={tabStateRef}
as={
<ResponsivePageFullWidth
scrollable={
(currentTab?.label ?? 'Info') === 'Info' ||
currentTab?.label === 'Metadata'
}
heading={name}
headingContent={
<HeadingTabList
tabStateRef={tabStateRef}
currentTab={currentTab}
/>
}
// eslint-disable-next-line react/no-children-prop
children={<Outlet />}
/>
}
/>
<TabPanel stateRef={tabStateRef}>
<ResponsivePageFullWidth
scrollable={
(currentTab?.label ?? 'Info') === 'Info' ||
currentTab?.label === 'Metadata'
}
heading={name}
headingContent={
<HeadingTabList
tabStateRef={tabStateRef}
currentTab={currentTab}
/>
}
>
<Outlet />
</ResponsivePageFullWidth>
</TabPanel>
)
}
6 changes: 4 additions & 2 deletions assets/src/components/component/ComponentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ export function ComponentDetails({
</div>
)}
<TabPanel
as={<Outlet context={outletContext} />}
css={{ display: 'contents' }}
stateRef={tabStateRef}
/>
>
<Outlet context={outletContext} />
</TabPanel>
</ResponsivePageFullWidth>
)
}
6 changes: 3 additions & 3 deletions assets/src/components/kubernetes/network/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export function TableEndpoints({
}) {
return endpoints.map((endpoint) =>
isEmpty(endpoint?.ports) ? (
<TableText>{endpoint?.host}</TableText>
<TableText key={endpoint?.host}>{endpoint?.host}</TableText>
) : (
<div>
<div key={endpoint?.host}>
{endpoint?.ports.map((port) => (
<TableText>
<TableText key={`${endpoint?.host}-${port?.port}-${port?.protocol}`}>
{endpoint?.host}:{port?.port ?? port?.nodePort} {port?.protocol}
</TableText>
))}
Expand Down
6 changes: 2 additions & 4 deletions assets/src/components/policies/PoliciesFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ function PoliciesFilter({
No kind
</Checkbox>
{kinds?.map((kind) => (
<CheckboxWrapperSC>
<CheckboxWrapperSC key={kind.id}>
<Checkbox
key={kind.id}
name="kinds"
value={kind.id}
checked={selectedKinds.includes(kind.id)}
Expand Down Expand Up @@ -177,9 +176,8 @@ function PoliciesFilter({
No namespace
</Checkbox>
{namespaces?.map((namespace) => (
<CheckboxWrapperSC>
<CheckboxWrapperSC key={namespace.id}>
<Checkbox
key={namespace.id}
name={namespaceLabel}
value={namespace}
checked={selectedNamespaces.includes(namespace.id)}
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/utils/Chloropleth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function Chloropleth({ data }) {
return (
<ResponsiveChoropleth
data={data}
theme={{ textColor: theme.colors.text }}
theme={{ text: { fill: theme.colors.text } }}
features={countries.features}
label="properties.name"
valueFormat=".2s"
Expand Down
5 changes: 4 additions & 1 deletion assets/src/components/utils/ModalMountTransition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ time it opens/closes.
*/

import { usePrevious } from '@pluralsh/design-system'
import { ReactElement, useLayoutEffect, useState } from 'react'
import { ReactElement, useLayoutEffect, useRef, useState } from 'react'
import { Transition, TransitionGroup } from 'react-transition-group'

export function ModalMountTransition({
Expand All @@ -21,6 +21,8 @@ export function ModalMountTransition({
}) {
const wasOpen = usePrevious(open)
const [counter, setCounter] = useState(0)
// this doesn't actually do anything, just to prevent TransitionGroup from using deprecated findDOMNode
const nodeRef = useRef(null)

useLayoutEffect(() => {
if (open && !wasOpen) {
Expand All @@ -33,6 +35,7 @@ export function ModalMountTransition({
<TransitionGroup css={{ display: 'none' }}>
{open || wasOpen ? (
<Transition
nodeRef={nodeRef}
key={key}
mountOnEnter
unmountOnExit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Flex } from 'honorable'
import { Ref, forwardRef } from 'react'

export const RESPONSIVE_LAYOUT_CONTENT_WIDTH = 896

export function ResponsiveLayoutContentContainer(props: any) {
function ResponsiveLayoutContentContainerRef(
props: any,
ref: Ref<HTMLDivElement>
) {
return (
<Flex
ref={ref}
direction="column"
flexGrow={1}
flexShrink={1}
Expand All @@ -19,3 +24,7 @@ export function ResponsiveLayoutContentContainer(props: any) {
/>
)
}

export const ResponsiveLayoutContentContainer = forwardRef(
ResponsiveLayoutContentContainerRef
)
22 changes: 15 additions & 7 deletions assets/src/components/utils/layout/ResponsivePageFullWidth.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentProps } from 'react'
import { ComponentProps, Ref, forwardRef } from 'react'
import styled from 'styled-components'

import { ResponsiveLayoutPage } from 'components/utils/layout/ResponsiveLayoutPage'
Expand All @@ -17,13 +17,19 @@ const ResponsivePageFullWidthSC = styled(ResponsiveLayoutPage)<{
: {}),
}))

export function ResponsivePageFullWidth({
scrollable = true,
children,
...props
}: ComponentProps<typeof ScrollablePage>) {
function ResponsivePageFullWidthRef(
{
scrollable = true,
children,
...props
}: ComponentProps<typeof ResponsivePageFullWidthSC>,
ref: Ref<HTMLDivElement>
) {
return (
<ResponsivePageFullWidthSC $scrollable={scrollable}>
<ResponsivePageFullWidthSC
$scrollable={scrollable}
ref={ref}
>
<ScrollablePage
scrollable={scrollable}
fullWidth
Expand All @@ -34,3 +40,5 @@ export function ResponsivePageFullWidth({
</ResponsivePageFullWidthSC>
)
}

export const ResponsivePageFullWidth = forwardRef(ResponsivePageFullWidthRef)
Loading

0 comments on commit 7d61b53

Please sign in to comment.