-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Graph] Deangularize saved object handling (workspace) (#52529)
- Loading branch information
Showing
6 changed files
with
168 additions
and
170 deletions.
There are no files selected for viewing
67 changes: 0 additions & 67 deletions
67
x-pack/legacy/plugins/graph/public/angular/services/saved_workspace.js
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
x-pack/legacy/plugins/graph/public/angular/services/saved_workspace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { SavedObject, SavedObjectKibanaServices } from 'ui/saved_objects/types'; | ||
import { createSavedObjectClass } from 'ui/saved_objects/saved_object'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { extractReferences, injectReferences } from './saved_workspace_references'; | ||
|
||
export interface SavedWorkspace extends SavedObject { | ||
wsState?: string; | ||
} | ||
|
||
export function createSavedWorkspaceClass(services: SavedObjectKibanaServices) { | ||
// SavedWorkspace constructor. Usually you'd interact with an instance of this. | ||
// ID is option, without it one will be generated on save. | ||
const SavedObjectClass = createSavedObjectClass(services); | ||
class SavedWorkspaceClass extends SavedObjectClass { | ||
public static type: string = 'graph-workspace'; | ||
// if type:workspace has no mapping, we push this mapping into ES | ||
public static mapping: Record<string, string> = { | ||
title: 'text', | ||
description: 'text', | ||
numLinks: 'integer', | ||
numVertices: 'integer', | ||
version: 'integer', | ||
wsState: 'json', | ||
}; | ||
// Order these fields to the top, the rest are alphabetical | ||
public static fieldOrder = ['title', 'description']; | ||
public static searchSource = false; | ||
|
||
public wsState?: string; | ||
|
||
constructor(id: string) { | ||
// Gives our SavedWorkspace the properties of a SavedObject | ||
super({ | ||
type: SavedWorkspaceClass.type, | ||
mapping: SavedWorkspaceClass.mapping, | ||
searchSource: SavedWorkspaceClass.searchSource, | ||
extractReferences, | ||
injectReferences, | ||
// if this is null/undefined then the SavedObject will be assigned the defaults | ||
id, | ||
// default values that will get assigned if the doc is new | ||
defaults: { | ||
title: i18n.translate('xpack.graph.savedWorkspace.workspaceNameTitle', { | ||
defaultMessage: 'New Graph Workspace', | ||
}), | ||
numLinks: 0, | ||
numVertices: 0, | ||
wsState: '{}', | ||
version: 1, | ||
}, | ||
}); | ||
} | ||
// Overwrite the default getDisplayName function which uses type and which is not very | ||
// user friendly for this object. | ||
getDisplayName = () => { | ||
return 'graph workspace'; | ||
}; | ||
} | ||
return SavedWorkspaceClass; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
x-pack/legacy/plugins/graph/public/angular/services/saved_workspaces.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.