mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Remove tag name validation * remove i18n key * add FTR test on searching for tag with special chars in name
This commit is contained in:
parent
38fe9614aa
commit
5daae0b0c0
11 changed files with 79 additions and 23 deletions
|
@ -37,8 +37,7 @@ Create a tag to assign to your saved objects.
|
|||
image::images/tags/create-tag.png[Tag creation popin]
|
||||
. Enter a name and select a color for the new tag.
|
||||
+
|
||||
The name can include alphanumeric characters (English letters and digits), `:`, `-`, `_` and the space character,
|
||||
and cannot be longer than 50 characters.
|
||||
The name cannot be longer than 50 characters.
|
||||
. Click *Create tag*.
|
||||
|
||||
[float]
|
||||
|
|
|
@ -20,10 +20,8 @@ describe('Tag attributes validation', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('returns an error message if the name contains invalid characters', () => {
|
||||
expect(validateTagName('t^ag+name&')).toMatchInlineSnapshot(
|
||||
`"Tag name can only include a-z, 0-9, _, -,:."`
|
||||
);
|
||||
it('does not return an error message if the name contains special characters', () => {
|
||||
expect(validateTagName('t^ag+name&')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ export const tagNameMaxLength = 50;
|
|||
export const tagDescriptionMaxLength = 100;
|
||||
|
||||
const hexColorRegexp = /^#[0-9A-F]{6}$/i;
|
||||
const nameValidCharsRegexp = /^[0-9A-Z:\-_\s]+$/i;
|
||||
|
||||
export interface TagValidation {
|
||||
valid: boolean;
|
||||
|
@ -49,11 +48,6 @@ export const validateTagName = (name: string): string | undefined => {
|
|||
},
|
||||
});
|
||||
}
|
||||
if (!nameValidCharsRegexp.test(name)) {
|
||||
return i18n.translate('xpack.savedObjectsTagging.validation.name.errorInvalidCharacters', {
|
||||
defaultMessage: 'Tag name can only include a-z, 0-9, _, -,:.',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const validateTagDescription = (description: string): string | undefined => {
|
||||
|
|
|
@ -16647,7 +16647,6 @@
|
|||
"xpack.savedObjectsTagging.uiApi.table.columnTagsName": "タグ",
|
||||
"xpack.savedObjectsTagging.validation.color.errorInvalid": "タグ色は有効な 16 進数値色でなければなりません",
|
||||
"xpack.savedObjectsTagging.validation.description.errorTooLong": "タグ説明は {length} 文字以下で入力してください",
|
||||
"xpack.savedObjectsTagging.validation.name.errorInvalidCharacters": "タグ名には、a-z、0-9、-、: のみを使用できます。",
|
||||
"xpack.savedObjectsTagging.validation.name.errorTooLong": "タグ名は {length} 文字以下で入力してください",
|
||||
"xpack.savedObjectsTagging.validation.name.errorTooShort": "タグ名は {length} 文字以上で入力してください",
|
||||
"xpack.searchProfiler.advanceTimeDescription": "イテレーターを次のドキュメントに進めるためにかかった時間。",
|
||||
|
|
|
@ -16689,7 +16689,6 @@
|
|||
"xpack.savedObjectsTagging.uiApi.table.columnTagsName": "标签",
|
||||
"xpack.savedObjectsTagging.validation.color.errorInvalid": "标签颜色必须为有效的十六进制颜色",
|
||||
"xpack.savedObjectsTagging.validation.description.errorTooLong": "标签描述不能超过 {length} 个字符。",
|
||||
"xpack.savedObjectsTagging.validation.name.errorInvalidCharacters": "标签名称只能包含 a-z、0-9、_、-、:。",
|
||||
"xpack.savedObjectsTagging.validation.name.errorTooLong": "标签名称不能超过 {length} 个字符",
|
||||
"xpack.savedObjectsTagging.validation.name.errorTooShort": "标签名称必须至少有 {length} 个字符",
|
||||
"xpack.searchProfiler.advanceTimeDescription": "将迭代器推进至下一文档所用时间。",
|
||||
|
|
|
@ -88,6 +88,24 @@
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "tag:tag-special-chars",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"tag": {
|
||||
"name": "my%tag",
|
||||
"description": "Special chars",
|
||||
"color": "#AA0077"
|
||||
},
|
||||
"type": "tag",
|
||||
"updated_at": "2017-09-21T18:49:16.270Z"
|
||||
},
|
||||
"type": "doc"
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
|
@ -356,3 +374,41 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "dashboard:ref-to-tag-special-chars",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"dashboard": {
|
||||
"title": "dashboard 4 (tag-special-chars)",
|
||||
"description": "",
|
||||
"hits": 0,
|
||||
"kibanaSavedObjectMeta": {
|
||||
"searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"animal\",\"value\":\"dog\",\"params\":{\"query\":\"dog\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"animal\":{\"query\":\"dog\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"highlightAll\":true,\"version\":true}"
|
||||
},
|
||||
"optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}",
|
||||
"panelsJSON": "[]",
|
||||
"timeFrom": "Mon Apr 09 2018 17:56:08 GMT-0400",
|
||||
"timeRestore": true,
|
||||
"timeTo": "Wed Apr 11 2018 17:56:08 GMT-0400",
|
||||
"version": 1
|
||||
},
|
||||
"migrationVersion": {
|
||||
"dashboard": "7.3.0"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"id": "tag-special-chars",
|
||||
"name": "tag-special-ref",
|
||||
"type": "tag"
|
||||
}
|
||||
],
|
||||
"type": "dashboard",
|
||||
"updated_at": "2018-04-11T21:57:52.253Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import expect from '@kbn/expect';
|
|||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
||||
describe('GlobalSearchBar', function () {
|
||||
describe('TOTO GlobalSearchBar', function () {
|
||||
const { common, navigationalSearch } = getPageObjects(['common', 'navigationalSearch']);
|
||||
const esArchiver = getService('esArchiver');
|
||||
const browser = getService('browser');
|
||||
|
@ -61,6 +61,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
'dashboard 1 (tag-2)',
|
||||
'dashboard 2 (tag-3)',
|
||||
'dashboard 3 (tag-1 and tag-3)',
|
||||
'dashboard 4 (tag-special-chars)',
|
||||
]);
|
||||
});
|
||||
it('shows a suggestion when searching for a term matching a tag name', async () => {
|
||||
|
@ -94,6 +95,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
'dashboard 1 (tag-2)',
|
||||
'dashboard 2 (tag-3)',
|
||||
'dashboard 3 (tag-1 and tag-3)',
|
||||
'dashboard 4 (tag-special-chars)',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -111,6 +113,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
'dashboard 1 (tag-2)',
|
||||
'dashboard 2 (tag-3)',
|
||||
'dashboard 3 (tag-1 and tag-3)',
|
||||
'dashboard 4 (tag-special-chars)',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -181,6 +184,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
expect(results.map((result) => result.label)).to.eql(['My awesome vis (tag-4)']);
|
||||
});
|
||||
|
||||
it('allows to filter by tags containing special characters', async () => {
|
||||
await navigationalSearch.searchFor('tag:"my%tag"');
|
||||
|
||||
const results = await navigationalSearch.getDisplayedResults();
|
||||
|
||||
expect(results.map((result) => result.label)).to.eql(['dashboard 4 (tag-special-chars)']);
|
||||
});
|
||||
|
||||
it('returns no results when searching for an unknown tag', async () => {
|
||||
await navigationalSearch.searchFor('tag:unknown');
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
await supertest
|
||||
.post(`/api/saved_objects_tagging/tags/create`)
|
||||
.send({
|
||||
name: 'Inv%li& t@g n*me',
|
||||
name: 'a',
|
||||
description: 'some desc',
|
||||
color: 'this is not a valid color',
|
||||
})
|
||||
|
@ -74,7 +74,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
valid: false,
|
||||
warnings: [],
|
||||
errors: {
|
||||
name: 'Tag name can only include a-z, 0-9, _, -,:.',
|
||||
name: 'Tag name must be at least 2 characters',
|
||||
color: 'Tag color must be a valid hex color',
|
||||
},
|
||||
},
|
||||
|
|
|
@ -78,7 +78,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
await supertest
|
||||
.post(`/api/saved_objects_tagging/tags/tag-1`)
|
||||
.send({
|
||||
name: 'Inv%li& t@g n*me',
|
||||
name: 'a',
|
||||
description: 'some desc',
|
||||
color: 'this is not a valid color',
|
||||
})
|
||||
|
@ -92,7 +92,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
valid: false,
|
||||
warnings: [],
|
||||
errors: {
|
||||
name: 'Tag name can only include a-z, 0-9, _, -,:.',
|
||||
name: 'Tag name must be at least 2 characters',
|
||||
color: 'Tag color must be a valid hex color',
|
||||
},
|
||||
},
|
||||
|
|
|
@ -54,7 +54,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await tagModal.openCreate();
|
||||
await tagModal.fillForm(
|
||||
{
|
||||
name: 'invalid&$%name',
|
||||
name: 'a',
|
||||
description: 'The name will fails validation',
|
||||
color: '#FF00CC',
|
||||
},
|
||||
|
@ -73,7 +73,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await tagModal.openCreate();
|
||||
await tagModal.fillForm(
|
||||
{
|
||||
name: 'invalid&$%name',
|
||||
name: 'a',
|
||||
description: 'The name will fails validation',
|
||||
color: '#FF00CC',
|
||||
},
|
||||
|
|
|
@ -71,7 +71,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await tagModal.openEdit('tag-2');
|
||||
await tagModal.fillForm(
|
||||
{
|
||||
name: 'invalid&$%name',
|
||||
name: 'a',
|
||||
},
|
||||
{ submit: true }
|
||||
);
|
||||
|
@ -88,7 +88,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await tagModal.openEdit('tag-2');
|
||||
await tagModal.fillForm(
|
||||
{
|
||||
name: 'invalid&$%name',
|
||||
name: 'a',
|
||||
description: 'edited description',
|
||||
color: '#FF00CC',
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue