mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
- Closes https://github.com/elastic/kibana/issues/89726 ## Summary This PR extends Data View Field flyout with a new textarea to enter and save a custom field description. This description will be shown in a field popover for Discover sidebar, in Doc Viewer and also on Data View management page. Current limit for the custom description is 300. When creating/editing a field: <img width="600" alt="Screenshot 2024-03-07 at 18 59 24" src="433e66d1
-9366-4906-8aea-33b77ae81c16"> In the field popover(truncated): <img width="500" alt="Screenshot 2024-03-07 at 18 56 52" src="8753a11d
-6b27-40c1-adaa-de35addb50df"> In the field popover(expanded): <img width="500" alt="Screenshot 2024-03-07 at 18 57 00" src="b593169e
-305e-4d4b-853a-4937324e2470"> In Doc Viewer popover(always expanded): <img width="500" alt="Screenshot 2024-03-07 at 18 57 21" src="106562a2
-baad-4952-a9cc-fa779f96c1e1"> On Data View Management page(truncated): <img width="500" alt="Screenshot 2024-03-07 at 18 57 42" src="031ed482
-5c84-484f-ae9e-6b1e7622c17c"> <details> <summary>Initial implementation examples</summary>  <img width="600" alt="Screenshot 2023-10-11 at 11 52 22" src="8e40da6f
-fcfc-4e36-9314-d3fc34e6ecab"> <img width="600" alt="Screenshot 2023-10-11 at 11 46 44" src="d5ee22a7
-0314-4742-b75f-6534e1b4024d"> <img width="600" alt="Screenshot 2023-10-11 at 11 46 29" src="dcd809df
-7942-4165-8b83-4a83267cea00"> <img width="600" alt="Screenshot 2023-10-11 at 11 47 15" src="197add4d
-b185-4631-a2b9-eaf013aad8ba"> <img width="600" alt="Screenshot 2023-10-11 at 12 05 29" src="9b619e20
-c3d1-4c20-ac65-8b922ad1da72"> </details> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Matthew Kime <matt@mattki.me> Co-authored-by: amyjtechwriter <61687663+amyjtechwriter@users.noreply.github.com>
156 lines
5.6 KiB
TypeScript
156 lines
5.6 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import { FtrService } from '../ftr_provider_context';
|
|
|
|
export class FieldEditorService extends FtrService {
|
|
private readonly browser = this.ctx.getService('browser');
|
|
private readonly testSubjects = this.ctx.getService('testSubjects');
|
|
private readonly retry = this.ctx.getService('retry');
|
|
private readonly find = this.ctx.getService('find');
|
|
private readonly comboBox = this.ctx.getService('comboBox');
|
|
|
|
public async setName(name: string, clearFirst = false, typeCharByChar = false) {
|
|
await this.testSubjects.setValue('nameField > input', name, {
|
|
clearWithKeyboard: clearFirst,
|
|
typeCharByChar,
|
|
});
|
|
}
|
|
public async enableCustomLabel() {
|
|
await this.testSubjects.setEuiSwitch('customLabelRow > toggle', 'check');
|
|
}
|
|
public async setCustomLabel(name: string) {
|
|
await this.testSubjects.setValue('customLabelRow > input', name);
|
|
}
|
|
public async enableCustomDescription() {
|
|
await this.testSubjects.setEuiSwitch('customDescriptionRow > toggle', 'check');
|
|
}
|
|
public async setCustomDescription(description: string) {
|
|
await this.testSubjects.setValue('customDescriptionRow > input', description);
|
|
}
|
|
public async getFormError() {
|
|
const alert = await this.find.byCssSelector(
|
|
'[data-test-subj=indexPatternFieldEditorForm] > [role="alert"]'
|
|
);
|
|
return await alert.getVisibleText();
|
|
}
|
|
public async enableValue() {
|
|
await this.testSubjects.setEuiSwitch('valueRow > toggle', 'check');
|
|
}
|
|
public async disableValue() {
|
|
await this.testSubjects.setEuiSwitch('valueRow > toggle', 'uncheck');
|
|
}
|
|
public async clearScript() {
|
|
const editor = await (
|
|
await this.testSubjects.find('valueRow')
|
|
).findByClassName('react-monaco-editor-container');
|
|
const textarea = await editor.findByClassName('monaco-mouse-cursor-text');
|
|
await textarea.click();
|
|
const input = await this.find.activeElement();
|
|
await input.clearValueWithKeyboard();
|
|
}
|
|
public async typeScript(script: string) {
|
|
const editor = await (
|
|
await this.testSubjects.find('valueRow')
|
|
).findByClassName('react-monaco-editor-container');
|
|
const textarea = await editor.findByClassName('monaco-mouse-cursor-text');
|
|
|
|
await textarea.click();
|
|
|
|
// To avoid issue with the timing needed for Selenium to write the script and the monaco editor
|
|
// syntax validation kicking in, we loop through all the chars of the script and enter
|
|
// them one by one (instead of calling "await this.browser.pressKeys(script);").
|
|
for (const letter of script.split('')) {
|
|
await this.browser.pressKeys(letter);
|
|
}
|
|
}
|
|
public async save() {
|
|
await this.testSubjects.click('fieldSaveButton');
|
|
}
|
|
|
|
async setUrlFieldFormat(template: string) {
|
|
const urlTemplateField = await this.find.byCssSelector(
|
|
'input[data-test-subj="urlEditorUrlTemplate"]'
|
|
);
|
|
await urlTemplateField.type(template);
|
|
}
|
|
|
|
public async setStaticLookupFormat(oldValue: string, newValue: string) {
|
|
await this.testSubjects.click('staticLookupEditorAddEntry');
|
|
await this.testSubjects.setValue('~staticLookupEditorKey', oldValue);
|
|
await this.testSubjects.setValue('~staticLookupEditorValue', newValue);
|
|
}
|
|
|
|
public async setColorFormat(value: string, color: string, backgroundColor?: string) {
|
|
await this.testSubjects.click('colorEditorAddColor');
|
|
await this.testSubjects.setValue('~colorEditorKeyPattern', value);
|
|
await this.testSubjects.setValue('~colorEditorColorPicker', color);
|
|
if (backgroundColor) {
|
|
await this.testSubjects.setValue('~colorEditorBackgroundPicker', backgroundColor);
|
|
}
|
|
}
|
|
|
|
public async setStringFormat(transform: string) {
|
|
await this.testSubjects.selectValue('stringEditorTransform', transform);
|
|
}
|
|
|
|
public async setTruncateFormatLength(length: string) {
|
|
await this.testSubjects.setValue('truncateEditorLength', length);
|
|
}
|
|
|
|
public async setFieldType(type: string) {
|
|
await this.comboBox.set('typeField', type);
|
|
}
|
|
|
|
public async setFieldFormat(format: string) {
|
|
await this.find.clickByCssSelector(
|
|
'select[data-test-subj="editorSelectedFormatId"] > option[value="' + format + '"]'
|
|
);
|
|
}
|
|
|
|
public async setFormat(format: string) {
|
|
await this.testSubjects.setEuiSwitch('formatRow > toggle', 'check');
|
|
await this.setFieldFormat(format);
|
|
}
|
|
|
|
public async confirmSave() {
|
|
await this.retry.try(async () => {
|
|
await this.testSubjects.setValue('saveModalConfirmText', 'change');
|
|
await this.testSubjects.clickWhenNotDisabledWithoutRetry('confirmModalConfirmButton', {
|
|
timeout: 1000,
|
|
});
|
|
});
|
|
}
|
|
|
|
public async confirmDelete() {
|
|
await this.retry.try(async () => {
|
|
await this.testSubjects.setValue('deleteModalConfirmText', 'remove');
|
|
await this.testSubjects.clickWhenNotDisabledWithoutRetry('confirmModalConfirmButton', {
|
|
timeout: 1000,
|
|
});
|
|
});
|
|
}
|
|
|
|
public async confirmDiscardChanges() {
|
|
await this.retry.try(async () => {
|
|
await this.testSubjects.clickWhenNotDisabledWithoutRetry('confirmModalConfirmButton', {
|
|
timeout: 1000,
|
|
});
|
|
});
|
|
}
|
|
|
|
public async waitUntilClosed() {
|
|
await this.testSubjects.waitForDeleted('fieldEditor');
|
|
}
|
|
|
|
public async closeFlyoutAndDiscardChanges() {
|
|
await this.testSubjects.click('fieldEditor > closeFlyoutButton');
|
|
await this.confirmDiscardChanges();
|
|
await this.waitUntilClosed();
|
|
}
|
|
}
|