Skip to content

Commit

Permalink
PB-1031: icon now redirect to repo
Browse files Browse the repository at this point in the history
- The github icon link redirects to the repository
- The app version link redirects to the release IF this is a clean version, otherwise it leads to the repository
  • Loading branch information
ltkum committed Jan 23, 2025
1 parent 95fdae3 commit bbf7931
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config/staging.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const APP_VERSION = __APP_VERSION__
* @type {String}
*/

export const GITHUB_REPOSITORY = 'https://github.com/geoadmin/web-mapviewer/releases/tag/'
export const GITHUB_REPOSITORY = 'https://github.com/geoadmin/web-mapviewer'
/**
* Display a big development banner on all but these hosts.
*
Expand Down
36 changes: 25 additions & 11 deletions src/utils/components/AppVersion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@ import { useStore } from 'vuex'
import { APP_VERSION } from '@/config/staging.config'
import { GITHUB_REPOSITORY } from '@/config/staging.config'
const cleanAppVersionRegex = /v\d+\.\d+\.\d+(-beta\.\d+)?$/
const store = useStore()
const appVersion = ref(APP_VERSION)
const isProd = computed(() => store.getters.isProductionSite)
function openGithubLink() {
window.open(GITHUB_REPOSITORY + APP_VERSION, '_blank')
function openGithubReleaseLink() {
const isAppVersionClean = appVersion.value.match(cleanAppVersionRegex)
if (!isAppVersionClean) {
openGithubRepoLink()
} else {
window.open(GITHUB_REPOSITORY + `/releases/tag/` + APP_VERSION, '_blank')
}
}
function openGithubRepoLink() {
window.open(GITHUB_REPOSITORY, '_blank')
}
</script>

<template>
<div
class="app-version"
:class="{ 'app-version-prod': isProd }"
data-cy="app-version"
@click="openGithubLink"
>
<font-awesome-icon :icon="['fab', 'github']" />
{{ appVersion }}
<div class="app-version" :class="{ 'app-version-prod': isProd }" data-cy="app-version">
<span @click="openGithubRepoLink" class="githubIcon"
><font-awesome-icon :icon="['fab', 'github']"
/></span>
<span class="app-version-link" @click="openGithubReleaseLink"> {{ appVersion }}</span>
</div>
</template>

Expand All @@ -32,11 +38,19 @@ function openGithubLink() {
.app-version {
color: $gray-800;
word-spacing: 3px;
cursor: pointer;
}
.app-version-link {
margin-left: 3px;
}
.githubIcon {
margin-right: 3px;
}
.app-version-prod {
color: $gray-500;
cursor: pointer;
}
</style>

0 comments on commit bbf7931

Please sign in to comment.