CB-2878 change error title

This commit is contained in:
naumov
2022-11-21 21:13:09 +04:00
parent 514db16af5
commit ef86884aca
2 changed files with 36 additions and 39 deletions
@@ -9,6 +9,7 @@
import { computed, makeObservable, observable, runInAction } from 'mobx';
import { injectable } from '@cloudbeaver/core-di';
import { NotificationService } from '@cloudbeaver/core-events';
import { ServerConfigResource } from '@cloudbeaver/core-root';
import { CachedMapAllKey, CachedMapResource } from '@cloudbeaver/core-sdk';
@@ -32,12 +33,13 @@ export class VersionResource extends CachedMapResource<string, IVersion> {
}
constructor(
private readonly serverConfigResource: ServerConfigResource
private readonly serverConfigResource: ServerConfigResource,
private readonly notificationService: NotificationService,
) {
super();
this.latestVersionNumber = null;
this.preloadResource(this.serverConfigResource, () => {});
this.preloadResource(this.serverConfigResource, () => { });
makeObservable<this, 'latestVersionNumber'>(this, {
latestVersionNumber: observable.ref,
@@ -56,26 +58,32 @@ export class VersionResource extends CachedMapResource<string, IVersion> {
return this.data;
}
const response = await fetch(versionLink, {
cache: 'no-cache',
});
try {
const response = await fetch(versionLink, {
cache: 'no-cache',
});
const json = await response.json() as IVersions;
const json = await response.json() as IVersions;
if (json.latestVersion) {
this.latestVersionNumber = json.latestVersion;
}
if (!json.versions) {
return this.data;
}
runInAction(() => {
this.data.clear();
for (const version of json.versions!) {
this.data.set(version.number, version);
if (json.latestVersion) {
this.latestVersionNumber = json.latestVersion;
}
});
if (!json.versions) {
return this.data;
}
runInAction(() => {
this.data.clear();
for (const version of json.versions!) {
this.data.set(version.number, version);
}
});
} catch (exception: any) {
this.notificationService.logException(exception, 'versions_load_fail');
}
return this.data;
}
@@ -11,7 +11,7 @@ import styled, { css } from 'reshadow';
import { gte } from 'semver';
import type { AdministrationItemContentComponent } from '@cloudbeaver/core-administration';
import { BASE_CONTAINERS_STYLES, ColoredContainer, Loader, useMapResource, useStyles } from '@cloudbeaver/core-blocks';
import { BASE_CONTAINERS_STYLES, ColoredContainer, useMapResource, useStyles } from '@cloudbeaver/core-blocks';
import { useService } from '@cloudbeaver/core-di';
import { CachedMapAllKey } from '@cloudbeaver/core-sdk';
import { VersionResource, VersionService } from '@cloudbeaver/core-version';
@@ -26,11 +26,6 @@ const styles = css`
composes: theme-typography--body2 from global;
list-style-position: inside;
}
Loader {
width: 100%;
height: 100%;
}
`;
export const VersionUpdate: AdministrationItemContentComponent = observer(function VersionUpdate() {
@@ -44,20 +39,14 @@ export const VersionUpdate: AdministrationItemContentComponent = observer(functi
return styled(style)(
<ColoredContainer wrap gap overflow parent>
<Loader state={versionResource}>
{() => (
<>
<VersionChecker />
{versions.length > 0 && (
<>
<Instructions />
<VersionSelector versions={versions} />
</>
)}
<Recommendations />
</>
)}
</Loader>
<VersionChecker />
{versions.length > 0 && (
<>
<Instructions />
<VersionSelector versions={versions} />
</>
)}
<Recommendations />
</ColoredContainer>
);
});