Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import {
SavedObjectsFindOptionsReference,
SavedObjectReference,
} from 'kibana/public';
import { SavedObject } from '../types';
import { StringUtils } from './helpers/string_utils';
import { SavedObject } from '../../../saved_objects/public';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: import type (even if the target is an interface)

import { upperFirst } from './string_utils';

/**
* @deprecated
* @removeBy 8.0
*/
export interface SavedObjectLoaderFindOptions {
size?: number;
fields?: string[];
Expand All @@ -23,6 +27,8 @@ export interface SavedObjectLoaderFindOptions {

/**
* @deprecated
* @removeBy 8.0
*
* The SavedObjectLoader class provides some convenience functions
* to load and save one kind of saved objects (specified in the constructor).
*
Expand All @@ -46,7 +52,7 @@ export class SavedObjectLoader {

this.loaderProperties = {
name: `${this.lowercaseType}s`,
noun: StringUtils.upperFirst(this.type),
noun: upperFirst(this.type),
nouns: `${this.lowercaseType}s`,
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/dashboard/public/services/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export type {
SavedObject,
SavedObjectsStart,
SavedObjectSaveOpts,
SavedObjectLoaderFindOptions,
} from '../../../saved_objects/public';
export {
showSaveModal,
SavedObjectLoader,
SavedObjectSaveModal,
getSavedObjectFinder,
} from '../../../saved_objects/public';
export { SavedObjectLoader } from './saved_object_loader';
export type { SavedObjectLoaderFindOptions } from './saved_object_loader';
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* Side Public License, v 1.
*/

import { StringUtils } from './string_utils';
import { upperFirst } from './string_utils';

describe('StringUtils class', () => {
describe('static upperFirst', () => {
describe('StringUtils', () => {
describe('upperFirst', () => {
test('should converts the first character of string to upper case', () => {
expect(StringUtils.upperFirst()).toBe('');
expect(StringUtils.upperFirst('')).toBe('');
expect(upperFirst()).toBe('');
expect(upperFirst('')).toBe('');

expect(StringUtils.upperFirst('Fred')).toBe('Fred');
expect(StringUtils.upperFirst('fred')).toBe('Fred');
expect(StringUtils.upperFirst('FRED')).toBe('FRED');
expect(upperFirst('Fred')).toBe('Fred');
expect(upperFirst('fred')).toBe('Fred');
expect(upperFirst('FRED')).toBe('FRED');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
* Side Public License, v 1.
*/

export class StringUtils {
/**
* Returns a version of the string with the first letter capitalized.
* @param str {string}
* @returns {string}
*/
public static upperFirst(str: string = ''): string {
return str ? str.charAt(0).toUpperCase() + str.slice(1) : '';
}
/**
* Returns a version of the string with the first letter capitalized.
* @param str {string}
* @returns {string}
*/
export function upperFirst(str: string = ''): string {
return str ? str.charAt(0).toUpperCase() + str.slice(1) : '';
}
8 changes: 1 addition & 7 deletions src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ export { SavedObjectSaveModal, SavedObjectSaveModalOrigin, showSaveModal } from
export type { SavedObjectFinderUiProps, SavedObjectMetaData } from './finder';
export { getSavedObjectFinder, SavedObjectFinderUi } from './finder';
export type {
SavedObjectLoaderFindOptions,
SavedObjectDecorator,
SavedObjectDecoratorFactory,
SavedObjectDecoratorConfig,
} from './saved_object';
export {
SavedObjectLoader,
checkForDuplicateTitle,
saveWithConfirmation,
isErrorNonFatal,
} from './saved_object';
export { checkForDuplicateTitle, saveWithConfirmation, isErrorNonFatal } from './saved_object';
export type { SavedObjectSaveOpts, SavedObject, SavedObjectConfig } from './types';
export { PER_PAGE_SETTING, LISTING_LIMIT_SETTING } from '../common';
export type { SavedObjectsStart, SavedObjectSetup } from './plugin';
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/saved_objects/public/saved_object/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/

export { createSavedObjectClass } from './saved_object';
export type { SavedObjectLoaderFindOptions } from './saved_object_loader';
export { SavedObjectLoader } from './saved_object_loader';
export { checkForDuplicateTitle } from './helpers/check_for_duplicate_title';
export { saveWithConfirmation } from './helpers/save_with_confirmation';
export { isErrorNonFatal } from './helpers/save_saved_object';
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/saved_objects/public/saved_object/saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export function createSavedObjectClass(
* provides additional functionality besides loading/saving/deleting/etc.
*
* It is overloaded and configured to provide type-aware functionality.
* To just retrieve the attributes of saved objects, it is recommended to use SavedObjectLoader
* which returns instances of SimpleSavedObject which don't introduce additional type-specific complexity.
* @param {*} config
*/
class SavedObjectClass {
Expand Down