Skip to content
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
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ updates:
- version-update:semver-minor
- version-update:semver-major
# @wordpress/scripts@31.x requires @wordpress/env@^10.0.0; unblock when scripts supports v11
- dependency-name: "@wordpress/env"
versions: [">=11"]
- dependency-name: '@wordpress/env'
versions: ['>=11']

- package-ecosystem: composer
directory: /
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,3 @@ jobs:
SPOTMAP_TOKEN_LINZ: ${{ secrets.SPOTMAP_TOKEN_LINZ }}
SPOTMAP_TOKEN_GEOPORTAIL: ${{ secrets.SPOTMAP_TOKEN_GEOPORTAIL }}
SPOTMAP_TOKEN_OSDATAHUB: ${{ secrets.SPOTMAP_TOKEN_OSDATAHUB }}

2 changes: 1 addition & 1 deletion .github/workflows/deploy_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release & Deploy

on:
workflow_run:
workflows: ["CI"]
workflows: ['CI']
types: [completed]
branches: [main]
workflow_dispatch:
Expand Down
36 changes: 24 additions & 12 deletions src/map-engine/MarkerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ export class MarkerManager {
const content = container.querySelector(
'.leaflet-popup-content'
);
if ( ! content || content.querySelector( '.spotmap-popup-nav' ) ) return;
if (
! content ||
content.querySelector( '.spotmap-popup-nav' )
)
return;
const nav = document.createElement( 'div' );
nav.className = 'spotmap-popup-nav';
nav.style.cssText =
Expand Down Expand Up @@ -210,9 +214,9 @@ export class MarkerManager {
}
};

const imgs = Array.from( container.querySelectorAll( 'img' ) ).filter(
( img ) => ! img.complete
);
const imgs = Array.from(
container.querySelectorAll( 'img' )
).filter( ( img ) => ! img.complete );
if ( imgs.length === 0 ) {
injectNav();
requestAnimationFrame( doPan );
Expand All @@ -226,20 +230,28 @@ export class MarkerManager {
if ( loaded === imgs.length ) {
// Reposition the tip without replacing content
// (popup.update() would wipe our injected nav).
( popup as unknown as { _updatePosition?: () => void } )._updatePosition?.();
(
popup as unknown as {
_updatePosition?: () => void;
}
)._updatePosition?.();
injectNav();
requestAnimationFrame( doPan );
}
},
{ once: true }
);
img.addEventListener(
'error',
() => {
loaded++;
if ( loaded === imgs.length ) {
injectNav();
requestAnimationFrame( doPan );
}
},
{ once: true }
);
img.addEventListener( 'error', () => {
loaded++;
if ( loaded === imgs.length ) {
injectNav();
requestAnimationFrame( doPan );
}
}, { once: true } );
} );
}
} );
Expand Down
8 changes: 6 additions & 2 deletions src/map-engine/Spotmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ export class Spotmap {
// circle-dot markers render above polylines. Avoids theme CSS targeting
// .leaflet-marker-pane which can set the SVG to 0×0.
this.map.createPane( 'spotmapCirclePane' );
( this.map.getPane( 'spotmapCirclePane' ) as HTMLElement ).style.zIndex = '450';
(
this.map.getPane( 'spotmapCirclePane' ) as HTMLElement
).style.zIndex = '450';
const canvasRenderer = L.svg( { pane: 'spotmapCirclePane' } );
this.markerManager = new MarkerManager(
this.map,
Expand Down Expand Up @@ -510,7 +512,9 @@ export class Spotmap {
icon,
zIndexOffset: Z_INDEX_LAST_POINT,
} )
.bindPopup( MarkerManager.getPopupHtml( lp, this.options.feeds.length ) )
.bindPopup(
MarkerManager.getPopupHtml( lp, this.options.feeds.length )
)
.addTo( feed.featureGroup );
}

Expand Down
4 changes: 2 additions & 2 deletions src/map-engine/__tests__/MarkerManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe( 'MarkerManager.getPopupHtml', () => {
expect( html ).not.toContain( '<img' );
} );

