Skip to content

Commit 0b23c75

Browse files
dmitriy-borzenkoDmitriy Borzenko
and
Dmitriy Borzenko
authored
Kamu UI 435 feature contextual schemas in data tab (#482)
* Reused SearchAndSchemasComponent * Fixed unit tests * changed CHANGELOG.md --------- Co-authored-by: Dmitriy Borzenko <[email protected]>
1 parent b0d319a commit 0b23c75

9 files changed

+40
-67
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Query page: added default query after searching for first dataset
1111
- Set the container width for large screens
12+
- Added contextual schemas in Data tab
1213
### Changed
1314
- Readme section: modified 'Run' button into a link
1415
- Hint extension for tile widget account

src/app/dataset-view/additional-components/data-component/data.component.html

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
<div class="dataset-view-data-result-container">
2-
<div class="search-result-container__content">
3-
<ng-container *ngIf="overviewUpdate$ | async as overviewUpdate">
4-
<ng-container *ngIf="overviewUpdate.schema">
5-
<h2 class="box-title align-items-center pb-3 m-0">Schema:</h2>
6-
<app-dynamic-table
7-
[hasTableHeader]="true"
8-
[schemaFields]="overviewUpdate.schema.fields"
9-
[idTable]="'schema-block-table'"
10-
/>
11-
</ng-container>
12-
</ng-container>
13-
14-
<div>
15-
<h2 class="box-title align-items-center pb-3 pt-3 m-0">Saved Queries</h2>
16-
<app-saved-queries-section></app-saved-queries-section>
17-
</div>
18-
</div>
19-
1+
<div class="query-container">
2+
<app-search-and-schemas-section [disableSearch]="true"></app-search-and-schemas-section>
203
<div class="search-result-container__content">
214
<app-query-and-result-sections
225
[sqlLoading]="sqlLoading"

src/app/dataset-view/additional-components/data-component/data.component.spec.ts

+3-23
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { ComponentFixture, TestBed, fakeAsync, flush, tick } from "@angular/core
44
import { MatIconModule } from "@angular/material/icon";
55
import { MatMenuModule } from "@angular/material/menu";
66
import { DataComponent } from "./data.component";
7-
8-
import { emitClickOnElementByDataTestId, findElementByDataTestId } from "src/app/common/base-test.helpers.spec";
9-
import { DatasetSubscriptionsService } from "../../dataset.subscriptions.service";
7+
import { emitClickOnElementByDataTestId } from "src/app/common/base-test.helpers.spec";
108
import { mockMetadataDerivedUpdate, mockOverviewDataUpdate, mockOverviewDataUpdateNullable } from "../data-tabs.mock";
119
import { RouterTestingModule } from "@angular/router/testing";
1210
import { Location } from "@angular/common";
@@ -26,11 +24,11 @@ import { Apollo } from "apollo-angular";
2624
import { ToastrModule } from "ngx-toastr";
2725
import { SavedQueriesSectionComponent } from "../../../query/shared/saved-queries-section/saved-queries-section.component";
2826
import { QueryAndResultSectionsComponent } from "../../../query/shared/query-and-result-sections/query-and-result-sections.component";
27+
import { SearchAndSchemasSectionComponent } from "src/app/query/global-query/search-and-schemas-section/search-and-schemas-section.component";
2928

3029
describe("DataComponent", () => {
3130
let component: DataComponent;
3231
let fixture: ComponentFixture<DataComponent>;
33-
let datasetSubsService: DatasetSubscriptionsService;
3432
let location: Location;
3533
let ngbModalService: NgbModal;
3634

@@ -58,10 +56,10 @@ describe("DataComponent", () => {
5856
LoadMoreComponent,
5957
RequestTimerComponent,
6058
SqlEditorComponent,
59+
SearchAndSchemasSectionComponent,
6160
],
6261
}).compileComponents();
6362
fixture = TestBed.createComponent(DataComponent);
64-
datasetSubsService = TestBed.inject(DatasetSubscriptionsService);
6563
location = TestBed.inject(Location);
6664
ngbModalService = TestBed.inject(NgbModal);
6765
component = fixture.componentInstance;
@@ -87,24 +85,6 @@ describe("DataComponent", () => {
8785
flush();
8886
}));
8987

90-
it("should check schema column names", fakeAsync(() => {
91-
datasetSubsService.emitOverviewChanged({
92-
schema: mockMetadataDerivedUpdate.schema,
93-
content: mockOverviewDataUpdate.content,
94-
overview: _.cloneDeep(mockOverviewDataUpdate.overview),
95-
size: mockOverviewDataUpdate.size,
96-
} as OverviewUpdate);
97-
tick();
98-
fixture.detectChanges();
99-
const columnSchemaNames = mockMetadataDerivedUpdate.schema?.fields.map((item) => item.name);
100-
columnSchemaNames?.forEach((columnName) => {
101-
expect(findElementByDataTestId(fixture, `column-name-${columnName}`)?.textContent?.trim()).toEqual(
102-
columnName,
103-
);
104-
});
105-
flush();
106-
}));
107-
10888
it("should check add data", () => {
10989
const ngbModalServiceSpy = spyOn(ngbModalService, "open").and.callThrough();
11090
component.datasetBasics = mockDatasetBasicsRootFragment;

src/app/dataset-view/dataset.component.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { promiseWithCatch } from "../common/app.helpers";
5353
import { QueryAndResultSectionsComponent } from "../query/shared/query-and-result-sections/query-and-result-sections.component";
5454
import { SavedQueriesSectionComponent } from "../query/shared/saved-queries-section/saved-queries-section.component";
5555
import { SqlQueryService } from "../services/sql-query.service";
56+
import { SearchAndSchemasSectionComponent } from "../query/global-query/search-and-schemas-section/search-and-schemas-section.component";
5657

5758
describe("DatasetComponent", () => {
5859
let component: DatasetComponent;
@@ -86,6 +87,7 @@ describe("DatasetComponent", () => {
8687
FlowsComponent,
8788
QueryAndResultSectionsComponent,
8889
SavedQueriesSectionComponent,
90+
SearchAndSchemasSectionComponent,
8991
],
9092
imports: [
9193
AngularSvgIconModule.forRoot(),

src/app/query/global-query/global-query.component.scss

-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,3 @@
33
margin-right: auto;
44
margin-left: auto;
55
}
6-
7-
.query-container {
8-
display: grid;
9-
align-items: start;
10-
grid-template-columns: minmax(16rem, 37%) 1fr;
11-
column-gap: 1.5rem;
12-
}

src/app/query/global-query/search-and-schemas-section/search-and-schemas-section.component.html

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="box p-4 schemes-container">
2-
<div class="d-flex flex-column">
2+
<div class="d-flex flex-column" *ngIf="!disableSearch">
33
<h2 class="mb-1">Search:</h2>
44
<div class="d-flex flex-row position-relative w-100">
55
<input
@@ -18,23 +18,25 @@ <h2 class="mb-1">Search:</h2>
1818
x
1919
</button>
2020
</div>
21-
</div>
22-
<ng-template #rt let-r="result" let-t="term">
23-
<div class="d-flex flex-row justify-content-between" [style.width.px]="searchDatasets.clientWidth - 28">
24-
<div class="search-result-item">
25-
<i class="bi bi-journal-album mr-2"></i>
26-
<ng-container *ngIf="!r.dummy">{{ r.dataset.owner.accountName }}/</ng-container>
27-
<ngb-highlight [result]="r.dataset.name" [term]="t" />
28-
</div>
29-
<div class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 f6 button-add color-text-tertiary ml-1">
30-
Add
31-
<span class="d-inline-block ml-1 v-align-middle"><i class="bi bi-arrow-return-left"></i></span>
21+
<ng-template #rt let-r="result" let-t="term">
22+
<div class="d-flex flex-row justify-content-between" [style.width.px]="searchDatasets.clientWidth - 28">
23+
<div class="search-result-item">
24+
<i class="bi bi-journal-album mr-2"></i>
25+
<ng-container *ngIf="!r.dummy">{{ r.dataset.owner.accountName }}/</ng-container>
26+
<ngb-highlight [result]="r.dataset.name" [term]="t" />
27+
</div>
28+
<div
29+
class="border rounded-1 flex-shrink-0 color-bg-tertiary px-1 f6 button-add color-text-tertiary ml-1"
30+
>
31+
Add
32+
<span class="d-inline-block ml-1 v-align-middle"><i class="bi bi-arrow-return-left"></i></span>
33+
</div>
3234
</div>
33-
</div>
34-
</ng-template>
35+
</ng-template>
36+
</div>
3537

3638
<div class="search-datasets mt-4">
37-
<h2>Dataset schemas:</h2>
39+
<h2>Schemas:</h2>
3840
<mat-divider class="px-2 mt-2 mb-4"></mat-divider>
3941

4042
<cdk-accordion
@@ -65,6 +67,7 @@ <h2>Dataset schemas:</h2>
6567
<mat-icon>keyboard_arrow_up</mat-icon>
6668
</ng-template>
6769
<button
70+
*ngIf="!disableSearch"
6871
class="no-button d-flex"
6972
(click)="removeDataset(item.datasetAlias)"
7073
title="Remove dataset"
@@ -94,7 +97,7 @@ <h2>Dataset schemas:</h2>
9497
</cdk-accordion-item>
9598
</cdk-accordion>
9699
<ng-template #emptyTemplate>
97-
<p class="text-center mt-4">No datasets selected</p>
100+
<p *ngIf="!disableSearch" class="text-center mt-4">No datasets selected</p>
98101
</ng-template>
99102
</div>
100103

src/app/query/global-query/search-and-schemas-section/search-and-schemas-section.component.scss

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ h2 {
2929

3030
.example-accordion-item {
3131
display: block;
32-
border: solid 1px #ccc;
3332

3433
&:last-child {
3534
border-bottom: 1px solid #ccc;
@@ -47,12 +46,15 @@ h2 {
4746
&-header {
4847
color: #000;
4948
font-size: 13px;
50-
font-weight: 400;
49+
font-weight: 500;
5150
line-height: 20px;
5251
cursor: pointer;
5352
display: flex;
5453
padding: 4px 10px;
5554
background: #f6f8fa;
55+
border-top: solid 1px #ccc;
56+
border-left: solid 1px #ccc;
57+
border-right: solid 1px #ccc;
5658

5759
&:hover {
5860
cursor: pointer;

src/app/query/global-query/search-and-schemas-section/search-and-schemas-section.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Component,
55
EventEmitter,
66
inject,
7+
Input,
78
OnInit,
89
Output,
910
} from "@angular/core";
@@ -39,6 +40,7 @@ import { SqlQueryService } from "src/app/services/sql-query.service";
3940
})
4041
export class SearchAndSchemasSectionComponent extends BaseComponent implements OnInit {
4142
@Output() public sqlQueryEmit = new EventEmitter<string>();
43+
@Input() public disableSearch: boolean;
4244
public searchResult: GlobalQuerySearchItem[] = [];
4345
public inputDatasets = new Set<string>();
4446
public searchDataset = "";

src/styles.scss

+7
Original file line numberDiff line numberDiff line change
@@ -1597,3 +1597,10 @@ pre.language-sql {
15971597
}
15981598
}
15991599
}
1600+
1601+
.query-container {
1602+
display: grid;
1603+
align-items: start;
1604+
grid-template-columns: minmax(16rem, 37%) 1fr;
1605+
column-gap: 1.5rem;
1606+
}

0 commit comments

Comments
 (0)