Skip to content

Commit

Permalink
RavenDB-21545 For a RavenDB Cloud license do not show Download Now in…
Browse files Browse the repository at this point in the history
… the Studio on the new version notification
  • Loading branch information
ml054 committed Jun 25, 2024
1 parent 28c5107 commit 01de0ed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/Raven.Server/Web/System/BuildVersionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public async Task Get()
[RavenAction("/build/version/updates", "POST", AuthorizationStatus.ValidUser, EndpointType.Read)]
public async Task GetVersionUpdatesInfo()
{
if (Server.Configuration.Updates.BackgroundChecksDisabled)
{
NoContentStatus();
return;
}

var shouldRefresh = GetBoolValueQueryString("refresh", required: false) ?? false;
if (shouldRefresh && IsLatestVersionCheckThrottled() == false)
{
Expand Down
31 changes: 20 additions & 11 deletions src/Raven.Studio/typescript/viewmodels/shell/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import popoverUtils = require("common/popoverUtils");
import app = require("durandal/app");
import feedback from "viewmodels/shell/feedback";

type newVersionStatus = "available" | "latest" | "checksDisabled";

class about extends viewModelBase {

view = require("views/shell/about.html");
Expand All @@ -37,30 +39,33 @@ class about extends viewModelBase {
developerLicense = license.developerLicense;

static latestVersion = ko.observable<Raven.Server.ServerWide.BackgroundTasks.LatestVersionCheck.VersionInfo>();
currentServerVersion = ko.pureComputed(() => this.serverVersion() ? this.serverVersion().FullVersion : "");
isNewVersionAvailable = ko.pureComputed(() => {
currentServerVersion = ko.pureComputed(() => this.serverVersion() ? this.serverVersion().FullVersion : "");

newVersionStatus = ko.pureComputed((): newVersionStatus => {
const latestVersionInfo = about.latestVersion();
if (!latestVersionInfo) {
return false;
return "checksDisabled";
}

const serverVersion = this.serverVersion();
if (!serverVersion) {
return false;
return "checksDisabled";
}

const isDevBuildNumber = (num: number) => num >= 40 && num < 60;

return !isDevBuildNumber(latestVersionInfo.BuildNumber) &&
latestVersionInfo.BuildNumber > serverVersion.BuildVersion;
return (!isDevBuildNumber(latestVersionInfo.BuildNumber) &&
latestVersionInfo.BuildNumber > serverVersion.BuildVersion) ? "available" : "latest";
});

newVersionAvailableHtml = ko.pureComputed(() => {
if (this.isNewVersionAvailable()) {
return `New version available<br/> <span class="nobr">${ about.latestVersion().Version }</span>`;
} else {
return `You are using the latest version`;
switch (this.newVersionStatus()) {
case "available":
return `New version available<br/> <span class="nobr">${ about.latestVersion().Version }</span>`;
case "latest":
return `You are using the latest version`;
default:
return null;
}
});

Expand Down Expand Up @@ -255,6 +260,8 @@ class about extends viewModelBase {
.done(versionInfo => {
if (versionInfo && versionInfo.Version) {
about.latestVersion(versionInfo);
} else {
about.latestVersion(null);
}
})
.always(() => this.spinners.latestVersionUpdates(false));
Expand All @@ -267,6 +274,8 @@ class about extends viewModelBase {
.done(versionInfo => {
if (versionInfo && versionInfo.Version) {
about.latestVersion(versionInfo);
} else {
about.latestVersion(null);
}
})
.always(() => this.spinners.latestVersionUpdates(false));
Expand Down
10 changes: 5 additions & 5 deletions src/Raven.Studio/wwwroot/App/views/shell/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@
</div>
</a>
</div>
<div>
<div data-bind="if: newVersionStatus() !== 'checksDisabled'">
<div class="flex-horizontal flex-stretch-items">
<button data-bind="click: openLatestVersionDownload" class="btn btn-primary big-button flex-grow">
<i class="icon-server"></i>
<div class="content">
<small data-bind="html: newVersionAvailableHtml"></small>
<strong data-bind="visible: !isNewVersionAvailable(), text: currentServerVersion"></strong>
<small data-bind="visible: isNewVersionAvailable">Newer version exists</small>
<strong data-bind="visible: isNewVersionAvailable">Download Now</strong>
<strong data-bind="visible: newVersionStatus() === 'latest', text: currentServerVersion"></strong>
<small data-bind="visible: newVersionStatus() === 'available'">Newer version exists</small>
<strong data-bind="visible: newVersionStatus() === 'available'">Download Now</strong>
</div>
</button>
<button data-bind="disable: spinners.latestVersionUpdates, click: refreshLatestVersionInfo, css: { 'btn-spinner': spinners.latestVersionUpdates }"
class="btn btn-primary" title="Click to refresh version info">
<i class="icon-refresh"></i>
</button>
</div>
<div class="text-center margin-top" data-bind="if: isNewVersionAvailable">
<div class="text-center margin-top" data-bind="if: newVersionStatus() === 'available'">
<a href="#" data-bind="attr: { href: latestVersionWhatsNewUrl }" target="_blank">See What's New</a>
</div>
</div>
Expand Down

0 comments on commit 01de0ed

Please sign in to comment.