Skip to content

PB-90: Reduce shortlink location popup calls tabs version #603

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

Merged

Conversation

LukasJoss
Copy link
Contributor

@LukasJoss LukasJoss commented Jan 15, 2024

Copy link

cypress bot commented Jan 15, 2024

Passing run #379 ↗︎

0 165 19 0 Flakiness 0

Details:

PB-90: Clean up code for PR
Project: web-mapviewer Commit: 2605c07491
Status: Passed Duration: 04:45 💡
Started: Jan 25, 2024 12:32 PM Ended: Jan 25, 2024 12:36 PM

Review all test suite changes for PR #603 ↗︎

@LukasJoss LukasJoss force-pushed the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch 2 times, most recently from 1e8bad8 to b4e2f29 Compare January 15, 2024 15:42
@LukasJoss LukasJoss requested a review from ltshb January 15, 2024 16:07
Copy link
Contributor

@ltshb ltshb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did a quick functional test of the UI (no code review yet) and looks very promising. A few issues/adjustment to do are listed below:

  1. Once the popup is open in the share tab, if you move the map around or change the map zoom, the URL parameter are updated, but this update is not reflected to the share link. So changes in the url parameter should trigger an update of the share link
  2. The name of the share tab should be changed to Share position (the old viewer is using this traduction so you should find a traduction key)
  3. The size of the window should be reduced, with both tab we have some white space on the right hand side.
  4. I would add the Share link label to the short link input element like in the Share menu (personal preference)
  5. The title of the popup window could be updated to the title of the tab (just an idea that needs to be experienced if it looks good)

@LukasJoss
Copy link
Contributor Author

4. Share

@LukasJoss LukasJoss closed this Jan 18, 2024
@LukasJoss LukasJoss reopened this Jan 18, 2024
@LukasJoss
Copy link
Contributor Author

LukasJoss commented Jan 18, 2024

I just did a quick functional test of the UI (no code review yet) and looks very promising. A few issues/adjustment to do are listed below:

1. Once the popup is open in the share tab, if you move the map around or change the map zoom, the URL parameter are updated, but this update is not reflected to the share link. So changes in the url parameter should trigger an update of the share link

2. The name of the share tab should be changed to `Share position` (the old viewer is using this traduction so you should find a traduction key)

3. The size of the window should be reduced, with both tab we have some white space on the right hand side.

4. I would add the `Share link` label to the short link input element like in the `Share` menu (personal preference)

5. The title of the popup window could be updated to the title of the tab (just an idea that needs to be experienced if it looks good)

1.) I added the sharelink update upon zoom but did not add the update upon map movement since the shortlink generated will always be centered on the chosen location anyway(what should be the behaviour upon changing maps?). Also maybe it would make sense to have the zoom level of the created url to have a fixed level to reduce the amount of created shortlinks even further.

3.) Instead of changing the windows size I made the tab buttons a constant size too keep consistency in the looks between the different language, is that good - though the copy sign might need to be removed?

4.) I didn't quite understand what you mean here.

5.)I temporarily added this change but I am not convinced of it

@LukasJoss LukasJoss force-pushed the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch from 7614eb9 to abe8915 Compare January 18, 2024 15:57
@LukasJoss LukasJoss requested a review from ltshb January 18, 2024 16:48
Copy link
Contributor

@ltshb ltshb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results looks very nice.

Some code clean up and improvements are required see comment, but thanks for the effort.

