Skip to content

Commit

Permalink
fix: minimum required version not respected, detect current prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzwa committed Jan 16, 2024
1 parent d1b864c commit 801d554
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
36 changes: 26 additions & 10 deletions src/components/Settings/SoftwareUpgradeSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,34 @@
<v-list-item>
<v-list-item-content>
<v-list-item-title> Select a release to upgrade to:</v-list-item-title>
<v-list-item-subtitle>
Minimum required version: {{ minimum?.tag_name }}</v-list-item-subtitle
>

<span v-if="loading"> <v-alert>Loading releases...</v-alert></span>
<v-alert v-if="!loading && !filteredReleases?.length">No releases to show.</v-alert>
<v-radio-group v-model="selectedRelease">
<v-radio
v-for="release in filteredReleases"
:key="release.tag_name"
:disabled="
isCurrentRelease(release) || !isUpgradeOrAllowedDowngrade(release, current)
isCurrentRelease(release) ||
!isUpgradeOrAllowedDowngrade(release, current) ||
isBelowMinimum(release)
"
:label="`${release.tag_name}${
!isUpgradeOrAllowedDowngrade(release, current)
? ' (cannot downgrade)'
: '' || (isCurrentRelease(release) ? ' (current)' : '')
? ' (cannot downgrade, '
: ' (' || (isCurrentRelease(release) ? ' (current, ' : '(')
}${
isVersionUnstable(release)
? `${isBelowMinimum(release) ? 'below minimum' : 'unstable'})`
: ')'
}`"
:value="release.tag_name"
>
</v-radio>
</v-radio-group>
<v-alert v-if="!loading && !filteredReleases?.length">No releases to show.</v-alert>
<div>
<v-alert v-if="showPrereleases" color="primary" max-width="500px">
You are viewing prereleases, please install such versions at your own risk!
Expand Down Expand Up @@ -141,15 +150,14 @@ async function loadReleases() {
}
const filteredReleases = computed(() => {
const currentlyUnstable = isCurrentUnstable();
return loadedClientReleases.value.filter((release) => {
const isMinimumVersion = minor(release.tag_name) === minor(minimum.value!.tag_name);
const isMinimumVersionOrHigher = minor(release.tag_name) === minor(minimum.value!.tag_name);
const isReleaseCandidate = isVersionUnstable(release);
const isDraft = release.draft;
return (
isMinimumVersion &&
(currentlyUnstable || showPrereleases.value || !isReleaseCandidate) &&
isMinimumVersionOrHigher &&
(isCurrentUnstable() || showPrereleases.value || !isReleaseCandidate) &&
!isDraft
);
});
Expand All @@ -166,14 +174,18 @@ function isCurrentUnstable() {
}
function isVersionUnstable(release?: IRelease) {
if (release?.tag_name.length) {
if (release?.tag_name?.length) {
return (
release.prerelease || release.tag_name.includes("rc") || release.tag_name.includes("unstable")
);
}
return false;
}
function isBelowMinimum(release: IRelease) {
return compare(release.tag_name, minimum.value!.tag_name) === -1;
}
function isUpgradeOrAllowedDowngrade(release: IRelease, current?: IRelease) {
// If no current release is known, we need to throw
if (!current) {
Expand All @@ -182,7 +194,11 @@ function isUpgradeOrAllowedDowngrade(release: IRelease, current?: IRelease) {
if (allowDowngrade.value) {
return true;
}
return compare(release.tag_name, current.tag_name) !== -1;
return (
compare(release.tag_name, current.tag_name) !== -1 &&
compare(minimum.value!.tag_name, current.tag_name) !== -1
);
}
function isCurrentRelease(release: IRelease) {
Expand Down
16 changes: 14 additions & 2 deletions src/components/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@
<v-btn icon @click="showHelp = true">
<v-icon>help</v-icon>
</v-btn>
<v-dialog v-model="showHelp" eager fullscreen transition="dialog-bottom-transition" width="90%">
<v-dialog
v-model="showHelp"
style="background-color: white"
eager
fullscreen
transition="dialog-bottom-transition"
width="90%"
>
<v-btn @click="showHelp = false"
>Close Help
<v-icon>close</v-icon>
Expand All @@ -61,7 +68,12 @@
Showing help from docs.fdm-monster.net
</v-toolbar>

<iframe height="100%" src="https://docs.fdm-monster.net/software_usage" width="100%" />
<iframe
style="background-color: white"
height="100%"
src="https://docs.fdm-monster.net"
width="100%"
/>
</v-card>
</v-dialog>
</v-app-bar>
Expand Down

0 comments on commit 801d554

Please sign in to comment.