Skip to content

Commit 6f4fa15

Browse files
committed
fix coderabbit requested changes
1 parent 10295bd commit 6f4fa15

4 files changed

Lines changed: 41 additions & 11 deletions

File tree

apps/geolibre-desktop/src/components/layout/TopToolbar.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ export function TopToolbar({
10451045
// openSettingsSection. This toolbar owns the dialog + its kind state.
10461046
useEffect(() => {
10471047
const onOpenAddData = (event: Event) => {
1048+
// Read-only embeds must not open Add Data via the Browser panel event.
1049+
if (viewer) return;
10481050
const detail = (event as CustomEvent<OpenAddDataDetail>).detail;
10491051
// Reject kinds the Mac App Store build hides so a stray event cannot
10501052
// open a dialog whose backing service is compiled out.
@@ -1059,7 +1061,7 @@ export function TopToolbar({
10591061
};
10601062
window.addEventListener(OPEN_ADD_DATA_EVENT, onOpenAddData);
10611063
return () => window.removeEventListener(OPEN_ADD_DATA_EVENT, onOpenAddData);
1062-
}, []);
1064+
}, [viewer]);
10631065
// Deck.gl Layer kind the Add Data dialog opens on (e.g. the 3D-model entry
10641066
// jumps straight to the scenegraph layer type).
10651067
const [addDataDeckVizKind, setAddDataDeckVizKind] = useState<string | undefined>(undefined);
@@ -1579,7 +1581,7 @@ export function TopToolbar({
15791581
},
15801582
{
15811583
id: "view.comments",
1582-
title: "View Comments",
1584+
title: t("toolbar.command.viewComments"),
15831585
group: t("toolbar.commandGroup.view"),
15841586
keywords: "comments review threads notes annotations pins",
15851587
icon: MessageSquare,
@@ -2093,7 +2095,11 @@ export function TopToolbar({
20932095
aria-label={t("toolbar.item.projectName")}
20942096
className="hidden h-7 w-44 border-transparent px-2 text-xs shadow-none focus-visible:border-input md:block"
20952097
value={projectName}
2096-
onChange={(event) => setProjectName(event.target.value)}
2098+
readOnly={viewer}
2099+
onChange={(event) => {
2100+
if (viewer) return;
2101+
setProjectName(event.target.value);
2102+
}}
20972103
onKeyDown={(event) => {
20982104
if (
20992105
event.key === "Enter" &&
@@ -2110,6 +2116,7 @@ export function TopToolbar({
21102116
projectNameComposingRef.current = false;
21112117
}}
21122118
onBlur={(event) => {
2119+
if (viewer) return;
21132120
const nextName = event.target.value.trim();
21142121
// Persist the canonical, locale-independent default name; a
21152122
// translated string would otherwise be written into the saved

apps/geolibre-desktop/src/i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,7 @@
20952095
"resetPitch": "Reset Pitch",
20962096
"resetPitchBearing": "Reset Pitch & Bearing",
20972097
"setView": "Set View",
2098+
"viewComments": "View Comments",
20982099
"zoomIn": "Zoom In",
20992100
"zoomOut": "Zoom Out",
21002101
"switchToLight": "Switch to Light Mode",

packages/plugins/src/plugins/maplibre-dggal.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ function refresh(): void {
641641
updatePanelStatus();
642642
}
643643

644-
/** Update the status line without recreating the rest of the panel controls. */
644+
/** Update the status line (and auto-resolution readout) without recreating controls. */
645645
function updatePanelStatus(): void {
646646
const status = panelContainer?.querySelector<HTMLElement>("[data-dggal-status]");
647647
if (!status) {
@@ -650,6 +650,16 @@ function updatePanelStatus(): void {
650650
}
651651
status.textContent = currentError ?? labels.cellCount(currentGrid.features.length);
652652
status.style.color = currentError ? "#dc2626" : "";
653+
if (settings.autoResolution) {
654+
const shown = String(effectiveResolution());
655+
const resolution = panelContainer?.querySelector<HTMLInputElement>("[data-dggal-resolution]");
656+
const resolutionValue = panelContainer?.querySelector<HTMLElement>("[data-dggal-resolution-value]");
657+
if (resolution) {
658+
resolution.value = shown;
659+
resolution.title = shown;
660+
}
661+
if (resolutionValue) resolutionValue.textContent = shown;
662+
}
653663
}
654664

655665
/**
@@ -824,11 +834,11 @@ function renderPanel(container: HTMLElement): void {
824834
);
825835
row(labels.autoResolution, autoResolution);
826836

827-
// In automatic mode the slider becomes a read-only indicator of the
828-
// zoom-derived resolution; refresh() re-renders the panel on every moveend,
829-
// so it tracks zoom gestures.
837+
// In automatic mode the slider is a read-only indicator of the zoom-derived
838+
// resolution; updatePanelStatus() keeps it in sync on every moveend.
830839
const shownResolution = effectiveResolution();
831840
const resolution = document.createElement("input");
841+
resolution.dataset.dggalResolution = "";
832842
resolution.type = "range";
833843
resolution.min = "0";
834844
resolution.max = String(DGGAL_TYPES[settings.dggrsType]);
@@ -847,6 +857,7 @@ function renderPanel(container: HTMLElement): void {
847857
resolutionWrap.style.gap = "6px";
848858
resolutionWrap.style.opacity = settings.autoResolution ? "0.6" : "1";
849859
const resolutionValue = document.createElement("strong");
860+
resolutionValue.dataset.dggalResolutionValue = "";
850861
resolutionValue.textContent = String(shownResolution);
851862
resolution.addEventListener("input", () => {
852863
resolutionValue.textContent = resolution.value;

packages/plugins/src/plugins/maplibre-dggrid.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ function refresh(): void {
865865
updatePanelStatus();
866866
}
867867

868-
/** Update the status line without recreating the rest of the panel controls. */
868+
/** Update the status line (and auto-resolution readout) without recreating controls. */
869869
function updatePanelStatus(): void {
870870
const status = panelContainer?.querySelector<HTMLElement>("[data-dggrid-status]");
871871
if (!status) {
@@ -874,6 +874,16 @@ function updatePanelStatus(): void {
874874
}
875875
status.textContent = currentError ?? labels.cellCount(currentGrid.features.length);
876876
status.style.color = currentError ? "#dc2626" : "";
877+
if (settings.autoResolution) {
878+
const shown = String(effectiveResolution());
879+
const resolution = panelContainer?.querySelector<HTMLInputElement>("[data-dggrid-resolution]");
880+
const resolutionValue = panelContainer?.querySelector<HTMLElement>("[data-dggrid-resolution-value]");
881+
if (resolution) {
882+
resolution.value = shown;
883+
resolution.title = shown;
884+
}
885+
if (resolutionValue) resolutionValue.textContent = shown;
886+
}
877887
}
878888

879889
/**
@@ -1054,11 +1064,11 @@ function renderPanel(container: HTMLElement): void {
10541064
);
10551065
row(labels.autoResolution, autoResolution);
10561066

1057-
// In automatic mode the slider becomes a read-only indicator of the
1058-
// zoom-derived resolution; refresh() re-renders the panel on every moveend,
1059-
// so it tracks zoom gestures.
1067+
// In automatic mode the slider is a read-only indicator of the zoom-derived
1068+
// resolution; updatePanelStatus() keeps it in sync on every moveend.
10601069
const shownResolution = effectiveResolution();
10611070
const resolution = document.createElement("input");
1071+
resolution.dataset.dggridResolution = "";
10621072
resolution.type = "range";
10631073
resolution.min = "0";
10641074
resolution.max = String(MAX_DGGRID_RESOLUTION);
@@ -1077,6 +1087,7 @@ function renderPanel(container: HTMLElement): void {
10771087
resolutionWrap.style.gap = "6px";
10781088
resolutionWrap.style.opacity = settings.autoResolution ? "0.6" : "1";
10791089
const resolutionValue = document.createElement("strong");
1090+
resolutionValue.dataset.dggridResolutionValue = "";
10801091
resolutionValue.textContent = String(shownResolution);
10811092
resolution.addEventListener("input", () => {
10821093
resolutionValue.textContent = resolution.value;

0 commit comments

Comments
 (0)