Skip to content

Commit 3e55094

Browse files
committed
feat: implement to open meshStack link to open in a new tab to use template
* update dependencies * fix spellings and minor improvements CU-86c2nhgk4
1 parent 75f482b commit 3e55094

File tree

7 files changed

+785
-289
lines changed

7 files changed

+785
-289
lines changed

website/package.json

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
},
1515
"private": true,
1616
"dependencies": {
17-
"@angular/common": "^19.2.0",
18-
"@angular/compiler": "^19.2.0",
19-
"@angular/core": "^19.2.0",
20-
"@angular/forms": "^19.2.0",
21-
"@angular/platform-browser": "^19.2.0",
22-
"@angular/platform-browser-dynamic": "^19.2.0",
23-
"@angular/platform-server": "^19.2.0",
24-
"@angular/router": "^19.2.0",
25-
"@angular/ssr": "^19.2.3",
17+
"@angular/common": "19.2.5",
18+
"@angular/compiler": "19.2.5",
19+
"@angular/core": "19.2.5",
20+
"@angular/forms": "19.2.5",
21+
"@angular/platform-browser": "19.2.5",
22+
"@angular/platform-browser-dynamic": "19.2.5",
23+
"@angular/platform-server": "19.2.5",
24+
"@angular/router": "19.2.5",
25+
"@angular/ssr": "19.2.5",
2626
"@fontsource/montserrat": "^5.2.5",
2727
"@fontsource/roboto": "^5.2.5",
2828
"@fortawesome/fontawesome-free": "^6.7.2",
@@ -44,23 +44,33 @@
4444
"@angular-eslint/schematics": "19.2.1",
4545
"@angular-eslint/template-parser": "19.2.1",
4646
"@angular/cli": "^19.2.3",
47-
"@angular/compiler-cli": "^19.2.0",
47+
"@angular/compiler-cli": "19.2.5",
48+
"@angular/localize": "19.2.5",
4849
"@types/express": "^4.17.17",
4950
"@types/jasmine": "~5.1.0",
5051
"@types/node": "20",
5152
"@typescript-eslint/eslint-plugin": "^8.28.0",
5253
"@typescript-eslint/parser": "^8.28.0",
54+
"@typescript-eslint/types": "^8.0.0",
55+
"@typescript-eslint/utils": "^8.0.0",
5356
"angular-eslint": "19.2.1",
54-
"eslint": "^9.23.0",
55-
"eslint-import-resolver-typescript": "^4.2.4",
57+
"eslint": "^8.57.0",
58+
"eslint-import-resolver-typescript": "^3.6.1",
59+
"eslint-plugin-import": "2.25.2",
60+
"eslint-plugin-jasmine": "^4.2.2",
61+
"eslint-plugin-jsdoc": "^43.0.5",
62+
"eslint-plugin-local-rules": "^3.0.2",
63+
"eslint-plugin-prefer-arrow": "1.2.2",
5664
"jasmine-core": "~5.6.0",
5765
"karma": "~6.4.0",
5866
"karma-chrome-launcher": "~3.2.0",
5967
"karma-coverage": "~2.2.0",
6068
"karma-jasmine": "~5.1.0",
6169
"karma-jasmine-html-reporter": "~2.1.0",
6270
"prettier": "^3.5.3",
63-
"typescript": "~5.7.2"
71+
"typescript": "~5.7.2",
72+
"typescript-eslint": "^8.0.0",
73+
"vite": "^5.0.0"
6474
},
6575
"engines": {
6676
"node": "^20.0"

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,32 @@
1515
<h4 class="card-title fw-bold">Provide link of your meshStack</h4>
1616
<h5 class="card-text mt-3">to continue using this building block template</h5>
1717
<div class="pt-4 text-start">
18-
<form [formGroup]="form" (ngSubmit)="open()">
19-
<label class="form-label" for="meshStackUrl">meshStack URL</label>
18+
<form [formGroup]="form" (ngSubmit)="openMeshStackUrl()">
19+
<label class="form-label" for="meshStackUrl">Your meshStack URL</label>
2020
<input
2121
type="text"
2222
class="form-control"
2323
aria-label="meshStack URL"
2424
formControlName="meshStackUrl"
25-
(keyup.enter)="open()"
2625
placeholder="Enter your meshStack URL"
2726
/>
2827
</form>
2928
</div>
30-
<a [href]="meshStackUrl" class="btn btn-primary mt-4" (click)="open()" target="_blank" rel="noopener noreferrer">
29+
<button
30+
type="submit"
31+
class="btn btn-primary mt-4"
32+
[disabled]="!form.valid"
33+
aria-label="Open up meshStack to add template"
34+
(click)="openMeshStackUrl()"
35+
>
3136
Add to meshStack
3237
<i class="fa-solid fa-arrow-up-right-from-square ms-2"></i>
33-
</a>
38+
</button>
3439
<hr />
3540
<div class="pt-3">
3641
<p>Don't use meshStack yet?</p>
37-
<p>Check out and how it can help your platform team</p>
38-
<a href="https://www.meshcloud.io/en/book-demo" class="btn btn-outline-primary mt-2" (click)="open()">
42+
<p>Check it out and how it can help your platform team</p>
43+
<a href="https://www.meshcloud.io/en/book-demo" class="btn btn-outline-primary mt-2">
3944
Discover meshStack
4045
<img src="assets/meshstack-logo.png" alt="meshStack Logo" class="button-image" />
4146
</a>
Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
1+
import { isPlatformBrowser } from '@angular/common';
2+
import { Component, Inject, Input, OnInit, PLATFORM_ID } from '@angular/core';
3+
import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
34
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
45

6+
interface ImportDialogForm {
7+
meshStackUrl: FormControl<string>;
8+
}
9+
510
@Component({
611
selector: 'mst-import-dialog',
712
imports: [ReactiveFormsModule],
@@ -10,25 +15,42 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
1015
})
1116
export class ImportDialogComponent implements OnInit {
1217

13-
public form!: FormGroup;
18+
@Input()
19+
public name!: string;
1420

15-
public get meshStackUrl() {
16-
return this.form.get('meshStackUrl')?.value;
17-
}
21+
@Input()
22+
public modulePath!: string;
23+
24+
public form!: FormGroup<ImportDialogForm>;
1825

1926
constructor(
27+
@Inject(PLATFORM_ID) private platformId: object,
2028
public activeModal: NgbActiveModal,
2129
private fb: FormBuilder
2230
) { }
2331

2432
ngOnInit(): void {
2533
this.form = this.fb.group({
26-
meshStackUrl: ['']
34+
meshStackUrl: this.fb.nonNullable.control('', [Validators.required, Validators.pattern(/^(https?:\/\/).*/)]),
2735
});
2836
}
2937

30-
public open() {
31-
38+
public openMeshStackUrl() {
39+
// Only runs in browser, not during SSR
40+
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);
44+
window.open(url.toString(), '_blank', 'noopener,noreferrer');
45+
}
3246
}
3347

48+
private getSanitizedMeshStackUrl(): string {
49+
let meshStackUrl = this.form.controls.meshStackUrl.value;
50+
if (meshStackUrl.endsWith('/')) {
51+
meshStackUrl = meshStackUrl.slice(0, -1);
52+
}
53+
54+
return meshStackUrl;
55+
}
3456
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ng-container *ngIf="template$ | async as template">
44
<nav aria-label="breadcrumb">
55
<ol class="breadcrumb">
6-
<li class="breadcrumb-item ps-0"><a href="#">meshStack Hub</a></li>
6+
<li class="breadcrumb-item ps-0"><a href="#">Overview</a></li>
77
<li class="breadcrumb-item active" aria-current="page">{{ template.name }}</li>
88
</ol>
99
</nav>
@@ -79,7 +79,7 @@ <h3 class="fw-bold h6">Option 2: Copy the Files into your own Repository</h3>
7979

8080
<div class="pt-5 d-flex justify-content-end">
8181
<a href="#" class="btn btn-outline-primary me-2">Go Back</a>
82-
<button class="btn btn-primary" (click)="open()">Use template</button>
82+
<button class="btn btn-primary" (click)="open(template)">Add to meshStack</button>
8383
</div>
8484
</div>
8585
</div>

website/src/app/features/template-details/template-details.component.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
line-height: 2rem;
2828
}
2929

