@gravitee/ui-schematics 12.10.0 → 12.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/schematics/collection.json +6 -0
- package/schematics/components/component-for-dialog/files/__name@dasherize__-dialog.component.html.template +28 -0
- package/schematics/components/component-for-dialog/files/__name@dasherize__-dialog.component.scss.template +15 -0
- package/schematics/components/component-for-dialog/files/__name@dasherize__-dialog.component.spec.ts.template +109 -0
- package/schematics/components/component-for-dialog/files/__name@dasherize__-dialog.component.ts.template +37 -0
- package/schematics/components/component-for-dialog/files/__name@dasherize__-dialog.harness.ts.template +54 -0
- package/schematics/components/component-for-dialog/files/__name@dasherize__-dialog.stories.ts.template +57 -0
- package/schematics/components/component-for-dialog/index.d.ts +3 -0
- package/schematics/components/component-for-dialog/index.js +9 -0
- package/schematics/components/component-for-dialog/index.js.map +1 -0
- package/schematics/components/component-for-dialog/schema.json +63 -0
package/package.json
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
"factory": "./components/component-with-table/index#createComponentWithTable",
|
|
19
19
|
"schema": "./components/component-with-table/schema.json",
|
|
20
20
|
"aliases": ["cwt"]
|
|
21
|
+
},
|
|
22
|
+
"component-for-dialog": {
|
|
23
|
+
"description": "Generate a component to use with MatDialog in the project.",
|
|
24
|
+
"factory": "./components/component-for-dialog/index#createComponentForDialog",
|
|
25
|
+
"schema": "./components/component-for-dialog/schema.json",
|
|
26
|
+
"aliases": ["cfd"]
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
|
|
17
|
+
-->
|
|
18
|
+
<span mat-dialog-title><%= name %> Dialog</span>
|
|
19
|
+
|
|
20
|
+
<mat-dialog-content>
|
|
21
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vel odio nec mi
|
|
22
|
+
</mat-dialog-content>
|
|
23
|
+
|
|
24
|
+
<mat-dialog-actions align="end">
|
|
25
|
+
<button mat-flat-button [mat-dialog-close]="false">Close</button>
|
|
26
|
+
<button mat-raised-button [mat-dialog-close]="true">My action</button>
|
|
27
|
+
</mat-dialog-actions>
|
|
28
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2021 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/*
|
|
17
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License.
|
|
21
|
+
* You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
32
|
+
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
|
33
|
+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
34
|
+
import { Component } from '@angular/core';
|
|
35
|
+
import { HarnessLoader } from '@angular/cdk/testing';
|
|
36
|
+
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
|
37
|
+
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
38
|
+
|
|
39
|
+
import { <%= classify(name) %>DialogHarness } from './<%= dasherize(name) %>-dialog.harness';
|
|
40
|
+
import { <%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult } from './<%= dasherize(name) %>-dialog.component';
|
|
41
|
+
|
|
42
|
+
@Component({
|
|
43
|
+
selector: 'test-component',
|
|
44
|
+
template: ``,
|
|
45
|
+
imports: [<%= classify(name) %>DialogComponent, MatDialogModule, MatIconTestingModule],
|
|
46
|
+
standalone: true,
|
|
47
|
+
})
|
|
48
|
+
class SpecDialogComponent {
|
|
49
|
+
constructor(private readonly matDialog: MatDialog) {}
|
|
50
|
+
|
|
51
|
+
public open(data?: <%= classify(name) %>DialogData) {
|
|
52
|
+
return this.matDialog.open<<%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult>(<%= classify(name) %>DialogComponent, {
|
|
53
|
+
data,
|
|
54
|
+
role: 'dialog',
|
|
55
|
+
id: 'test-dialog',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe('<%= classify(name) %>DialogComponent', () => {
|
|
61
|
+
let fixture: ComponentFixture<SpecDialogComponent>;
|
|
62
|
+
let loader: HarnessLoader;
|
|
63
|
+
|
|
64
|
+
beforeEach(async () => {
|
|
65
|
+
await TestBed.configureTestingModule({
|
|
66
|
+
imports: [NoopAnimationsModule],
|
|
67
|
+
}).compileComponents();
|
|
68
|
+
|
|
69
|
+
fixture = TestBed.createComponent(SpecDialogComponent);
|
|
70
|
+
fixture.detectChanges();
|
|
71
|
+
loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should open dialog', async () => {
|
|
75
|
+
fixture.componentInstance.open();
|
|
76
|
+
|
|
77
|
+
const dialog = await loader.getHarness(<%= classify(name) %>DialogHarness);
|
|
78
|
+
|
|
79
|
+
expect(await dialog.getTitleText()).toEqual('<%= classify(name) %> Dialog');
|
|
80
|
+
expect(await dialog.getContentText()).toContain('Lorem');
|
|
81
|
+
expect(await dialog.getActionsText()).toContain('My action');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should close dialog', async () => {
|
|
85
|
+
let dialogResult: undefined | boolean;
|
|
86
|
+
fixture.componentInstance
|
|
87
|
+
.open()
|
|
88
|
+
.afterClosed()
|
|
89
|
+
.subscribe(result => (dialogResult = result));
|
|
90
|
+
|
|
91
|
+
const dialog = await loader.getHarness(<%= classify(name) %>DialogHarness);
|
|
92
|
+
|
|
93
|
+
await dialog.close();
|
|
94
|
+
expect(dialogResult).toEqual(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should validate & close dialog', async () => {
|
|
98
|
+
let dialogResult: undefined | boolean;
|
|
99
|
+
fixture.componentInstance
|
|
100
|
+
.open()
|
|
101
|
+
.afterClosed()
|
|
102
|
+
.subscribe(result => (dialogResult = result));
|
|
103
|
+
|
|
104
|
+
const dialog = await loader.getHarness(<%= classify(name) %>DialogHarness);
|
|
105
|
+
|
|
106
|
+
await dialog.confirmMyAction();
|
|
107
|
+
expect(dialogResult).toEqual(true);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Component, Inject } from '@angular/core';
|
|
17
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
18
|
+
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
|
19
|
+
|
|
20
|
+
export interface <%= classify(name) %>DialogData {}
|
|
21
|
+
|
|
22
|
+
export type <%= classify(name) %>DialogResult = boolean;
|
|
23
|
+
|
|
24
|
+
@Component({
|
|
25
|
+
selector: '<%= dasherize(name) %>-dialog',
|
|
26
|
+
templateUrl: './<%= dasherize(name) %>-dialog.component.html',
|
|
27
|
+
styleUrls: ['./<%= dasherize(name) %>-dialog.component.scss'],
|
|
28
|
+
standalone: true,
|
|
29
|
+
imports: [MatDialogModule, MatButtonModule],
|
|
30
|
+
})
|
|
31
|
+
export class <%= classify(name) %>DialogComponent {
|
|
32
|
+
constructor(
|
|
33
|
+
@Inject(MAT_DIALOG_DATA)
|
|
34
|
+
public data: <%= classify(name) %>DialogData,
|
|
35
|
+
public dialogRef: MatDialogRef<<%= classify(name) %>DialogComponent, <%= classify(name) %>DialogResult>,
|
|
36
|
+
) {}
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
17
|
+
import { MatDialogSection } from '@angular/material/dialog/testing';
|
|
18
|
+
import { MatButtonHarness } from '@angular/material/button/testing';
|
|
19
|
+
|
|
20
|
+
export interface <%= classify(name) %>DialogHarnessOptions extends BaseHarnessFilters {}
|
|
21
|
+
|
|
22
|
+
export class <%= classify(name) %>DialogHarness extends ComponentHarness {
|
|
23
|
+
public static readonly hostSelector = `<%= dasherize(name) %>-dialog`;
|
|
24
|
+
|
|
25
|
+
public static with(options: <%= classify(name) %>DialogHarnessOptions): HarnessPredicate<<%= classify(name) %>DialogHarness> {
|
|
26
|
+
return new HarnessPredicate(<%= classify(name) %>DialogHarness, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
protected _title = this.locatorForOptional(MatDialogSection.TITLE);
|
|
30
|
+
protected _content = this.locatorForOptional(MatDialogSection.CONTENT);
|
|
31
|
+
protected _actions = this.locatorForOptional(MatDialogSection.ACTIONS);
|
|
32
|
+
|
|
33
|
+
public async getTitleText(): Promise<string> {
|
|
34
|
+
return (await this._title())?.text() ?? '';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async getContentText(): Promise<string> {
|
|
38
|
+
return (await this._content())?.text() ?? '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async getActionsText(): Promise<string> {
|
|
42
|
+
return (await this._actions())?.text() ?? '';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async close(): Promise<void> {
|
|
46
|
+
const closeButton = await this.locatorFor(MatButtonHarness.with({ text: /Close/ }))();
|
|
47
|
+
await closeButton.click();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async confirmMyAction(): Promise<void> {
|
|
51
|
+
const confirmButton = await this.locatorFor(MatButtonHarness.with({ text: /My action/ }))();
|
|
52
|
+
await confirmButton.click();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Meta, StoryObj } from '@storybook/angular';
|
|
17
|
+
import { Component } from '@angular/core';
|
|
18
|
+
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
19
|
+
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
|
20
|
+
import { action } from '@storybook/addon-actions';
|
|
21
|
+
|
|
22
|
+
import { <%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult } from './<%= dasherize(name) %>-dialog.component';
|
|
23
|
+
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'story-component',
|
|
26
|
+
template: `<button id="open-dialog" (click)="open()">Open dialog</button>`,
|
|
27
|
+
imports: [<%= classify(name) %>DialogComponent, MatDialogModule, MatIconTestingModule],
|
|
28
|
+
standalone: true,
|
|
29
|
+
})
|
|
30
|
+
class StoryDialogComponent {
|
|
31
|
+
constructor(private readonly matDialog: MatDialog) {}
|
|
32
|
+
|
|
33
|
+
public open(data?: <%= classify(name) %>DialogData) {
|
|
34
|
+
return this.matDialog
|
|
35
|
+
.open<<%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult>(<%= classify(name) %>DialogComponent, {
|
|
36
|
+
data,
|
|
37
|
+
role: 'dialog',
|
|
38
|
+
id: 'test-story-dialog',
|
|
39
|
+
})
|
|
40
|
+
.afterClosed()
|
|
41
|
+
.subscribe(result => {
|
|
42
|
+
action('Close')({ result });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
title: '<%= classify(name) %>DialogComponent story',
|
|
49
|
+
component: StoryDialogComponent,
|
|
50
|
+
} as Meta;
|
|
51
|
+
|
|
52
|
+
export const Default: StoryObj = {
|
|
53
|
+
play: context => {
|
|
54
|
+
const button = context.canvasElement.querySelector('#open-dialog') as HTMLButtonElement;
|
|
55
|
+
button.click();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createComponentForDialog = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function createComponentForDialog(options) {
|
|
6
|
+
return (0, utils_1.createComponent)(options);
|
|
7
|
+
}
|
|
8
|
+
exports.createComponentForDialog = createComponentForDialog;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/ui-schematics/schematics/components/component-for-dialog/index.ts"],"names":[],"mappings":";;;AAiBA,oCAA2C;AAG3C,SAAgB,wBAAwB,CAAC,OAAe;IACtD,OAAO,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,4DAEC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "GioComponentForDialog",
|
|
4
|
+
"title": "A Component for dialog use",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"module": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The declaring NgModule."
|
|
10
|
+
},
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The name of the component. (without `-dialog` suffix)",
|
|
14
|
+
"$default": {
|
|
15
|
+
"$source": "argv",
|
|
16
|
+
"index": 0
|
|
17
|
+
},
|
|
18
|
+
"x-prompt": "What name would you like to use for the component? (without `-dialog` suffix)"
|
|
19
|
+
},
|
|
20
|
+
"path": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"format": "path",
|
|
23
|
+
"description": "The path at which to create the component file, relative to the current workspace. Default is a folder with the same name as the component in the project root.",
|
|
24
|
+
"visible": false
|
|
25
|
+
},
|
|
26
|
+
"prefix": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "The prefix to apply to the generated component selector.",
|
|
29
|
+
"oneOf": [
|
|
30
|
+
{
|
|
31
|
+
"maxLength": 0
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"minLength": 1,
|
|
35
|
+
"format": "html-selector"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"project": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "The name of the project.",
|
|
42
|
+
"$default": {
|
|
43
|
+
"$source": "projectName"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"selector": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"format": "html-selector",
|
|
49
|
+
"description": "The HTML selector to use for this component."
|
|
50
|
+
},
|
|
51
|
+
"skipImport": {
|
|
52
|
+
"type": "boolean",
|
|
53
|
+
"description": "Do not import this component into the owning NgModule.",
|
|
54
|
+
"default": false
|
|
55
|
+
},
|
|
56
|
+
"skipStories": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Do not create \"stories.ts\" storybook file for the new component.",
|
|
59
|
+
"default": false
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"required": ["name"]
|
|
63
|
+
}
|