-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of new by-value editor
Fixing broken behavior and applying relevant changes Adding changes to dashboard Removing unnecessary empty line Removing unnecessary deepClone Fixing some stuff in dashboard container Extracting logic into common components Fixing eslint Fix breadcrumbs Fixing error in search interceptor Reintroduce mistakenly removed empty lines Renaming function
- Loading branch information
Maja Grubic
committed
Jul 17, 2020
1 parent
9296369
commit b4972da
Showing
25 changed files
with
550 additions
and
151 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
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
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
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
102 changes: 102 additions & 0 deletions
102
src/plugins/visualize/public/application/components/visualize_byvalue_editor.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,102 @@ | ||
/* | ||
* 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 './visualize_editor.scss'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { EventEmitter } from 'events'; | ||
|
||
import { VisualizeInput } from 'src/plugins/visualizations/public'; | ||
import { useKibana } from '../../../../kibana_react/public'; | ||
import { | ||
useChromeVisibility, | ||
useVisByValue, | ||
useVisualizeAppState, | ||
useEditorUpdates, | ||
useLinkedSearchUpdates, | ||
} from '../utils'; | ||
import { VisualizeServices } from '../types'; | ||
import { VisualizeEditorCommon } from './visualize_editor_common'; | ||
|
||
export const VisualizeByValueEditor = () => { | ||
const [originatingApp, setOriginatingApp] = useState<string>(); | ||
const { services } = useKibana<VisualizeServices>(); | ||
const [eventEmitter] = useState(new EventEmitter()); | ||
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(true); | ||
const [embeddableId, setEmbeddableId] = useState<string>(); | ||
const [valueInput, setValueInput] = useState<VisualizeInput>(); | ||
|
||
useEffect(() => { | ||
const { originatingApp: value, embeddableId: embeddableIdValue, valueInput: valueInputValue } = | ||
services.embeddable | ||
.getStateTransfer(services.scopedHistory) | ||
.getIncomingEditorState({ keysToRemoveAfterFetch: ['id', 'embeddableId', 'valueInput'] }) || | ||
{}; | ||
setOriginatingApp(value); | ||
setValueInput(valueInputValue); | ||
setEmbeddableId(embeddableIdValue); | ||
}, [services]); | ||
|
||
const isChromeVisible = useChromeVisibility(services.chrome); | ||
|
||
const { savedVisInstance, visEditorRef, visEditorController } = useVisByValue( | ||
services, | ||
eventEmitter, | ||
isChromeVisible, | ||
valueInput | ||
); | ||
const { appState, hasUnappliedChanges } = useVisualizeAppState( | ||
services, | ||
eventEmitter, | ||
true, | ||
savedVisInstance | ||
); | ||
const { isEmbeddableRendered, currentAppState } = useEditorUpdates( | ||
services, | ||
eventEmitter, | ||
setHasUnsavedChanges, | ||
appState, | ||
savedVisInstance, | ||
visEditorController, | ||
true | ||
); | ||
useLinkedSearchUpdates(services, eventEmitter, appState, savedVisInstance); | ||
|
||
useEffect(() => { | ||
// clean up all registered listeners if any is left | ||
return () => { | ||
eventEmitter.removeAllListeners(); | ||
}; | ||
}, [eventEmitter]); | ||
|
||
return ( | ||
<VisualizeEditorCommon | ||
savedVisInstance={savedVisInstance} | ||
appState={appState} | ||
currentAppState={currentAppState} | ||
isChromeVisible={isChromeVisible} | ||
hasUnsavedChanges={hasUnsavedChanges} | ||
hasUnappliedChanges={hasUnappliedChanges} | ||
isEmbeddableRendered={isEmbeddableRendered} | ||
originatingApp={originatingApp} | ||
setHasUnsavedChanges={setHasUnsavedChanges} | ||
visEditorRef={visEditorRef} | ||
embeddableId={embeddableId} | ||
/> | ||
); | ||
}; |
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.