-
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.
Browse files
Browse the repository at this point in the history
* 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 * Adding missing null check * Making typescript play nicely * Fixing failing tests * Applying PR comments * Fixing eslint errors * Fix save as behavior * Fixing HTMLElement type * Passing in setOriginatingApp parameter * Redirect back to dashboard if input is missing * Fixing i18n error * Unlink saved search * Fix duplicating embeddable by reference Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
2d958e5
commit 09a2db8
Showing
28 changed files
with
656 additions
and
196 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
105 changes: 105 additions & 0 deletions
105
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,105 @@ | ||
/* | ||
* 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); | ||
if (!valueInputValue) { | ||
history.back(); | ||
} | ||
}, [services]); | ||
|
||
const isChromeVisible = useChromeVisibility(services.chrome); | ||
|
||
const { byValueVisInstance, visEditorRef, visEditorController } = useVisByValue( | ||
services, | ||
eventEmitter, | ||
isChromeVisible, | ||
valueInput, | ||
originatingApp | ||
); | ||
const { appState, hasUnappliedChanges } = useVisualizeAppState( | ||
services, | ||
eventEmitter, | ||
byValueVisInstance | ||
); | ||
const { isEmbeddableRendered, currentAppState } = useEditorUpdates( | ||
services, | ||
eventEmitter, | ||
setHasUnsavedChanges, | ||
appState, | ||
byValueVisInstance, | ||
visEditorController | ||
); | ||
useLinkedSearchUpdates(services, eventEmitter, appState, byValueVisInstance); | ||
|
||
useEffect(() => { | ||
// clean up all registered listeners if any is left | ||
return () => { | ||
eventEmitter.removeAllListeners(); | ||
}; | ||
}, [eventEmitter]); | ||
|
||
return ( | ||
<VisualizeEditorCommon | ||
visInstance={byValueVisInstance} | ||
appState={appState} | ||
currentAppState={currentAppState} | ||
isChromeVisible={isChromeVisible} | ||
hasUnsavedChanges={hasUnsavedChanges} | ||
hasUnappliedChanges={hasUnappliedChanges} | ||
isEmbeddableRendered={isEmbeddableRendered} | ||
originatingApp={originatingApp} | ||
setOriginatingApp={setOriginatingApp} | ||
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.