<cd-form-button-panel
(submitActionEvent)="submit()"
[form]="formDir"
- [submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
+ [submitText]="submitAction"
wrappingClass="text-right"
></cd-form-button-panel>
</form>
action: string;
resource: string;
+ submitAction: string;
private rbdImage = new ReplaySubject(1);
private routerUrl: string;
if (url.startsWith('/block/rbd/edit')) {
this.mode = this.rbdFormMode.editing;
this.action = this.actionLabels.EDIT;
+ this.submitAction = this.actionLabels.SAVE_CHANGES;
this.disableForEdit();
} else if (url.startsWith('/block/rbd/clone')) {
this.mode = this.rbdFormMode.cloning;
this.disableForClone();
this.action = this.actionLabels.CLONE;
+ this.submitAction = `${this.action} ${this.resource}`;
} else if (url.startsWith('/block/rbd/copy')) {
this.mode = this.rbdFormMode.copying;
this.action = this.actionLabels.COPY;
+ this.submitAction = `${this.action} ${this.resource}`;
this.disableForCopy();
} else {
this.action = this.actionLabels.CREATE;
+ this.submitAction = `${this.action} ${this.resource}`;
}
_.each(this.features, (feature) => {
this.rbdForm
import { CoreModule } from '~/app/core/core.module';
import { HostService } from '~/app/shared/api/host.service';
import { OrchestratorService } from '~/app/shared/api/orchestrator.service';
+import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
import { TableActionsComponent } from '~/app/shared/datatable/table-actions/table-actions.component';
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
expect(showForceMaintenanceModal.showModal).toBeFalsy();
});
+ it('should set host edit modal submit label to Save changes', () => {
+ const hostService = TestBed.inject(HostService);
+ const modalService = TestBed.inject(ModalCdsService);
+ spyOn(hostService, 'getLabels').and.returnValue(of([]));
+ const showSpy = spyOn(modalService, 'show').and.stub();
+
+ component.selection = new CdTableSelection();
+ component.selection.selected = [{ hostname: 'host-test', labels: [] }];
+
+ component.editAction();
+
+ expect(showSpy).toHaveBeenCalled();
+ expect(showSpy.calls.mostRecent().args[1].submitButtonText).toBe('Save changes');
+ });
+
describe('table actions', () => {
const fakeHosts = require('./fixtures/host_list_response.json');
<cd-form-button-panel
(submitActionEvent)="onSubmit()"
[form]="serviceForm"
- [submitText]="(action | titlecase) + ' ' + resource"
+ [submitText]="submitAction"
[modalForm]="true"
></cd-form-button-panel>
</cds-modal>
serviceForm: CdFormGroup;
action: string;
resource: string;
+ submitAction: string;
serviceTypes: string[] = [];
serviceIds: string[] = [];
selectedHosts: string[] = [];
ngOnInit(): void {
this.open = true;
this.action = this.actionLabels.CREATE;
+ this.submitAction = `${this.action} ${this.resource}`;
this.resolveRoute();
this.getRgwModuleStatus();
this.mgrModuleService.updateCompleted$.subscribe(() => this.getRgwModuleStatus());
if (this.editing) {
this.action = this.actionLabels.EDIT;
+ this.submitAction = this.actionLabels.SAVE_CHANGES;
+ this.disableForEditing(this.serviceType);
this.cephServiceService
.list(new HttpParams({ fromObject: { limit: -1, offset: 0 } }), this.serviceName)
.observable.subscribe((response: CephServiceSpec[]) => {
<cd-form-button-panel
(submitActionEvent)="submit()"
[form]="form"
- [submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
+ [submitText]="submitAction"
wrappingClass="text-right form-button"
>
</cd-form-button-panel>
expect(component).toBeTruthy();
});
+ describe('submit label', () => {
+ it('should set submit label to Create Pool in create mode', () => {
+ expect(component.submitAction).toBe('Create Pool');
+ });
+
+ it('should set submit label to Save changes in edit mode', () => {
+ fixture.destroy();
+ Object.defineProperty(router, 'url', {
+ get: () => '/pool/edit/somePoolName',
+ configurable: true
+ });
+ setUpPoolComponent();
+
+ expect(component.submitAction).toBe('Save changes');
+ });
+ });
+
describe('throws error for not allowed users', () => {
const expectError = (redirected: boolean) => {
navigationSpy.calls.reset();
currentConfigurationValues: { [configKey: string]: any } = {};
action: string;
resource: string;
+ submitAction: string;
icons = Icons;
pgAutoscaleModes: string[];
crushUsage: string[] = undefined; // Will only be set if a rule is used by some pool
this.editing = this.router.url.startsWith(`/pool/${URLVerbs.EDIT}`);
this.action = this.editing ? this.actionLabels.EDIT : this.actionLabels.CREATE;
this.resource = $localize`pool`;
+ this.submitAction = this.editing
+ ? this.actionLabels.SAVE_CHANGES
+ : `${this.action} ${_.upperFirst(this.resource)}`;
this.authenticate();
this.createForm();
}
<cd-form-button-panel
(submitActionEvent)="submit()"
[form]="roleForm"
- [submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
+ [submitText]="submitAction"
wrappingClass="text-right"
>
</cd-form-button-panel>
expect(component.mode).toBeUndefined();
});
+ it('should set submit action to Create Role', () => {
+ expect(component.submitAction).toBe('Create Role');
+ });
+
it('should submit', () => {
const role: RoleFormModel = {
name: 'role1',
expect(component.mode).toBe('editing');
});
+ it('should set submit action to Save changes', () => {
+ expect(component.submitAction).toBe('Save changes');
+ });
+
it('should submit', () => {
formHelper.setValue('scopes_permissions', {
osd: ['read', 'update'],
action: string;
resource: string;
+ submitAction: string;
constructor(
private route: ActivatedRoute,
if (this.router.url.startsWith('/user-management/roles/edit')) {
this.mode = this.roleFormMode.editing;
this.action = this.actionLabels.EDIT;
+ this.submitAction = this.actionLabels.SAVE_CHANGES;
} else {
this.action = this.actionLabels.CREATE;
+ this.submitAction = `${this.action} ${_.upperFirst(this.resource)}`;
}
if (this.mode === this.roleFormMode.editing) {
this.initEdit();
<cd-form-button-panel
(submitActionEvent)="submit()"
[form]="userForm"
- [submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
+ [submitText]="submitAction"
wrappingClass="text-right"
>
</cd-form-button-panel>
component.ngOnInit();
});
+ it('should set submit label to Create User', () => {
+ expect(component.submitAction).toBe('Create User');
+ });
+
it('should not disable fields', () => {
[
'username',
expect(form.getValue('roles')).toContain('administrator');
});
+ it('should set submit label to Save changes', () => {
+ expect(component.submitAction).toBe('Save changes');
+ });
+
it('should alert if user is removing needed role permission', () => {
let modalBodyTpl = null;
spyOn(modalService, 'show').and.callFake((_content, initialState) => {
messages = new SelectMessages({ empty: $localize`There are no roles.` });
action: string;
resource: string;
+ submitAction: string;
passwordPolicyHelpText = '';
passwordStrengthLevelClass: string;
passwordValuation: string;
if (this.router.url.startsWith('/user-management/users/edit')) {
this.mode = this.userFormMode.editing;
this.action = this.actionLabels.EDIT;
+ this.submitAction = this.actionLabels.SAVE_CHANGES;
this.passwordexp = false;
} else {
this.action = this.actionLabels.CREATE;
+ this.submitAction = `${this.action} ${_.upperFirst(this.resource)}`;
this.passwordexp = true;
}
this.userForm.get('password').updateValueAndValidity();
NFS_EXPORT: string;
VIEW: string;
EDIT_GATEWAYS_GROUP: string;
+ SAVE_CHANGES: string;
constructor() {
/* Create a new item */
this.CREATE = $localize`Create`;
this.NFS_EXPORT = $localize`Create NFS Share`;
this.VIEW = $localize`View`;
this.EDIT_GATEWAYS_GROUP = $localize`Edit gateways group`;
+ this.SAVE_CHANGES = $localize`Save changes`;
}
}
this.cdsModalService.show(FormModalComponent, {
titleText: $localize`Edit Host: ${host.hostname}`,
fields: [labelsField],
- submitButtonText: $localize`Edit Host`,
+ submitButtonText: $localize`Save changes`,
onSubmit: (values: { labels: string[] }) => {
this.submitHostLabelUpdate(host.hostname, values.labels, onSuccess);
}