Comment on lines 63 to 95
copyTooltip.value = tippy(copyButton.value, {
content: i18n.t('copy_success'),
arrow: true,
placement: 'right',
trigger: 'manual',
onShow(instance) {
setTimeout(() => {
instance.hide()
}, 1000)
},
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should not make the tippy instance reactive. We should only use javascript plain object as reactive and as well in store. Unfortunately this is not always the case in our code, but we should make sure not to add more exception to this rule.
Adding complex object to reactive has some performance drawback and can lead to very subtle bugs.

Wo here you dan simply use a normal variable without ref

let copyTooltipInstance = null

onMounted(()=>{
  copyTooltipInstance = tippy(...)
})

shareLinkUrl.value = `${location.origin}/#/map?${stringifyQuery(query)}`
shortenShareLink(shareLinkUrl.value)

function showTooltip() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe showCopiedTooltip is more explicit

}
async function updateQrCode(url) {

async function copyValue() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use copyShareLink

const newClickInfo = ref(true)
const showEmbedSharing = ref(false)
const requestClipboard = ref(false)
const copied = ref(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe shareLinkCopied

Comment on lines 140 to 144
@click="
(selectedTab = 'position'),
(showEmbedSharing = false),
(newClickInfo = false)
"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to put this code to a function, e.g. onPositionTabClick

Comment on lines 178 to 179
.location-popup {
@extend .clear-no-ios-long-press;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is not needed here, already part of the parent component

})
watch(currentLang, () => {
if (showEmbedSharing.value) {
setTimeout(() => updateShareLink(), 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the setTimeout here ? if you have a race condition it could be also solved using vue nextTick method

})
watch(zoom, () => {
if (showEmbedSharing.value) {
setTimeout(() => updateShareLink(), 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dito as above

Comment on lines 184 to 191
<LocationPopupShare
:class="{ active: selectedTab === 'share', show: selectedTab === 'share' }"
:coordinate="coordinate"
:click-info="clickInfo"
:current-lang="currentLang"
:show-embed-sharing="showEmbedSharing"
@share-link="(i) => (shareLink = i)"
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the logic of the share link with the child event and the show-embed-sharing hard to follow, might be better to put the shortlink logic in the parent vue, meaning in this component LocationPopup and to pass the shortlink to the child component, might make the code simpler to follow.

@LukasJoss LukasJoss force-pushed the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch 3 times, most recently from 24a2af5 to 21106ca Compare January 24, 2024 16:34
@LukasJoss LukasJoss requested a review from ltshb January 24, 2024 16:41
Copy link
Contributor

@ltshb ltshb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice just a few minor comments but otherwise its all good.

@@ -1,45 +1,39 @@
<script setup>
/** Right click pop up which shows the coordinates of the position under the cursor. */

import proj4 from 'proj4'
import { computed, onMounted, ref, watch } from 'vue'
// importing directly the vue component, see https://github.com/ivanvermeyen/vue-collapse-transition/issues/5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is probably a copy past mistake

Comment on lines 36 to 27
const route = useRoute()
const store = useStore()

const clickInfo = computed(() => store.state.map.clickInfo)
const currentLang = computed(() => store.state.i18n.lang)
const projection = computed(() => store.state.position.projection)
const showIn3d = computed(() => store.state.cesium.active)
const currentLang = computed(() => store.state.i18n.lang)

const route = useRoute()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just code style I would keep the useRoute above with the other use...

updateShareLink()
}
}
console.log('Query parameters changed:', newQuery)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No console, if you want to keep some debugging log, you need to use log.debug

const selectedTab = ref('position')
const shareTabButton = ref(null)
const newClickInfo = ref(true)
const showEmbedSharing = ref(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified by using a computed property

const showEmbedSharing = computed(()=> selectedTab.value === 'share')

So you don't have to set it and clear it below

</script>

<template>
<component
:is="mappingFrameworkSpecificPopup"
v-if="coordinate"
:title="$t('position')"
:title="selectedTab == 'position' ? $t('position') : $t('link_bowl_crosshair')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the new style for translation i18n.t instead of $t

:value="heightInMeter"
:extra-value="heightInFeet"
>
<a :href="$t('elevation_href')" target="_blank">{{ $t('elevation') }}</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n.t

Comment on lines 37 to 39
<style lang="scss" scoped>
@import 'src/scss/webmapviewer-bootstrap-theme';
</style>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the style is not used it can be removed

@LukasJoss LukasJoss force-pushed the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch from 7cb07ed to 5ac6711 Compare January 25, 2024 09:52
@LukasJoss LukasJoss force-pushed the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch from 5ac6711 to dc1876c Compare January 25, 2024 10:19
@LukasJoss LukasJoss force-pushed the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch from b285b68 to 2605c07 Compare January 25, 2024 12:28
@LukasJoss LukasJoss merged commit 2b80df5 into develop Jan 25, 2024
@LukasJoss LukasJoss deleted the feat-PB-90-reduce_shortlink_location_popup_calls_tabs_version branch January 25, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants