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

feat(react-components): remove all URL-mutations #4739

Merged
merged 11 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { LayersButton } from './LayersButton';
import { SlicerButton } from './SlicerButton';
import { SettingsButton } from './SettingsButton';
import { withSuppressRevealEvents } from '../../higher-order-components/withSuppressRevealEvents';
import { MeasurementButton } from './MeasurementButton';
import { HelpButton } from './HelpButton';
import { ShareButton } from './ShareButton';
import { ResetCameraButton } from './ResetCameraButton';
Expand Down Expand Up @@ -51,8 +50,7 @@ const DefaultContentWrapper = (props: CustomToolbarContent): ReactElement => {
<RuleBasedOutputsButton />
<Divider weight="2px" length="75%" />

<SlicerButton storeStateInUrl={props.storeStateInUrl} />
<MeasurementButton />
<SlicerButton />

<Divider weight="2px" length="75%" />

Expand Down Expand Up @@ -105,7 +103,6 @@ export const RevealToolbar = withSuppressRevealEvents(
FitModelsButton: typeof FitModelsButton;
SlicerButton: typeof SlicerButton;
LayersButton: typeof LayersButton;
MeasurementButton: typeof MeasurementButton;
ShareButton: typeof ShareButton;
SettingsButton: typeof SettingsButton;
HelpButton: typeof HelpButton;
Expand All @@ -120,7 +117,6 @@ export const RevealToolbar = withSuppressRevealEvents(
RevealToolbar.FitModelsButton = FitModelsButton;
RevealToolbar.SlicerButton = SlicerButton;
RevealToolbar.LayersButton = LayersButton;
RevealToolbar.MeasurementButton = MeasurementButton;
RevealToolbar.ShareButton = ShareButton;
RevealToolbar.SettingsButton = SettingsButton;
RevealToolbar.HelpButton = HelpButton;
Expand Down
20 changes: 2 additions & 18 deletions react-components/src/components/RevealToolbar/SlicerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useReveal } from '../RevealCanvas/ViewerContext';
import { Button, Dropdown, Menu, RangeSlider, Tooltip as CogsTooltip } from '@cognite/cogs.js';

import styled from 'styled-components';
import { useSlicerUrlParams } from './hooks/useUrlStateParam';
import { useTranslation } from '../i18n/I18n';
import { use3dModels } from '../../hooks/use3dModels';

Expand All @@ -21,18 +20,11 @@ type SliceState = {
bottomRatio: number;
};

type SlicerButtonProps = {
storeStateInUrl?: boolean;
};

export const SlicerButton = ({ storeStateInUrl = true }: SlicerButtonProps): ReactElement => {
export const SlicerButton = (): ReactElement => {
const viewer = useReveal();
const { t } = useTranslation();
const models = use3dModels();
const [slicerUrlState, setSlicerUrlState] = useSlicerUrlParams();
const { bottom: initialBottomRatio, top: initialTopRatio } = storeStateInUrl
? slicerUrlState
: { bottom: 0, top: 1 };
const { bottom: initialBottomRatio, top: initialTopRatio } = { bottom: 0, top: 1 };
const [sliceActive, setSliceActive] = useState<boolean>(false);

const [sliceState, setSliceState] = useState<SliceState>({
Expand All @@ -58,10 +50,6 @@ export const SlicerButton = ({ storeStateInUrl = true }: SlicerButtonProps): Rea
if (maxHeight !== newMaxY || minHeight !== newMinY) {
// Set clipping plane only if top or bottom has changed & storeStateInUrl is enabled

if (storeStateInUrl && (bottomRatio !== 0 || topRatio !== 1)) {
setGlobalPlanes(bottomRatio, topRatio, newMaxY, newMinY);
}

setSliceState({
maxHeight: newMaxY,
minHeight: newMinY,
Expand All @@ -80,10 +68,6 @@ export const SlicerButton = ({ storeStateInUrl = true }: SlicerButtonProps): Rea
bottomRatio: newValues[0],
topRatio: newValues[1]
});

if (storeStateInUrl) {
setSlicerUrlState(newValues);
}
}

function setGlobalPlanes(
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading