-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
148 additions
and
12 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
17 changes: 17 additions & 0 deletions
17
.../drilldowns/public/components/flyout_manage_drilldowns/flyout_manage_drilldowns.story.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,17 @@ | ||
/* | ||
* 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 * as React from 'react'; | ||
import { EuiFlyout } from '@elastic/eui'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { FlyoutManageDrilldowns } from './flyout_manage_drilldowns'; | ||
import { drilldowns } from '../list_manage_drilldowns/test_data'; | ||
|
||
storiesOf('components/FlyoutManageDrilldowns', module).add('default', () => ( | ||
<EuiFlyout onClose={() => {}}> | ||
<FlyoutManageDrilldowns drilldowns={drilldowns} /> | ||
</EuiFlyout> | ||
)); |
64 changes: 64 additions & 0 deletions
64
...lugins/drilldowns/public/components/flyout_manage_drilldowns/flyout_manage_drilldowns.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,64 @@ | ||
/* | ||
* 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, { useState } from 'react'; | ||
import { FlyoutFrame } from '../flyout_frame'; | ||
import { DrilldownListItem, ListManageDrilldowns } from '../list_manage_drilldowns'; | ||
import { FlyoutDrilldownWizard } from '../flyout_drilldown_wizard'; | ||
import { txtManageDrilldowns } from './i18n'; | ||
|
||
export interface FlyoutManageDrilldownsProps { | ||
drilldowns: DrilldownListItem[]; | ||
onClose?: () => void; | ||
} | ||
|
||
enum ViewState { | ||
List, | ||
Create, | ||
Edit, | ||
} | ||
|
||
export function FlyoutManageDrilldowns({ | ||
drilldowns, | ||
onClose = () => {}, | ||
}: FlyoutManageDrilldownsProps) { | ||
const [viewState, setViewState] = useState<ViewState>(ViewState.List); | ||
|
||
switch (viewState) { | ||
case ViewState.Create: | ||
case ViewState.Edit: | ||
return ( | ||
<FlyoutDrilldownWizard | ||
mode={viewState === ViewState.Create ? 'create' : 'edit'} | ||
onSubmit={() => setViewState(ViewState.List)} | ||
onDelete={() => { | ||
setViewState(ViewState.List); | ||
}} | ||
onClose={() => { | ||
onClose(); | ||
}} | ||
onBack={() => { | ||
setViewState(ViewState.List); | ||
}} | ||
/> | ||
); | ||
case ViewState.List: | ||
default: | ||
return ( | ||
<FlyoutFrame title={txtManageDrilldowns} onClose={onClose}> | ||
<ListManageDrilldowns | ||
drilldowns={drilldowns} | ||
onCreate={() => { | ||
setViewState(ViewState.Create); | ||
}} | ||
onEdit={() => { | ||
setViewState(ViewState.Edit); | ||
}} | ||
/> | ||
</FlyoutFrame> | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
x-pack/plugins/drilldowns/public/components/flyout_manage_drilldowns/i18n.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,14 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const txtManageDrilldowns = i18n.translate( | ||
'xpack.drilldowns.components.FlyoutManageDrilldowns.manageDrilldownsTitle', | ||
{ | ||
defaultMessage: 'Manage Drilldowns', | ||
} | ||
); |