From 7c867262f1d155b5b65b100f5d4770e593c29b1a Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Mon, 24 Jun 2024 06:22:48 +0200 Subject: [PATCH 1/3] Set correct geoloc error in case of timeout --- src/store/plugins/geolocation-management.plugin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/store/plugins/geolocation-management.plugin.js b/src/store/plugins/geolocation-management.plugin.js index c70453996..e890b07f9 100644 --- a/src/store/plugins/geolocation-management.plugin.js +++ b/src/store/plugins/geolocation-management.plugin.js @@ -55,6 +55,9 @@ const handlePositionError = (error, store) => { }) alert(i18n.global.t('geoloc_permission_denied')) break + case error.TIMEOUT: + alert(i18n.global.t('geoloc_time_out')) + break default: if (IS_TESTING_WITH_CYPRESS && error.code === error.POSITION_UNAVAILABLE) { // edge case for e2e testing, if we are testing with Cypress and we receive a POSITION_UNAVAILABLE From 350c13b4761bce8ece23584371a067206f4d0228 Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Mon, 24 Jun 2024 07:39:02 +0200 Subject: [PATCH 2/3] Improve geolocation error management by removing the alert() Now the geolocation error is not anymore in a window.alert() but in an error overlay on the top right corner that can be close. --- src/App.vue | 11 +- .../map/components/toolbox/GeolocButton.vue | 39 ++++-- src/store/modules/ui.store.js | 13 ++ .../plugins/geolocation-management.plugin.js | 9 +- src/utils/components/ErrorWindow.vue | 111 ++++++++++++++++++ tests/cypress/tests-e2e/geolocation.cy.js | 4 + 6 files changed, 168 insertions(+), 19 deletions(-) create mode 100644 src/utils/components/ErrorWindow.vue diff --git a/src/App.vue b/src/App.vue index 6234c3691..ce5d23350 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,10 +5,11 @@ * Will listen for screen size changes and commit this changes to the store */ -import { onMounted, onUnmounted, ref } from 'vue' +import { computed, onMounted, onUnmounted, ref } from 'vue' import { useI18n } from 'vue-i18n' import { useStore } from 'vuex' +import ErrorWindow from '@/utils/components/ErrorWindow.vue' import debounce from '@/utils/debounce' const withOutline = ref(false) @@ -20,6 +21,8 @@ const dispatcher = { dispatcher: 'App.vue' } let debouncedOnResize +const errorText = computed(() => store.state.ui.errorText) + onMounted(() => { // reading size setScreenSizeFromWindowSize() @@ -51,6 +54,12 @@ function refreshPageTitle() { @pointerdown="withOutline = false" > +
{{ i18n.t(errorText) }}
diff --git a/src/modules/map/components/toolbox/GeolocButton.vue b/src/modules/map/components/toolbox/GeolocButton.vue index 08e4bbcc6..103c1110a 100644 --- a/src/modules/map/components/toolbox/GeolocButton.vue +++ b/src/modules/map/components/toolbox/GeolocButton.vue @@ -8,10 +8,19 @@ const dispatcher = { dispatcher: 'GeolocButton.vue' } const store = useStore() -useTippyTooltip('.geoloc-button[data-tippy-content]', { placement: 'left' }) +useTippyTooltip('.geoloc-button-div[data-tippy-content]', { placement: 'left' }) const isActive = computed(() => store.state.geolocation.active) const isDenied = computed(() => store.state.geolocation.denied) +const tippyContent = computed(() => { + if (isDenied.value) { + return 'geoloc_permission_denied' + } + if (isActive.value) { + return 'geoloc_stop_tracking' + } + return 'geoloc_start_tracking' +}) function toggleGeolocation() { store.dispatch('toggleGeolocation', dispatcher) @@ -19,18 +28,22 @@ function toggleGeolocation() { diff --git a/tests/cypress/tests-e2e/geolocation.cy.js b/tests/cypress/tests-e2e/geolocation.cy.js index 3e7be21cf..719da434f 100644 --- a/tests/cypress/tests-e2e/geolocation.cy.js +++ b/tests/cypress/tests-e2e/geolocation.cy.js @@ -11,6 +11,10 @@ function getGeolocationButtonAndClickIt() { cy.get(geolocationButtonSelector).should('be.visible').click() } +// TODO Those tests below are not working as expected, as the cypress-browser-permissions is not +// working and the goelocation is always allowed, this needs to be reworked and probably need to +// use another plugin. + describe('Geolocation cypress', () => { context( 'Test geolocation when first time activating it', From 85a12c623069ff409e0e858457c297495d39d67d Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Mon, 24 Jun 2024 11:42:57 +0200 Subject: [PATCH 3/3] Fixing some typos --- src/modules/map/components/toolbox/GeolocButton.vue | 2 +- src/utils/components/ErrorWindow.vue | 1 - tests/cypress/tests-e2e/geolocation.cy.js | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/map/components/toolbox/GeolocButton.vue b/src/modules/map/components/toolbox/GeolocButton.vue index 103c1110a..d7e15f01f 100644 --- a/src/modules/map/components/toolbox/GeolocButton.vue +++ b/src/modules/map/components/toolbox/GeolocButton.vue @@ -28,7 +28,7 @@ function toggleGeolocation() {