it( 'shows battery warning when status is LOW', () => {
it( 'shows battery warning when status is LOW', () => {
const html = MarkerManager.getPopupHtml(
makePoint( { battery_status: 'LOW' } )
);
Expand Down Expand Up @@ -174,7 +174,7 @@ describe( 'MarkerManager instance', () => {
markerMock.marker.mock.results[ 0 ].value as {
bindPopup: jest.Mock;
}
).bindPopup.mock.calls[ 0 ][ 0 ] as string;
).bindPopup.mock.calls[ 0 ][ 0 ] as string;
expect( bindPopupCall ).toContain( 'OK' );
} );
} );
1 change: 0 additions & 1 deletion src/map-engine/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ declare global {
};
polyline_options?: L.PolylineOptions;
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions src/map-engine/popup-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export function buildView( entry: SpotPoint, feedCount = 1 ): PopupView {
if ( entry.type === 'POST' ) {
return {
imageUrl: entry.image_url,
linkedTitle: entry.url ? ( entry.message ?? 'Post' ) : undefined,
linkedTitle: entry.url ? entry.message ?? 'Post' : undefined,
url: entry.url,
plainTitle: entry.url ? undefined : ( entry.message ?? 'Post' ),
plainTitle: entry.url ? undefined : entry.message ?? 'Post',
excerpt: entry.excerpt,
date: entry.date,
};
Expand Down
4 changes: 1 addition & 3 deletions src/spotmap-admin/components/FeedsToolbarGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ export default function FeedsToolbarGroup( {
{ onStyle && (
<Button
icon={ brush }
label={
__( 'Style' ) + ' ' + feed
}
label={ __( 'Style' ) + ' ' + feed }
size="small"
variant="tertiary"
style={ {
Expand Down
7 changes: 6 additions & 1 deletion src/spotmap-admin/components/ProviderSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ const PROVIDER_ICONS = {
// Tile grid
// ---------------------------------------------------------------------------

export default function ProviderSelector( { providers, value, onChange, disabledTypes = [] } ) {
export default function ProviderSelector( {
providers,
value,
onChange,
disabledTypes = [],
} ) {
const entries = Object.entries( providers );

return (
Expand Down
9 changes: 3 additions & 6 deletions src/spotmap-admin/tabs/EditPointsTab.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { useState, useEffect, useRef, useCallback } from '@wordpress/element';
import {
Button,
Notice,
Toolbar,
} from '@wordpress/components';
import { Button, Notice, Toolbar } from '@wordpress/components';
import { undo } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import MapsToolbarGroup from '../../spotmap/components/MapsToolbarGroup';
Expand Down Expand Up @@ -96,7 +92,8 @@ export default function EditPointsTab( { onNoticeChange } ) {
return;
}
if ( typeof window.Spotmap === 'undefined' ) {
const missing = typeof window.L === 'undefined' ? 'Leaflet (L)' : 'Spotmap';
const missing =
typeof window.L === 'undefined' ? 'Leaflet (L)' : 'Spotmap';
onNoticeChange( {
status: 'error',
text: `Map engine not loaded (${ missing } is undefined). Check the browser console for script errors — a JavaScript conflict or ad-blocker may be preventing one of the map scripts from loading.`,
Expand Down
4 changes: 3 additions & 1 deletion src/spotmap-admin/tabs/FeedsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ export default function FeedsTab( {
status: 'success',
text:
count > 0
? `Fetched ${ count } new point${ count === 1 ? '' : 's' }.`
? `Fetched ${ count } new point${
count === 1 ? '' : 's'
}.`
: 'No new points found.',
} );
} catch ( err ) {
Expand Down
9 changes: 7 additions & 2 deletions src/spotmap-admin/tabs/ShortcodeTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ function buildShortcode( {
parts.push( `gpx-name="${ gpx.map( ( t ) => t.name ).join( ',' ) }"` );
parts.push( `gpx-url="${ gpx.map( ( t ) => t.url ).join( ',' ) }"` );
parts.push(
`gpx-color="${ gpx.map( ( t ) => t.color || '#FFD700' ).join( ',' ) }"`
`gpx-color="${ gpx
.map( ( t ) => t.color || '#FFD700' )
.join( ',' ) }"`
);
}
if ( debug ) {
Expand Down Expand Up @@ -310,7 +312,10 @@ export default function ShortcodeTab() {
const updateStyle = ( feed, key, value ) => {
setStyles( ( prev ) => ( {
...prev,
[ feed ]: { ...( prev[ feed ] ?? DEFAULT_FEED_STYLE ), [ key ]: value },
[ feed ]: {
...( prev[ feed ] ?? DEFAULT_FEED_STYLE ),
[ key ]: value,
},
} ) );
};

Expand Down
27 changes: 9 additions & 18 deletions src/spotmap/components/GpxManagerModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ export default function GpxManagerModal( { gpx, onChange, onClose } ) {
button: { text: __( 'Select' ) },
} );
frame.on( 'select', () => {
const selection = frame
.state()
.get( 'selection' )
.toJSON();
const selection = frame.state().get( 'selection' ).toJSON();
mergeTracks(
selection.map( ( t ) => ( {
id: t.id,
Expand Down Expand Up @@ -90,11 +87,7 @@ export default function GpxManagerModal( { gpx, onChange, onClose } ) {
valid.map( ( t ) => ( {
id: t.id,
url: t.url,
name:
t.title ||
t.filename ||
t.slug ||
String( t.id ),
name: t.title || t.filename || t.slug || String( t.id ),
color: gpx[ 0 ]?.color || '#FFD700',
visible: true,
download: false,
Expand Down Expand Up @@ -182,9 +175,7 @@ export default function GpxManagerModal( { gpx, onChange, onClose } ) {
<ColorPalette
colors={ COLORS }
value={ styleTrack?.color || '#FFD700' }
onChange={ ( v ) =>
v && updateProp( 'color', v )
}
onChange={ ( v ) => v && updateProp( 'color', v ) }
disableCustomColors={ false }
clearable={ false }
/>
Expand Down Expand Up @@ -265,7 +256,10 @@ export default function GpxManagerModal( { gpx, onChange, onClose } ) {
>
{ __( 'Upload' ) }
</Button>
<Button variant="secondary" onClick={ openMediaLibrary }>
<Button
variant="secondary"
onClick={ openMediaLibrary }
>
{ __( 'Media Library' ) }
</Button>
<input
Expand Down Expand Up @@ -306,8 +300,7 @@ export default function GpxManagerModal( { gpx, onChange, onClose } ) {
>
<tbody>
{ pageTracks.map( ( track, localIdx ) => {
const globalIdx =
pageStart + localIdx;
const globalIdx = pageStart + localIdx;
return (
<tr
key={
Expand Down Expand Up @@ -435,9 +428,7 @@ export default function GpxManagerModal( { gpx, onChange, onClose } ) {
</span>
<Button
variant="secondary"
disabled={
safePage >= totalPages - 1
}
disabled={ safePage >= totalPages - 1 }
onClick={ () =>
setPage( safePage + 1 )
}
Expand Down
10 changes: 9 additions & 1 deletion src/spotmap/components/MapsToolbarGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import { __ } from '@wordpress/i18n';
* A single row in the base-layer list. Shows a permanent "● active" badge for the
* primary map, and a hover-only "set active" link for other checked layers.
*/
function MapRowItem( { mapKey, label, isChecked, isActive, isDisabled, onToggle, onSetActive } ) {
function MapRowItem( {
mapKey,
label,
isChecked,
isActive,
isDisabled,
onToggle,
onSetActive,
} ) {
const [ hovered, setHovered ] = useState( false );
return (
<div
Expand Down
Loading
Loading