});
}
- add(hostname: string, exist?: boolean, maintenance?: boolean) {
+ add(hostname: string, exist?: boolean, maintenance?: boolean, labels: string[] = []) {
cy.get(`${this.pages.add.id}`).within(() => {
cy.get('#hostname').type(hostname);
if (maintenance) {
if (exist) {
cy.get('#hostname').should('have.class', 'ng-invalid');
}
- cy.get('cd-submit-button').click();
});
+
+ if (labels.length) {
+ this.selectPredefinedLabels(labels);
+ }
+
+ cy.get('cd-submit-button').click();
// back to host list
cy.get(`${this.pages.index.id}`);
}
+ selectPredefinedLabels(labels: string[]) {
+ cy.get('a[data-testid=select-menu-edit]').click();
+ for (const label of labels) {
+ cy.get('.popover-body div.select-menu-item-content').contains(label).click();
+ }
+ }
+
checkExist(hostname: string, exist: boolean) {
this.clearTableSearchInput();
this.getTableCell(this.columnIndex.hostname, hostname).should(($elements) => {
'ceph-node-02.cephlab.com',
'ceph-node-[01-02].cephlab.com'
];
- const addHost = (hostname: string, exist?: boolean, pattern?: boolean) => {
+ const addHost = (hostname: string, exist?: boolean, pattern?: boolean, labels: string[] = []) => {
cy.get('.btn.btn-accent').first().click({ force: true });
- createClusterHostPage.add(hostname, exist, false);
+ createClusterHostPage.add(hostname, exist, false, labels);
if (!pattern) {
createClusterHostPage.checkExist(hostname, true);
}
addHost(hostnames[3], false, true);
});
- it('should delete a host and add it back', () => {
+ it('should delete a host', () => {
createClusterHostPage.delete(hostnames[1]);
- addHost(hostnames[1], false);
+ });
+
+ it('should add a host with some predefined labels and verify it', () => {
+ const labels = ['mon', 'mgr', 'rgw', 'osd'];
+ addHost(hostnames[1], false, false, labels);
+ createClusterHostPage.checkLabelExists(hostnames[1], labels, true);
});
it('should verify "_no_schedule" label is added', () => {
<div class="cd-col-form-input">
<cd-select-badges id="labels"
[data]="hostForm.controls.labels.value"
+ [options]="labelsOption"
[customBadges]="true"
[messages]="messages">
</cd-select-badges>
import { HostService } from '~/app/shared/api/host.service';
import { SelectMessages } from '~/app/shared/components/select/select-messages.model';
+import { SelectOption } from '~/app/shared/components/select/select-option.model';
import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants';
import { CdForm } from '~/app/shared/forms/cd-form';
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
allLabels: string[];
pageURL: string;
hostPattern = false;
+ labelsOption: Array<SelectOption> = [];
messages = new SelectMessages({
empty: $localize`There are no labels.`,
});
this.loadingReady();
});
+
+ this.hostService.getLabels().subscribe((resp: string[]) => {
+ const uniqueLabels = new Set(resp.concat(this.hostService.predefinedLabels));
+ this.labelsOption = Array.from(uniqueLabels).map((label) => {
+ return { enabled: true, name: label, selected: false, description: null };
+ });
+ });
}
// check if hostname is a single value or pattern to hide network address field
editAction() {
this.hostService.getLabels().subscribe((resp: string[]) => {
const host = this.selection.first();
- const allLabels = resp.map((label) => {
+ const labels = new Set(resp.concat(this.hostService.predefinedLabels));
+ const allLabels = Array.from(labels).map((label) => {
return { enabled: true, name: label };
});
this.modalService.show(FormModalComponent, {
baseURL = 'api/host';
baseUIURL = 'ui-api/host';
+ predefinedLabels = ['mon', 'mgr', 'osd', 'mds', 'rgw', 'nfs', 'iscsi', 'rbd', 'grafana'];
+
constructor(private http: HttpClient, private deviceService: DeviceService) {
super();
}
<a class="select-menu-edit float-left"
[ngClass]="elemClass"
[ngbPopover]="popTemplate"
+ data-testid="select-menu-edit"
*ngIf="customBadges || options.length > 0">
<ng-content></ng-content>
</a>