30-
.breadcrumb-item+.breadcrumb-item::before {
31-
content: "\f054";
32-
font-family: "Font Awesome 6 Free";
30+
.breadcrumb-item + .breadcrumb-item::before {
31+
content: '\f054';
32+
font-family: 'Font Awesome 6 Free';
3333
font-weight: 900;
34-
color: gray
35-
}
34+
color: gray;
35+
}

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,25 @@ export class TemplateDetailsComponent implements OnInit, OnDestroy {
7171
this.copyLabel = 'Copy';
7272
}, 1000);
7373
})
74-
.catch(e => console.log(e));
74+
.catch(e =>
75+
/* eslint-disable-next-line */
76+
console.log(e)
77+
);
7578
}
7679

77-
public open() {
78-
this.modalService.open(ImportDialogComponent, { size: 'lg', centered: true });
80+
public open(template: TemplateDetailsVm) {
81+
const regex = /modules\/[^\/]+\/[^\/]+/;
82+
const match = template.source.match(regex);
83+
const modulePath = match ? match[0] : '';
84+
85+
if (!modulePath) {
86+
/* eslint-disable-next-line */
87+
console.error('Module path not found in source URL');
88+
} else {
89+
const component = this.modalService.open(ImportDialogComponent, { size: 'lg', centered: true }).componentInstance;
90+
component.name = template.name;
91+
component.modulePath = modulePath;
92+
}
7993
}
8094

8195
}

0 commit comments

Comments
 (0)