Skip to content

Commit

Permalink
Correct split 'command' key.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Borzenko committed Jul 20, 2023
1 parent 4602cb4 commit 7c29d69
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/app/common/app.values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class AppValues {
public static readonly URL_PATTERN = /^(http:\/\/)|(https:\/\/)/i;
public static readonly SCHEMA_NAME_PATTERN =
/^[a-zA-Z0-9]+[a-zA-Z0-9\s(_)]*$/i;
public static readonly SPLIT_ARGUMENTS_PATTERN = /\w+|"[^"]+"/g;

public static readonly DISPLAY_DATE_FORMAT = "DD MMM YYYY";
public static readonly DISPLAY_TOOLTIP_DATE_FORMAT = "MMM D, YYYY, HH:mm A";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export enum PrepareKind {
DECOMPRESS = "decompress",
}

export enum DecompressFormat {
ZIP = "zip",
GZIP = "gzip",
}

export enum PreprocessKind {
SQL = "sql",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
FetchKind,
PrepareKind,
} from "./add-polling-source-form.types";
import AppValues from "src/app/common/app.values";

@Injectable({
providedIn: "root",
Expand Down Expand Up @@ -51,7 +52,9 @@ export class ProcessFormService {
item.kind === PrepareKind.PIPE &&
typeof item.command === "string"
) {
item.command = item.command.trim().split(" ");
item.command = item.command
.trim()
.match(AppValues.SPLIT_ARGUMENTS_PATTERN) as string[];
}
if (item.kind === PrepareKind.DECOMPRESS && !item.subPath) {
delete item.subPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { SetPollingSourceSection } from "src/app/shared/shared.types";
import { MatIconModule } from "@angular/material/icon";
import { mockSetPollingSourceEventYaml } from "../../../set-transform/mock.data";
import { emitClickOnElementByDataTestId } from "src/app/common/base-test.helpers.spec";
import { PrepareKind } from "../../add-polling-source-form.types";
import {
DecompressFormat,
PrepareKind,
} from "../../add-polling-source-form.types";

describe("PrepareStepComponent", () => {
let component: PrepareStepComponent;
Expand Down Expand Up @@ -55,7 +58,7 @@ describe("PrepareStepComponent", () => {
it("should check add decompress", () => {
const result = {
kind: PrepareKind.DECOMPRESS,
format: "",
format: DecompressFormat.ZIP,
subPath: "",
};
component.sectionForm.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import {
import { MaybeNull } from "src/app/common/app.types";
import { BaseComponent } from "src/app/common/base.component";
import { SetPollingSourceSection } from "src/app/shared/shared.types";
import { EditFormType, PrepareKind } from "../../add-polling-source-form.types";
import {
DecompressFormat,
EditFormType,
PrepareKind,
} from "../../add-polling-source-form.types";
import { EditPollingSourceService } from "../../edit-polling-source.service";
import { RxwebValidators } from "@rxweb/reactive-form-validators";

@Component({
selector: "app-prepare-step",
Expand Down Expand Up @@ -101,7 +104,7 @@ export class PrepareStepComponent extends BaseComponent implements OnInit {
this.sectionForm.push(
this.fb.group({
kind: this.fb.control(PrepareKind.DECOMPRESS),
format: this.fb.control("zip"),
format: this.fb.control(DecompressFormat.ZIP),
subPath: this.fb.control(""),
}),
);
Expand Down

0 comments on commit 7c29d69

Please sign in to comment.