Skip to content

Commit e917775

Browse files
dmitriy-borzenkoDmitriy Borzenko
and
Dmitriy Borzenko
authored
Kamu UI 450 terms and conditions UI (#473)
* Added laoyour for Tos * Extended feature flags * changed CHANGELOG.md * fixed CHANGELOG.md --------- Co-authored-by: Dmitriy Borzenko <[email protected]>
1 parent 5c0df81 commit e917775

File tree

9 files changed

+57
-20
lines changed

9 files changed

+57
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
### Added
10+
- Added Terms of Service link
11+
812
## [0.30.0] - 2024-11-22
913
### Added
1014
- Added a new page `Query` that allows you to make sql queries without being tied to a dataset

src/app/app-config.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface AppConfigFeatureFlags {
2222
enableLogout: boolean;
2323
enableScheduling: boolean;
2424
enableDatasetEnvVarsManagment: boolean;
25+
enableTermsOfService: boolean;
2526
}
2627

2728
export interface GrafanaLogsConfiguration {

src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class AppComponent extends BaseComponent implements OnInit {
4141
enableLogout: true,
4242
enableScheduling: true,
4343
enableDatasetEnvVarsManagment: true,
44+
enableTermsOfService: true,
4445
};
4546

4647
public readonly APP_LOGO = `/${AppValues.APP_LOGO}`;

src/app/auth/login/login.component.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ <h1 class="text-center text-muted mt-4">Select your Login Method</h1>
2020
>
2121
Login with Password
2222
</a>
23+
<ng-container *ngIf="enableTermsOfService">
24+
<ng-container *ngTemplateOutlet="termsOfServiceFragment"></ng-container>
25+
</ng-container>
2326
</div>
2427
</div>
2528
</ng-container>
@@ -88,5 +91,17 @@ <h1 class="text-center text-muted mt-4">Login to Kamu</h1>
8891
<div *ngIf="passwordLoginError$ | async as passwordLoginError" class="mt-4">
8992
<div class="error-block" data-test-id="password-method-error">{{ passwordLoginError }}</div>
9093
</div>
94+
<div class="mt-30" *ngIf="enableTermsOfService">
95+
<ng-container *ngTemplateOutlet="termsOfServiceFragment"></ng-container>
96+
</div>
9197
</form>
9298
</div>
99+
100+
<ng-template #termsOfServiceFragment>
101+
<p class="text-center fs-12">
102+
By logging in you accept the
103+
<a class="fs-12 tos-link" href="https://docs.kamu.dev/terms-of-service" target="_blank"
104+
>Kamu Terms of Service</a
105+
>
106+
</p>
107+
</ng-template>

src/app/auth/login/login.component.scss

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@ a {
55
color: $app-dark;
66
}
77

8+
.tos-link {
9+
text-decoration: underline;
10+
color: #0d6efd;
11+
}
12+
13+
p {
14+
margin: 0;
15+
}
16+
17+
.mt-30 {
18+
margin-top: 30px;
19+
}
20+
821
.login-container__buttons {
922
height: 100vh;
10-
overflow: hidden;
11-
margin-top: 200px;
23+
display: flex;
24+
justify-content: center;
25+
flex-direction: column;
1226

1327
.inner-container {
1428
border: 1px solid $app-color-border-default;
@@ -17,7 +31,7 @@ a {
1731
display: flex;
1832
justify-content: center;
1933
flex-direction: column;
20-
gap: 40px;
34+
gap: 30px;
2135
border-radius: 6px;
2236
}
2337

@@ -26,7 +40,7 @@ a {
2640
display: flex;
2741
justify-content: center;
2842
border: 1px solid $app-color-border-default;
29-
width: 200px;
43+
width: 280px;
3044
padding: 5px 15px;
3145
border-radius: 6px;
3246
background-color: #ebeef1;

src/app/auth/login/login.component.spec.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ describe("LoginComponent", () => {
3939
let localStorageService: LocalStorageService;
4040
let authApi: AuthApi;
4141
let httpController: HttpTestingController;
42+
const MOCK_FEATURE_FLAGS = {
43+
enableLogout: true,
44+
enableScheduling: true,
45+
enableDatasetEnvVarsManagment: true,
46+
enableTermsOfService: true,
47+
};
4248

4349
enum Elements {
4450
METHOD_SELECTION_BLOCK = "method-selection-block",
@@ -98,11 +104,7 @@ describe("LoginComponent", () => {
98104
describe("Main test suite", () => {
99105
beforeEach(() => {
100106
appConfigService = TestBed.inject(AppConfigService);
101-
spyOnProperty(appConfigService, "featureFlags", "get").and.returnValue({
102-
enableLogout: true,
103-
enableScheduling: true,
104-
enableDatasetEnvVarsManagment: true,
105-
});
107+
spyOnProperty(appConfigService, "featureFlags", "get").and.returnValue(MOCK_FEATURE_FLAGS);
106108
spyOnProperty(loginService, "loginMethods", "get").and.returnValue([
107109
LoginMethod.GITHUB,
108110
LoginMethod.PASSWORD,
@@ -266,11 +268,7 @@ describe("LoginComponent", () => {
266268

267269
beforeEach(() => {
268270
appConfigService = TestBed.inject(AppConfigService);
269-
spyOnProperty(appConfigService, "featureFlags", "get").and.returnValue({
270-
enableLogout: true,
271-
enableScheduling: true,
272-
enableDatasetEnvVarsManagment: true,
273-
});
271+
spyOnProperty(appConfigService, "featureFlags", "get").and.returnValue(MOCK_FEATURE_FLAGS);
274272
spyOnProperty(loginService, "loginMethods", "get").and.returnValue([loginMethod]);
275273

276274
spyGotoGithub = spyOn(loginService, "gotoGithub").and.stub();
@@ -297,11 +295,7 @@ describe("LoginComponent", () => {
297295
describe("Zero-method-config", () => {
298296
beforeEach(() => {
299297
appConfigService = TestBed.inject(AppConfigService);
300-
spyOnProperty(appConfigService, "featureFlags", "get").and.returnValue({
301-
enableLogout: true,
302-
enableScheduling: true,
303-
enableDatasetEnvVarsManagment: true,
304-
});
298+
spyOnProperty(appConfigService, "featureFlags", "get").and.returnValue(MOCK_FEATURE_FLAGS);
305299
spyOnProperty(loginService, "loginMethods", "get").and.returnValue([]);
306300
});
307301

src/app/auth/login/login.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { BaseComponent } from "src/app/common/base.component";
1212
import { LocalStorageService } from "src/app/services/local-storage.service";
1313
import { LoginFormType } from "./login.component.model";
1414
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
15+
import { AppConfigService } from "src/app/app-config.service";
1516

1617
@Component({
1718
selector: "app-login",
@@ -27,6 +28,7 @@ export class LoginComponent extends BaseComponent implements OnInit {
2728
private route = inject(ActivatedRoute);
2829
private fb = inject(FormBuilder);
2930
private loginService = inject(LoginService);
31+
private appConfigService = inject(AppConfigService);
3032

3133
public readonly APP_LOGO = `/${AppValues.APP_LOGO}`;
3234
public readonly LoginMethod = LoginMethod;
@@ -64,6 +66,10 @@ export class LoginComponent extends BaseComponent implements OnInit {
6466
return this.passwordLoginForm.get("password");
6567
}
6668

69+
public get enableTermsOfService(): boolean {
70+
return this.appConfigService.featureFlags.enableTermsOfService;
71+
}
72+
6773
public onSelectedLoginMethod(loginMethod: LoginMethod): void {
6874
this.selectedLoginMethod = loginMethod;
6975
if (loginMethod === LoginMethod.GITHUB) {

src/app/components/app-header/app-header.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ describe("AppHeaderComponent", () => {
8787
enableLogout: true,
8888
enableScheduling: true,
8989
enableDatasetEnvVarsManagment: true,
90+
enableTermsOfService: true,
9091
};
9192
component.loginMethods = [LoginMethod.GITHUB, LoginMethod.PASSWORD];
9293
component.isVisible = true;

src/assets/runtime-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"featureFlags": {
77
"enableLogout": true,
88
"enableScheduling": true,
9-
"enableDatasetEnvVarsManagment": true
9+
"enableDatasetEnvVarsManagment": true,
10+
"enableTermsOfService": true
1011
},
1112
"grafanaLogs": {
1213
"taskDetailsUrl": " https://grafana.sha.stg.internal.kamu.dev/explore?schemaVersion=1&panes=%7B%22LYy%22%3A%7B%22datasource%22%3A%22365dd1cc-3781-43c1-86a1-a3f78c6ab420%22%2C%22queries%22%3A%5B%7B%22refId%22%3A%22A%22%2C%22expr%22%3A%22%7Bjob%3D%5C%22europort%2Fkamu-api-server%5C%22%7D+%7C+json+root_span%2C+task_id%3D%5C%22log.spans%5B0%5D.task_id%5C%22%2C+target%3D%5C%22log.target%5C%22%2C+message%3D%5C%22log.fields.message%5C%22+%7C+task_id+%3D+%60{{taskId}}%60+%7C%3D+%60%60%22%2C%22queryType%22%3A%22range%22%2C%22datasource%22%3A%7B%22type%22%3A%22loki%22%2C%22uid%22%3A%22365dd1cc-3781-43c1-86a1-a3f78c6ab420%22%7D%2C%22editorMode%22%3A%22builder%22%7D%5D%2C%22range%22%3A%7B%22from%22%3A%22{{fromTime}}%22%2C%22to%22%3A%22{{toTime}}%22%7D%7D%7D&orgId=1",

0 commit comments

Comments
 (0)