Skip to content

Commit

Permalink
Added i18n and changed hidden to be true so we cannot copy the object…
Browse files Browse the repository at this point in the history
…s from space to space
  • Loading branch information
FrankHassanabad committed Aug 31, 2021
1 parent b0ab0e5 commit a877b9d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 7 additions & 8 deletions x-pack/plugins/lists/server/saved_objects/exception_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ExceptionListSoSchema } from '../schemas/saved_objects/exceptions_list_

import { migrations } from './migrations';
import { onExport } from './on_export';
import * as i18n from './translations';

/**
* This is a super set of exception list and exception list items. The switch
Expand Down Expand Up @@ -187,17 +188,16 @@ const combinedMappings: SavedObjectsType['mappings'] = {
export const getExceptionListType = (
startServices: Promise<[CoreStart, object, unknown]>
): SavedObjectsType => ({
hidden: false,
hidden: true,
management: {
getTitle(savedObject: SavedObject<ExceptionListSoSchema>): string {
// TODO: i18n all of this
const type = savedObject.attributes.list_type;
switch (type) {
case 'list': {
return `Exception List: [${savedObject.attributes.name}]`;
return `${i18n.EXCEPTION_LIST_NAME}: [${savedObject.attributes.name}]`;
}
case 'item': {
return `Exception List Item: [${savedObject.attributes.name}]`;
return `${i18n.EXCEPTION_LIST_ITEM_NAME}: [${savedObject.attributes.name}]`;
}
default: {
throw new Error(`Unhandled type for type: ${type}`);
Expand All @@ -221,17 +221,16 @@ export const getExceptionListType = (
export const exceptionListAgnosticType = (
startServices: Promise<[CoreStart, object, unknown]>
): SavedObjectsType => ({
hidden: false,
hidden: true,
management: {
getTitle(savedObject: SavedObject<ExceptionListSoSchema>): string {
// TODO: i18n all of this
const type = savedObject.attributes.list_type;
switch (type) {
case 'list': {
return `Agnostic Exception List: [${savedObject.attributes.name}]`;
return `${i18n.AGNOSTIC_EXCEPTION_LIST_NAME}: [${savedObject.attributes.name}]`;
}
case 'item': {
return `Agnostic Exception List Item (Agnostic): [${savedObject.attributes.name}]`;
return `${i18n.AGNOSTIC_EXCEPTION_LIST_ITEM_NAME}: [${savedObject.attributes.name}]`;
}
default: {
throw new Error(`Unhandled type for type: ${type}`);
Expand Down
29 changes: 29 additions & 0 deletions x-pack/plugins/lists/server/saved_objects/translations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';

export const EXCEPTION_LIST_NAME = i18n.translate('xpack.lists.exceptions.listNameLabel', {
defaultMessage: 'Exception List',
});

export const EXCEPTION_LIST_ITEM_NAME = i18n.translate('xpack.lists.exceptions.listItemNameLabel', {
defaultMessage: 'Exception List Item',
});

export const AGNOSTIC_EXCEPTION_LIST_NAME = i18n.translate(
'xpack.lists.exceptions.agnosticListNameLabel',
{
defaultMessage: 'Agnostic Exception List',
}
);

export const AGNOSTIC_EXCEPTION_LIST_ITEM_NAME = i18n.translate(
'xpack.lists.exceptions.agnosticListItemNameLabel',
{
defaultMessage: 'Agnostic Exception List Item',
}
);

0 comments on commit a877b9d

Please sign in to comment.