Skip to content

Commit d4e8f87

Browse files
committed
feat: fix logic to open url
* display error message if url is not valid CU-86c2nhgk4
1 parent 201f25a commit d4e8f87

File tree

3 files changed

+21
-28
lines changed

3 files changed

+21
-28
lines changed

website/src/app/app.component.spec.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,5 @@ describe('AppComponent', () => {
1616
expect(app)
1717
.toBeTruthy();
1818
});
19-
20-
it('should have the \'meshstack-hub\' title', () => {
21-
const fixture = TestBed.createComponent(AppComponent);
22-
const app = fixture.componentInstance;
23-
expect(app.title)
24-
.toEqual('meshstack-hub');
25-
});
26-
27-
it('should render title', () => {
28-
const fixture = TestBed.createComponent(AppComponent);
29-
fixture.detectChanges();
30-
const compiled = fixture.nativeElement as HTMLElement;
31-
expect(compiled.querySelector('h1')?.textContent)
32-
.toContain('Hello, meshstack-hub');
33-
});
3419
});
20+

website/src/app/features/template-details/import-dialog/import-dialog.component.html

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@ <h5 class="card-text mt-3">to continue using this building block template</h5>
1717
<div class="pt-4 text-start">
1818
<form [formGroup]="form" (ngSubmit)="openMeshStackUrl()">
1919
<label class="form-label" for="meshStackUrl">Your meshStack URL</label>
20-
<input
21-
type="text"
22-
class="form-control"
23-
aria-label="meshStack URL"
24-
formControlName="meshStackUrl"
25-
placeholder="Enter your meshStack URL"
26-
/>
20+
<div class="ms-2">
21+
<input
22+
type="text"
23+
class="form-control"
24+
aria-label="meshStack URL"
25+
formControlName="meshStackUrl"
26+
placeholder="Enter your meshStack URL"
27+
/>
28+
<div
29+
*ngIf="form.controls.meshStackUrl.invalid && form.controls.meshStackUrl.touched"
30+
class="mt-1 text-danger small"
31+
>
32+
Please enter a valid URL.
33+
</div>
34+
</div>
2735
</form>
2836
</div>
2937
<button

website/src/app/features/template-details/import-dialog/import-dialog.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isPlatformBrowser } from '@angular/common';
1+
import { CommonModule, isPlatformBrowser } from '@angular/common';
22
import { Component, Inject, Input, OnInit, PLATFORM_ID } from '@angular/core';
33
import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
44
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@@ -9,9 +9,10 @@ interface ImportDialogForm {
99

1010
@Component({
1111
selector: 'mst-import-dialog',
12-
imports: [ReactiveFormsModule],
12+
imports: [CommonModule, ReactiveFormsModule],
1313
templateUrl: './import-dialog.component.html',
14-
styleUrl: './import-dialog.component.scss'
14+
styleUrl: './import-dialog.component.scss',
15+
standalone: true
1516
})
1617
export class ImportDialogComponent implements OnInit {
1718

@@ -38,9 +39,7 @@ export class ImportDialogComponent implements OnInit {
3839
public openMeshStackUrl() {
3940
// Only runs in browser, not during SSR
4041
if (isPlatformBrowser(this.platformId)) {
41-
const url = new URL(this.getSanitizedMeshStackUrl());
42-
url.searchParams.set('module-path', this.modulePath);
43-
url.searchParams.set('name', this.name);
42+
const url = this.getSanitizedMeshStackUrl() + '/#/building-block-definition-import?name=' + this.name + '&module-path=' + this.modulePath;
4443
window.open(url.toString(), '_blank', 'noopener,noreferrer');
4544
}
4645
}

0 commit comments

Comments
 (0)