forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Console] Text Objects (elastic#52402) (elastic#55668)
* WiP * Initial commit for localStorage -> SavedObjects, untested [skip ci] * Restore text_object model and mappings * Fix use of mappings * WIP on anonymous saved objects and user ids * refactor: remove saved objects entirely and rescope changes to only introducing text objects * Update use of .findAll after changes * Where did that come from? * Slight refactor to generic names Removed unused files (mappings.json, README.md) Documented object storage client interface Failure to restore previous state does not block editor Updated copy * Rename exported variable * Document TextObject interface * Rename EuiLoadingContent10 -> EditorContentSpinner * Update src/legacy/core_plugins/console/public/np_ready/application/components/something_went_wrong_callout.tsx Co-Authored-By: Rory Hunter <[email protected]> * Update src/legacy/core_plugins/console/public/np_ready/application/components/something_went_wrong_callout.tsx Co-Authored-By: Rory Hunter <[email protected]> * Update src/legacy/core_plugins/console/public/np_ready/application/components/top_nav_menu.tsx Co-Authored-By: Rory Hunter <[email protected]> * Update src/legacy/core_plugins/console/public/np_ready/application/components/top_nav_menu.tsx Co-Authored-By: Rory Hunter <[email protected]> * Update src/legacy/core_plugins/console/public/np_ready/application/containers/editor/legacy/console_editor/editor.test.tsx Co-Authored-By: Rory Hunter <[email protected]> * Added FunctionComponent imports * Implement preventing editting console text if init failed * Simply console boot states for now * This reverts commit 07b7bfb. * Fix eslint issue Update copy Co-authored-by: Rory Hunter <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Rory Hunter <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
1d14b68
commit 00c346b
Showing
24 changed files
with
565 additions
and
25 deletions.
There are no files selected for viewing
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,48 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export const textObjectTypeName = 'text-object'; | ||
|
||
/** | ||
* Describes the shape of persisted objects that contain information about the current text in the | ||
* text editor. | ||
*/ | ||
export interface TextObject { | ||
/** | ||
* An ID that uniquely identifies this object. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* UNIX timestamp of when the object was created. | ||
*/ | ||
createdAt: number; | ||
|
||
/** | ||
* UNIX timestamp of when the object was last updated. | ||
*/ | ||
updatedAt: number; | ||
|
||
/** | ||
* Text value input by the user. | ||
* | ||
* Used to re-populate a text editor buffer. | ||
*/ | ||
text: string; | ||
} |
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,49 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { TextObject } from './text_object'; | ||
|
||
export interface IdObject { | ||
id: string; | ||
} | ||
|
||
export interface ObjectStorage<O extends IdObject> { | ||
/** | ||
* Creates a new object in the underlying persistance layer. | ||
* | ||
* @remarks Does not accept an ID, a new ID is generated and returned with the newly created object. | ||
*/ | ||
create(obj: Omit<O, 'id'>): Promise<O>; | ||
|
||
/** | ||
* This method should update specific object in the persistance layer. | ||
*/ | ||
update(obj: O): Promise<void>; | ||
|
||
/** | ||
* A function that will return all of the objects in the persistance layer. | ||
* | ||
* @remarks Unless an error is thrown this function should always return an array (empty if there are not objects present). | ||
*/ | ||
findAll(): Promise<O[]>; | ||
} | ||
|
||
export interface ObjectStorageClient { | ||
text: ObjectStorage<TextObject>; | ||
} |
29 changes: 29 additions & 0 deletions
29
...cy/core_plugins/console/public/np_ready/application/components/editor_content_spinner.tsx
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,29 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
import { EuiLoadingContent, EuiPageContent } from '@elastic/eui'; | ||
|
||
export const EditorContentSpinner: FunctionComponent = () => { | ||
return ( | ||
<EuiPageContent className="conApp__editor__spinner"> | ||
<EuiLoadingContent lines={10} /> | ||
</EuiPageContent> | ||
); | ||
}; |
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
58 changes: 58 additions & 0 deletions
58
...e_plugins/console/public/np_ready/application/components/something_went_wrong_callout.tsx
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,58 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React, { FunctionComponent, useEffect } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiCallOut, EuiText, EuiButton, EuiSpacer } from '@elastic/eui'; | ||
|
||
interface Props { | ||
error: Error; | ||
onButtonClick: () => void; | ||
} | ||
|
||
export const SomethingWentWrongCallout: FunctionComponent<Props> = ({ error, onButtonClick }) => { | ||
useEffect(() => { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
}, [error]); | ||
|
||
return ( | ||
<EuiCallOut | ||
iconType="alert" | ||
color="danger" | ||
title={i18n.translate('console.loadingError.title', { | ||
defaultMessage: 'Cannot load Console', | ||
})} | ||
> | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="console.loadingError.message" | ||
defaultMessage="Try reloading to get the latest data." | ||
/> | ||
</p> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
<EuiButton color="danger" onClick={() => onButtonClick()}> | ||
<FormattedMessage id="console.loadingError.buttonLabel" defaultMessage="Reload Console" /> | ||
</EuiButton> | ||
</EuiCallOut> | ||
); | ||
}; |
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
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
Oops, something went wrong.