Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kamu UI 122 disabled run query button after error #127

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h2 class="box-title align-items-center pb-3 m-0">Query:</h2>
data-test-id="runSqlQueryButton"
name="run sql button"
(click)="onRunSQLRequest()"
[disabled]="!currentData.length"
[disabled]="!currentData.length && !sqlErrorMarker"
class="sql-run-button rounded-left-2 border-right-0 btnGroup-item btn d-flex justify-content-center align-items-center"
>
<span>Run</span><mat-icon>play_arrow</mat-icon>
Expand Down Expand Up @@ -151,7 +151,7 @@ <h2 class="box-title align-items-center py-3 m-0">Result:</h2>
[dataRows]="currentData || []"
></app-dynamic-table>
</ng-container>
<ng-container *ngIf="!sqlErrorMarker || !currentSchema || !currentData.length">
<ng-container *ngIf="!sqlErrorMarker && !currentSchema">
<mat-divider></mat-divider>
<h3 class="box-title text-center pt-4 author" *ngIf="!currentData.length">
Need
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ComponentFixture, TestBed } from "@angular/core/testing";
import { MatIconModule } from "@angular/material/icon";
import { MatMenuModule } from "@angular/material/menu";
import { DataComponent } from "./data-component";
import { emitClickOnElementByDataTestId } from "src/app/common/base-test.helpers.spec";
import { emitClickOnElementByDataTestId, findElementByDataTestId } from "src/app/common/base-test.helpers.spec";
import { AppDatasetSubscriptionsService } from "../../dataset.subscriptions.service";
import { mockDataUpdate, mockSqlErrorUpdate } from "../data-tabs.mock";
import { first } from "rxjs/operators";
Expand Down Expand Up @@ -75,11 +75,12 @@ describe("DataComponent", () => {
});

it("should check invalid SQL result update", () => {
fixture.detectChanges();
const runSqlButton = findElementByDataTestId(fixture, "runSqlQueryButton") as HTMLButtonElement;
appDatasetSubsService.observeSqlErrorOccurred(mockSqlErrorUpdate);

fixture.detectChanges();
expect(component.currentData).toEqual([]);
expect(component.currentSchema).toEqual(null);
expect(component.sqlErrorMarker).toBe(mockSqlErrorUpdate.error);
expect(runSqlButton.disabled).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export class DataComponent extends BaseComponent implements OnInit {

public ngOnInit(): void {
this.trackSubscriptions(
this.appDatasetSubsService.onDatasetDataSqlErrorOccured.subscribe(
(dataSqlErrorUpdate: DataSqlErrorUpdate) => {
this.sqlErrorMarker = dataSqlErrorUpdate.error;
this.cdr.markForCheck();
},
),
EvilAlexei marked this conversation as resolved.
Show resolved Hide resolved
this.appDatasetSubsService.onDatasetDataChanges.subscribe((dataUpdate: DataUpdate) => {
if (dataUpdate.currentVocab?.offsetColumn) {
this.offsetColumnName = dataUpdate.currentVocab.offsetColumn;
Expand All @@ -60,14 +66,6 @@ export class DataComponent extends BaseComponent implements OnInit {
this.sqlErrorMarker = null;
this.cdr.markForCheck();
}),
this.appDatasetSubsService.onDatasetDataSqlErrorOccured.subscribe(
(dataSqlErrorUpdate: DataSqlErrorUpdate) => {
this.currentData = [];
this.currentSchema = null;
this.sqlErrorMarker = dataSqlErrorUpdate.error;
this.cdr.markForCheck();
},
),
);
this.buildSqlRequestCode();
}
Expand Down
8 changes: 2 additions & 6 deletions src/app/dataset-view/dataset.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,12 @@ describe("AppDatasetService", () => {
/* Intentionally blank */
});

const subscriptionErrorChanges$ = appDatasetSubsService.onDatasetDataSqlErrorOccured
.pipe(first())
.subscribe(() => {
/* Intentionally blank */
});
const subscriptionErrorChangesSpy = spyOn(appDatasetSubsService, "observeSqlErrorOccurred");

service.requestDatasetDataSqlRun(query, limit).subscribe();

expect(subscriptionDataChanges$.closed).toBeTrue();
expect(subscriptionErrorChanges$.closed).toBeFalse();
expect(subscriptionErrorChangesSpy).toHaveBeenCalledWith({ error: "" });
});

it("should check get SQL query data from api with invalid SQL", () => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/dataset-view/dataset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ export class DatasetService {
currentVocab: this.currentSetVocab,
};
this.appDatasetSubsService.changeDatasetData(dataUpdate);
this.appDatasetSubsService.observeSqlErrorOccurred({
error: "",
});
} else if (queryResult.errorKind === DataQueryResultErrorKind.InvalidSql) {
this.appDatasetSubsService.observeSqlErrorOccurred({
error: queryResult.errorMessage,
Expand Down
4 changes: 2 additions & 2 deletions src/assets/styles/var.sass
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ $app-color-action-list-item-inline-divider: #d0d7de7a
border-radius: 1px
position: relative
float: left
border-color: $app-color-border-default
border-color: $app-color-border-default!important
zaychenko-sergei marked this conversation as resolved.
Show resolved Hide resolved
height: inherit
background: $app-aliceBlue
zaychenko-sergei marked this conversation as resolved.
Show resolved Hide resolved
&:last-child
Expand Down Expand Up @@ -245,7 +245,7 @@ $app-color-action-list-item-inline-divider: #d0d7de7a
background-color: $app-color-btn-counter-bg
.btn:hover, .btn.hover, [open]>.btn
background-color: $app-color-btn-hover-bg
border-color: $app-color-btn-hover-border
border-color: $app-color-btn-hover-border !important
zaychenko-sergei marked this conversation as resolved.
Show resolved Hide resolved
transition-duration: .1s
.SelectMenu-modal
position: relative
Expand Down
Loading