Skip to content

Commit 288b47f

Browse files
committed
refactor: change user to can not remove dataAttribution
1 parent 48c7a8a commit 288b47f

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

  • web/src/classic/components/molecules/EarthEditor/LayerTreeViewItem

web/src/classic/components/molecules/EarthEditor/LayerTreeViewItem/Layer/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import HelpButton from "@reearth/classic/components/atoms/HelpButton";
55
import Icon from "@reearth/classic/components/atoms/Icon";
66
import Text from "@reearth/classic/components/atoms/Text";
77
import ToggleButton from "@reearth/classic/components/atoms/ToggleButton";
8+
import { DATAATTRIBUTION_BUILTIN_WIDGET_ID } from "@reearth/classic/components/molecules/Visualizer/Widget/builtin";
89
import { metricsSizes } from "@reearth/classic/theme";
910
import fonts from "@reearth/classic/theme/reearthTheme/common/fonts";
1011
import useDoubleClick from "@reearth/classic/util/use-double-click";
@@ -86,6 +87,7 @@ const Layer: React.ForwardRefRenderFunction<HTMLDivElement, Props> = (
8687
showLayerActions,
8788
actionItems,
8889
underlined,
90+
id,
8991
},
9092
expanded,
9193
selected,
@@ -132,6 +134,7 @@ const Layer: React.ForwardRefRenderFunction<HTMLDivElement, Props> = (
132134
const [handleClick, handleDoubleClick] = useDoubleClick(onClick, startEditing);
133135

134136
const theme = useTheme();
137+
const isDataAttribution = id?.includes(DATAATTRIBUTION_BUILTIN_WIDGET_ID);
135138

136139
return (
137140
<Wrapper
@@ -217,7 +220,7 @@ const Layer: React.ForwardRefRenderFunction<HTMLDivElement, Props> = (
217220
/>
218221
</HideableDiv>
219222
)}
220-
{deactivated !== undefined && (
223+
{deactivated !== undefined && !isDataAttribution && (
221224
<HideableDiv isVisible={isHover || selected} onClick={handleActivationChange}>
222225
<ToggleButton size="sm" checked={!deactivated} parentSelected={selected} />
223226
</HideableDiv>

web/src/classic/components/molecules/EarthEditor/LayerTreeViewItem/LayerActionsList/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import HelpButton from "@reearth/classic/components/atoms/HelpButton";
77
import Icon from "@reearth/classic/components/atoms/Icon";
88
import Text from "@reearth/classic/components/atoms/Text";
99
import { Layer } from "@reearth/classic/components/molecules/EarthEditor/LayerTreeViewItem/Layer";
10+
import { DATAATTRIBUTION_BUILTIN_WIDGET_ID } from "@reearth/classic/components/molecules/Visualizer/Widget/builtin";
1011
import { metricsSizes } from "@reearth/classic/theme";
1112
import { useT } from "@reearth/services/i18n";
1213
import { styled } from "@reearth/services/theme";
@@ -49,17 +50,22 @@ const LayerActionsList: React.FC<Props> = ({
4950

5051
useClickAway(wrapperRef, () => setVisibleMenu(false));
5152

53+
const isDataAttribution = selectedLayerId?.includes(DATAATTRIBUTION_BUILTIN_WIDGET_ID);
54+
5255
return (
5356
<ActionWrapper
5457
ref={wrapperRef}
5558
onClick={e => {
5659
e.stopPropagation();
5760
}}>
5861
<Action
59-
disabled={!selectedLayerId}
60-
onClick={() => onWarning?.(true) ?? (selectedLayerId && onRemove?.(selectedLayerId))}>
62+
disabled={!selectedLayerId || isDataAttribution}
63+
onClick={() =>
64+
onWarning?.(true) ??
65+
(selectedLayerId && !isDataAttribution && onRemove?.(selectedLayerId))
66+
}>
6167
<HelpButton descriptionTitle={t("Delete the selected item.")} balloonDirection="top">
62-
<StyledIcon icon="bin" size={16} disabled={!selectedLayerId} />
68+
<StyledIcon icon="bin" size={16} disabled={!selectedLayerId || isDataAttribution} />
6369
</HelpButton>
6470
</Action>
6571
<Action ref={referenceElement} onClick={() => setVisibleMenu(!visibleMenu)}>

0 commit comments

Comments
 (0)