Skip to content

Commit

Permalink
feat: 🎸 augment factory context
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 16, 2020
1 parent 68a04ea commit f5b9e45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { TEST_SUBJ_DRILLDOWN_ITEM } from '../list_manage_drilldowns';
import { WELCOME_MESSAGE_TEST_SUBJ } from '../drilldown_hello_bar';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { NotificationsStart } from 'kibana/public';
import { toastDrilldownsCRUDError, toastDrilldownsFetchError } from './i18n';
import { toastDrilldownsCRUDError } from './i18n';

const storage = new Storage(new StubBrowserStorage());
const notifications = coreMock.createStart().notifications;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
toastDrilldownsCRUDError,
toastDrilldownsDeleted,
} from './i18n';
import { DrilldownFactoryContext } from '../../types';

interface ConnectedFlyoutManageDrilldownsProps<Context extends object = object> {
context: Context;
Expand Down Expand Up @@ -65,9 +66,15 @@ export function createFlyoutManageDrilldowns({
return (props: ConnectedFlyoutManageDrilldownsProps) => {
const isCreateOnly = props.viewMode === 'create';

const factoryContext: DrilldownFactoryContext<unknown> = {
place: '',
placeContext: props.context,
triggers: [],
};

const actionFactories = useCompatibleActionFactoriesForCurrentContext(
allActionFactories,
props.context
factoryContext
);

const [route, setRoute] = useState<Routes>(
Expand Down Expand Up @@ -121,8 +128,8 @@ export function createFlyoutManageDrilldowns({
return {
id: drilldown.eventId,
drilldownName: drilldown.action.name,
actionName: actionFactory?.getDisplayName(props.context) ?? drilldown.action.factoryId,
icon: actionFactory?.getIconType(props.context),
actionName: actionFactory?.getDisplayName(factoryContext) ?? drilldown.action.factoryId,
icon: actionFactory?.getIconType(factoryContext),
};
}

Expand Down Expand Up @@ -168,7 +175,7 @@ export function createFlyoutManageDrilldowns({
setRoute(Routes.Manage);
setCurrentEditId(null);
}}
actionFactoryContext={props.context}
actionFactoryContext={factoryContext}
initialDrilldownWizardConfig={resolveInitialDrilldownWizardConfig()}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/drilldowns/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export interface Drilldown<
*/
export interface DrilldownFactoryContext<T> {
/**
* List of places as configured in @type {Drilldown} interface.
* Place where factory is being rendered.
*/
places?: string[];
place?: string;

/**
* Context provided to the drilldown factory by the place where the UI is
Expand Down

0 comments on commit f5b9e45

Please sign in to comment.