-
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.
[Canvas][tech-debt] Update Redux components to reflect new structure
- Loading branch information
1 parent
d8d8306
commit 92ba235
Showing
55 changed files
with
1,465 additions
and
1,344 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
x-pack/plugins/canvas/public/components/embeddable_flyout/flyout.component.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,78 @@ | ||
/* | ||
* 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 React, { FC } from 'react'; | ||
import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutBody, EuiTitle } from '@elastic/eui'; | ||
import { | ||
SavedObjectFinderUi, | ||
SavedObjectMetaData, | ||
} from '../../../../../../src/plugins/saved_objects/public/'; | ||
import { ComponentStrings } from '../../../i18n'; | ||
import { useServices } from '../../services'; | ||
|
||
const { AddEmbeddableFlyout: strings } = ComponentStrings; | ||
|
||
export interface Props { | ||
onClose: () => void; | ||
onSelect: (id: string, embeddableType: string) => void; | ||
availableEmbeddables: string[]; | ||
} | ||
|
||
export const AddEmbeddableFlyout: FC<Props> = ({ onSelect, availableEmbeddables, onClose }) => { | ||
const services = useServices(); | ||
const { embeddables, platform } = services; | ||
const { getEmbeddableFactories } = embeddables; | ||
const { getSavedObjects, getUISettings } = platform; | ||
|
||
const onAddPanel = (id: string, savedObjectType: string, name: string) => { | ||
const embeddableFactories = getEmbeddableFactories(); | ||
|
||
// Find the embeddable type from the saved object type | ||
const found = Array.from(embeddableFactories).find((embeddableFactory) => { | ||
return Boolean( | ||
embeddableFactory.savedObjectMetaData && | ||
embeddableFactory.savedObjectMetaData.type === savedObjectType | ||
); | ||
}); | ||
|
||
const foundEmbeddableType = found ? found.type : 'unknown'; | ||
|
||
onSelect(id, foundEmbeddableType); | ||
}; | ||
|
||
const embeddableFactories = getEmbeddableFactories(); | ||
|
||
const availableSavedObjects = Array.from(embeddableFactories) | ||
.filter((factory) => { | ||
return availableEmbeddables.includes(factory.type); | ||
}) | ||
.map((factory) => factory.savedObjectMetaData) | ||
.filter<SavedObjectMetaData<{}>>(function ( | ||
maybeSavedObjectMetaData | ||
): maybeSavedObjectMetaData is SavedObjectMetaData<{}> { | ||
return maybeSavedObjectMetaData !== undefined; | ||
}); | ||
|
||
return ( | ||
<EuiFlyout ownFocus onClose={onClose} data-test-subj="dashboardAddPanel"> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="m"> | ||
<h2>{strings.getTitleText()}</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<SavedObjectFinderUi | ||
onChoose={onAddPanel} | ||
savedObjectMetaData={availableSavedObjects} | ||
showFilter={true} | ||
noItemsMessage={strings.getNoItemsText()} | ||
savedObjects={getSavedObjects()} | ||
uiSettings={getUISettings()} | ||
/> | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
}; |
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
11 changes: 11 additions & 0 deletions
11
x-pack/plugins/canvas/public/components/embeddable_flyout/index.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,11 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { EmbeddableFlyoutPortal, AddEmbeddablePanel } from './flyout'; | ||
export { | ||
AddEmbeddableFlyout as AddEmbeddableFlyoutComponent, | ||
Props as AddEmbeddableFlyoutComponentProps, | ||
} from './flyout.component'; |
113 changes: 0 additions & 113 deletions
113
x-pack/plugins/canvas/public/components/embeddable_flyout/index.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.