From b3bb9fdd4003a49a1772bc3f731ec1af5fc67277 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 27 Jul 2021 22:29:29 +0200 Subject: [PATCH] . --- backend/tabby/app/api.py | 2 ++ backend/tabby/settings.py | 2 ++ frontend/src/api.ts | 1 + frontend/src/components/home.component.scss | 4 ++-- frontend/src/components/home.component.ts | 6 +++++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/tabby/app/api.py b/backend/tabby/app/api.py index ffa2b2e..b4ced52 100644 --- a/backend/tabby/app/api.py +++ b/backend/tabby/app/api.py @@ -162,6 +162,7 @@ class LogoutView(APIView): class InstanceInfoSerializer(Serializer): login_enabled = fields.BooleanField() + homepage_enabled = fields.BooleanField() class InstanceInfoViewSet(RetrieveModelMixin, GenericViewSet): @@ -171,6 +172,7 @@ class InstanceInfoViewSet(RetrieveModelMixin, GenericViewSet): def get_object(self): return { 'login_enabled': settings.ENABLE_LOGIN, + 'homepage_enabled': settings.ENABLE_HOMEPAGE, } diff --git a/backend/tabby/settings.py b/backend/tabby/settings.py index c1038d9..baa8704 100644 --- a/backend/tabby/settings.py +++ b/backend/tabby/settings.py @@ -194,6 +194,7 @@ for key in [ 'ENABLE_LOGIN', 'GA_ID', 'GA_DOMAIN', + 'ENABLE_HOMEPAGE', ]: globals()[key] = os.getenv(key) @@ -206,6 +207,7 @@ for key in [ for key in [ 'ENABLE_LOGIN', + 'ENABLE_HOMEPAGE', ]: globals()[key] = bool(globals()[key]) if globals()[key] else None diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 6670436..178e804 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -28,6 +28,7 @@ export interface Version { export interface InstanceInfo { login_enabled: boolean + homepage_enabled: boolean } export interface Gateway { diff --git a/frontend/src/components/home.component.scss b/frontend/src/components/home.component.scss index 55533c6..d37a415 100644 --- a/frontend/src/components/home.component.scss +++ b/frontend/src/components/home.component.scss @@ -112,6 +112,6 @@ strong { img { min-width: 100px; max-width: 100%; - width: 100%; -} + width: 100%; + } } diff --git a/frontend/src/components/home.component.ts b/frontend/src/components/home.component.ts index a1311fc..350024b 100644 --- a/frontend/src/components/home.component.ts +++ b/frontend/src/components/home.component.ts @@ -5,7 +5,7 @@ import { Component, ElementRef, ViewChild } from '@angular/core' import { InstanceInfo, Version } from '../api' import { faCoffee, faDownload, faSignInAlt } from '@fortawesome/free-solid-svg-icons' import { faGithub } from '@fortawesome/free-brands-svg-icons' -import { ActivatedRoute } from '@angular/router' +import { ActivatedRoute, Router } from '@angular/router' import { CommonService } from '../services/common.service' @@ -101,9 +101,13 @@ export class HomeComponent { private http: HttpClient, private commonService: CommonService, route: ActivatedRoute, + router: Router, ) { window.addEventListener('message', this.connectorRequestHandler) this.instanceInfo = route.snapshot.data.instanceInfo + if (!this.instanceInfo.homepage_enabled) { + router.navigate(['/app']) + } } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types