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

fix(garden): 🐛 added condition for rendering of viewsettings #581

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/garden/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-garden",
"version": "7.0.0",
"version": "7.0.1",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
14 changes: 5 additions & 9 deletions packages/garden/src/lib/components/Garden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function Garden<TData extends Record<PropertyKey, unknown>, TContext = un
}: GardenProps<TData, TContext>): JSX.Element | null {
const client = useRef(new QueryClient());
const [groupingKeys, setGroupingKeys] = useState<string[]>(initialGrouping);

const [isLoading, setIsLoading] = useState(true);
const [timeInterval, updateTimeInterval] = useState<string | null>(initialTimeInterval ?? null);
const onChangetimeInterval = (timeInterval: string | null) => {
updateTimeInterval(timeInterval);
Expand Down Expand Up @@ -116,12 +116,8 @@ export function Garden<TData extends Record<PropertyKey, unknown>, TContext = un
customViews={customViews}
visuals={visuals}
>
<VirtualContainer context={context as TContext} dataSource={dataSource} />
</GardenConfigProvider>

{
// Hides ViewSettings sidebar when sidesheet is open
selected ? null : (
<VirtualContainer context={context as TContext} dataSource={dataSource} setIsLoading={setIsLoading} />
{selected || isLoading ? null : (
<ViewSettings
dateVariant={dateVariant}
groupingKeys={groupingKeys}
Expand All @@ -130,8 +126,8 @@ export function Garden<TData extends Record<PropertyKey, unknown>, TContext = un
onChangeTimeInterval={onChangetimeInterval}
setGroupingKeys={setGroupingKeys}
/>
)
}
)}
</GardenConfigProvider>
</GardenContextProvider>
</Suspense>
</ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { Icon } from '@equinor/eds-core-react';
import { info_circle } from '@equinor/eds-icons';
import { useEffect } from 'react';
import styled from 'styled-components';
import { useItemWidths } from '../../hooks';
import { useGarden } from '../../hooks/useGarden';
import { useGardenConfig } from '../../hooks/useGardenConfig';
import { ExpandProvider } from '../ExpandProvider';
import { GardenDataSource } from '../Garden';
import { VirtualGarden } from '../VirtualGarden';
import { StyledVirtualContainer } from './virtualContainer.styles';
import { info_circle } from '@equinor/eds-icons';
import { Icon } from '@equinor/eds-core-react';
import styled from 'styled-components';
import { SplashScreen } from '../splashScreen/SplashScreen';
import { StyledVirtualContainer } from './virtualContainer.styles';
Icon.add({ info_circle });

type VirtualContainerProps<TContext = undefined> = {
dataSource: GardenDataSource<TContext>;
context: TContext;
setIsLoading: (isLoading: boolean) => void;
};

export const VirtualContainer = <TContext,>({
dataSource,
context,
setIsLoading,
}: VirtualContainerProps<TContext>): JSX.Element | null => {
const { onClickItem } = useGardenConfig();
const { gardenMetaQuery } = useGarden();
Expand All @@ -27,6 +30,10 @@ export const VirtualContainer = <TContext,>({
return <SplashScreen />;
}

useEffect(() => {
if (!gardenMetaQuery.isLoading) setIsLoading(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should have just lifted the useGarden call up one level?

}, [gardenMetaQuery.isLoading]);

if (!gardenMetaQuery.data) {
// Will never happen when suspense is true
throw new Error();
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace-fusion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-fusion",
"version": "7.0.3",
"version": "7.0.4",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
Loading