[Input Controls] Hide ability to create legacy input controls (#156455)

Closes https://github.com/elastic/kibana/issues/150639

>**Note**
> The attached issue mentions possibly preventing legacy input control
panels from being **cloned** - while I understand the reasoning for this
(if we allow cloning, aren't we essentially still giving users a
roundabout way to create new legacy input controls?), I think that the
primary goal of this should be to make legacy input controls **more
difficult to access**, not necessarily to prevent users from creating
legacy input controls entirely.
>
> After all, if we went to prevent **any** new legacy input controls
from being created, wouldn't we also have to prevent users from cloning
existing **dashboards** that have at least one legacy input control? I
think that simply hiding them from the creation menus is a good enough
beginning step until we can finally remove them for good.

## Summary

This PR takes another step forward in the deprecation process of the
legacy input controls by hiding them from the visualization wizard + the
visualization creation menu by marking the `input_control_vis` type as
`hidden`.

**Visualize Wizard**
| Before | After |
|--------|-------|
|
![image](https://user-images.githubusercontent.com/8698078/236558589-f1947a01-b306-46ea-9c30-5aa4662340de.png)
|
![image](https://user-images.githubusercontent.com/8698078/236558642-a6f6bd0a-529b-4760-9f19-4967fde9548f.png)
|

> **Note**
> As a follow up, the [visualize team will be removing the
`visualize:enableLabs`
setting](https://github.com/elastic/kibana/issues/152833), since it is
used exclusively to hide the controls from this wizard; however, because
this PR hides them from this wizard via the `hidden` property, this
setting is now obsolete.

**Creation Menu in Dashboard**
| Before | After |
|--------|-------|
|
![image](https://user-images.githubusercontent.com/8698078/236559127-17765459-286f-4b50-b69a-7087c4055840.png)
|
![image](https://user-images.githubusercontent.com/8698078/236559199-192614c9-5c5c-484c-ab7f-822c8a54f67f.png)
|


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
Hannah Mudge 2023-05-10 08:55:23 -06:00 committed by GitHub
parent 80a6d76e76
commit ac84798672
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 55 deletions

View file

@ -29,6 +29,7 @@ export function createInputControlVisTypeDefinition(
defaultMessage: 'Input controls are deprecated and will be removed in a future version.',
}),
stage: 'experimental',
hidden: true,
isDeprecated: true,
visConfig: {
defaults: {

View file

@ -44,6 +44,7 @@ export interface VisTypeAlias {
note?: string;
getSupportedTriggers?: () => string[];
stage: VisualizationStage;
hidden?: boolean;
isDeprecated?: boolean;
appExtensions?: {

View file

@ -215,8 +215,9 @@ const ToolsGroup = ({ visType, onVisTypeSelected, showExperimental }: VisCardPro
const onClick = useCallback(() => {
onVisTypeSelected(visType);
}, [onVisTypeSelected, visType]);
// hide the experimental visualization if lab mode is not enabled
if (!showExperimental && visType.stage === 'experimental') {
// hide both the hidden visualizations and, if lab mode is not enabled, the experimental visualizations
// TODO: Remove the showExperimental logic as part of https://github.com/elastic/kibana/issues/152833
if (visType.hidden || (!showExperimental && visType.stage === 'experimental')) {
return null;
}
return (

View file

@ -19,20 +19,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const comboBox = getService('comboBox');
const FIELD_NAME = 'machine.os.raw';
const from = 'Jan 1, 2017 @ 00:00:00.000';
const to = 'Jan 1, 2017 @ 00:00:00.000';
describe('input control options', () => {
before(async () => {
await PageObjects.visualize.initTests();
await PageObjects.common.setTime({ from, to });
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickInputControlVis();
await PageObjects.visEditor.clickVisEditorTab('controls');
await PageObjects.visEditor.addInputControl();
await comboBox.set('indexPatternSelect-0', 'logstash-');
await comboBox.set('fieldSelect-0', FIELD_NAME);
await PageObjects.visEditor.clickGo();
await PageObjects.common.navigateToApp('visualize');
await PageObjects.visualize.loadSavedVisualization('input control options', {
navigateToVisualize: false,
});
});
it('should not have inspector enabled', async function () {

View file

@ -11,58 +11,25 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const find = getService('find');
const security = getService('security');
const PageObjects = getPageObjects(['visualize']);
const { visualize, visEditor } = getPageObjects(['visualize', 'visEditor']);
const { visualize, visEditor, common } = getPageObjects(['visualize', 'visEditor', 'common']);
describe('input control range', () => {
before(async () => {
await PageObjects.visualize.initTests();
await security.testUser.setRoles(['kibana_admin', 'kibana_sample_admin']);
await esArchiver.load('test/functional/fixtures/es_archiver/kibana_sample_data_flights');
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/kibana_sample_data_flights_index_pattern'
);
await kibanaServer.uiSettings.replace({
defaultIndex: 'd3d7af60-4c81-11e8-b3d7-01146121b73d',
await visualize.initTests();
await common.navigateToApp('visualize');
await visualize.loadSavedVisualization('input control range', {
navigateToVisualize: false,
});
await visualize.navigateToNewVisualization();
await visualize.clickInputControlVis();
});
it('should add filter with scripted field', async () => {
await visEditor.addInputControl('range');
await visEditor.setFilterParams(0, 'kibana_sample_data_flights', 'hour_of_day');
await visEditor.clickGo();
await visEditor.setFilterRange(0, '7', '10');
it('should add filter', async () => {
await visEditor.setFilterRange(0, '400', '999');
await visEditor.inputControlSubmit();
const controlFilters = await find.allByCssSelector('[data-test-subj^="filter"]');
expect(controlFilters).to.have.length(1);
expect(await controlFilters[0].getVisibleText()).to.equal('hour_of_day: 7 to 10');
});
it('should add filter with price field', async () => {
await visEditor.addInputControl('range');
await visEditor.setFilterParams(1, 'kibana_sample_data_flights', 'AvgTicketPrice');
await visEditor.clickGo();
await visEditor.setFilterRange(1, '400', '999');
await visEditor.inputControlSubmit();
const controlFilters = await find.allByCssSelector('[data-test-subj^="filter"]');
expect(controlFilters).to.have.length(2);
expect(await controlFilters[1].getVisibleText()).to.equal('AvgTicketPrice: $400 to $999');
});
after(async () => {
await kibanaServer.importExport.unload(
'test/functional/fixtures/kbn_archiver/kibana_sample_data_flights_index_pattern'
);
await esArchiver.unload('test/functional/fixtures/es_archiver/kibana_sample_data_flights');
await kibanaServer.uiSettings.unset('defaultIndex');
await security.testUser.restoreDefaults();
expect(await controlFilters[0].getVisibleText()).to.equal('memory: 400 to 999');
});
});
}

View file

@ -111,6 +111,63 @@
"version": "WzE4LDFd"
}
{
"attributes":{
"description":"",
"kibanaSavedObjectMeta":{
"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
},
"title":"input control options",
"uiStateJSON":"{}",
"version":1,
"visState":"{\"title\":\"input control options\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1683308974253\",\"fieldName\":\"machine.os.raw\",\"parent\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}"
},
"coreMigrationVersion": "7.14.0",
"id":"5493d640-eb71-11ed-95fe-1d6198198e62",
"migrationVersion": {
"visualization": "7.14.0"
},
"references": [
{
"id": "logstash-*",
"name": "control_0_index_pattern",
"type": "index-pattern"
}
],
"type":"visualization",
"updated_at": "2019-06-05T18:04:48.310Z",
"version":"WzYwLDFd"
}
{
"attributes":{
"description":"",
"kibanaSavedObjectMeta":{
"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
},
"title":"input control range",
"uiStateJSON":"{}",
"version":1,
"visState":"{\"title\":\"input control range\",\"type\":\"input_control_vis\",\"aggs\":[],\"params\":{\"controls\":[{\"id\":\"1683312573005\",\"fieldName\":\"memory\",\"parent\":\"\",\"label\":\"\",\"type\":\"range\",\"options\":{\"decimalPlaces\":0,\"step\":1},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1683312619904\",\"indexPattern\":\"\",\"fieldName\":\"\",\"parent\":\"\",\"label\":\"\",\"type\":\"range\",\"options\":{\"decimalPlaces\":0,\"step\":1}}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false}}"
},
"coreMigrationVersion": "7.14.0",
"created_at":"2023-05-05T18:50:52.396Z",
"id":"c26cbac0-eb75-11ed-9d36-af11c87c7c69",
"managed":false,
"references":[
{
"id": "logstash-*",
"name": "control_0_index_pattern",
"type":"index-pattern"
}
],
"type":"visualization",
"typeMigrationVersion":"7.14.0",
"updated_at":"2023-05-05T18:50:52.396Z",
"version":"WzY1LDFd"
}
{
"attributes": {
"fields": "[{\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"esTypes\":[\"_type\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"message\",\"type\":\"string\",\"esTypes\":[\"text\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"message.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"message\"}}},{\"name\":\"user\",\"type\":\"string\",\"esTypes\":[\"text\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"user.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"user\"}}}]",
@ -302,4 +359,4 @@
"references": [],
"type": "index-pattern",
"version": "WzE1LDFd"
}
}