-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Chore] Moves Drag and Drop to new branch #1400
Merged
ashwin-pc
merged 7 commits into
opensearch-project:feature/d-and-d
from
ashwin-pc:feature/d-and-d
Mar 29, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a2e05d5
Initial Drag and Drop plugin code (#946)
ashwin-pc b7907a6
Adds state management to Drag and Drop
ashwin-pc 9477522
Moves Drag and Drop to create visualization menu
ashwin-pc 68a1e38
Field Search in Data panel (#995)
abbashus a685985
Adds initial type service (#1260)
ashwin-pc 71fa5fe
chore: updates viz modal snapshot
ashwin-pc e9fdd29
fix(License): Fixes license headers
ashwin-pc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
216 changes: 120 additions & 96 deletions
216
src/plugins/visualizations/public/wizard/__snapshots__/new_vis_modal.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"prefix": "wizard", | ||
"paths": { | ||
"wizard": "." | ||
}, | ||
"translations": ["translations/ja-JP.json"] | ||
} |
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 @@ | ||
# wizard | ||
|
||
A OpenSearch Dashboards plugin | ||
|
||
--- | ||
|
||
## Development | ||
|
||
See the [OpenSearch Dashboards contributing | ||
guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/master/CONTRIBUTING.md) for instructions | ||
setting up your development environment. |
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,9 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const PLUGIN_ID = 'wizard'; | ||
export const PLUGIN_NAME = 'Wizard'; | ||
|
||
export { WizardSavedObjectAttributes, WIZARD_SAVED_OBJECT } from './wizard_saved_object_attributes'; |
14 changes: 14 additions & 0 deletions
14
src/plugins/wizard/common/wizard_saved_object_attributes.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 OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { SavedObjectAttributes } from 'opensearch-dashboards/public'; | ||
|
||
export const WIZARD_SAVED_OBJECT = 'wizard'; | ||
|
||
export interface WizardSavedObjectAttributes extends SavedObjectAttributes { | ||
title: string; | ||
description?: string; | ||
state: string; | ||
} |
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 @@ | ||
{ | ||
"id": "wizard", | ||
"version": "1.0.0", | ||
"opensearchDashboardsVersion": "opensearchDashboards", | ||
"server": true, | ||
"ui": true, | ||
"requiredPlugins": [ | ||
"navigation", | ||
"data", | ||
"opensearchDashboardsReact", | ||
"savedObjects", | ||
"embeddable", | ||
"dashboard", | ||
"visualizations" | ||
], | ||
"optionalPlugins": [] | ||
} |
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,3 @@ | ||
@import '@elastic/eui/src/global_styling/variables/header'; | ||
|
||
$osdHeaderOffset: $euiHeaderHeightCompensation * 2; |
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,13 @@ | ||
@import "variables"; | ||
|
||
.wizLayout { | ||
padding: 0; | ||
display: grid; | ||
grid-template-rows: min-content 1fr; | ||
grid-template-columns: 420px 1fr; | ||
grid-template-areas: | ||
"topNav topNav" | ||
"sideNav workspace" | ||
; | ||
height: calc(100vh - #{$osdHeaderOffset}); // TODO: update 190px to correct offset variable | ||
} |
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,29 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { I18nProvider } from '@osd/i18n/react'; | ||
import { EuiPage } from '@elastic/eui'; | ||
import { SideNav } from './components/side_nav'; | ||
import { DragDropProvider } from './utils/drag_drop/drag_drop_context'; | ||
import { Workspace } from './components/workspace'; | ||
|
||
import './app.scss'; | ||
import { TopNav } from './components/top_nav'; | ||
|
||
export const WizardApp = () => { | ||
// Render the application DOM. | ||
return ( | ||
<I18nProvider> | ||
<DragDropProvider> | ||
<EuiPage className="wizLayout"> | ||
<TopNav /> | ||
<SideNav /> | ||
<Workspace /> | ||
</EuiPage> | ||
</DragDropProvider> | ||
</I18nProvider> | ||
); | ||
}; |
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,8 @@ | ||
@mixin scrollNavParent ($template-row: none) { | ||
display: grid; | ||
min-height: 0; | ||
|
||
@if $template-row != 'none' { | ||
grid-template-rows: $template-row; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/plugins/wizard/public/application/components/data_tab/config_panel.scss
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,9 @@ | ||
.wizConfigPanel { | ||
background: #f0f1f3; | ||
border-left: $euiBorderThin; | ||
padding: $euiSizeS; | ||
} | ||
|
||
.wizConfigPanel__title { | ||
margin-left: $euiSizeS; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/plugins/wizard/public/application/components/data_tab/config_panel.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,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiForm, EuiTitle } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { i18n } from '@osd/i18n'; | ||
import { ConfigSection } from './config_section'; | ||
|
||
import './config_panel.scss'; | ||
import { useTypedSelector } from '../../utils/state_management'; | ||
|
||
export function ConfigPanel() { | ||
const { configSections } = useTypedSelector((state) => state.config); | ||
|
||
return ( | ||
<EuiForm className="wizConfigPanel"> | ||
<EuiTitle size="xxxs"> | ||
<h2 className="wizConfigPanel__title"> | ||
{i18n.translate('wizard.nav.dataTab.configPanel.title', { | ||
defaultMessage: 'Configuration', | ||
})} | ||
</h2> | ||
</EuiTitle> | ||
{Object.entries(configSections).map(([sectionId, sectionProps], index) => ( | ||
<ConfigSection key={index} id={sectionId} {...sectionProps} /> | ||
))} | ||
</EuiForm> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/plugins/wizard/public/application/components/data_tab/config_section.scss
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,23 @@ | ||
.wizConfigSection { | ||
margin-top: $euiSize; | ||
border-bottom: $euiBorderThin; | ||
padding-bottom: $euiSize; | ||
|
||
&:last-child { | ||
border-bottom: none; | ||
} | ||
|
||
& .euiFormRow__labelWrapper { | ||
margin-left: $euiSizeS; | ||
} | ||
} | ||
|
||
.wizConfigSection__dropTarget { | ||
@include euiSlightShadow; | ||
background: $euiColorEmptyShade; | ||
border: $euiBorderThin; | ||
box-shadow: 0px 2px 2px rgba(152, 162, 179, 0.15); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be pulled from the theme? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above. |
||
border-radius: $euiBorderRadius; | ||
padding: $euiSizeS $euiSizeM; | ||
color: $euiColorDarkShade; | ||
} |
83 changes: 83 additions & 0 deletions
83
src/plugins/wizard/public/application/components/data_tab/config_section.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,83 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiButtonIcon, EuiPanel, EuiText, EuiTitle } from '@elastic/eui'; | ||
import { i18n } from '@osd/i18n'; | ||
import React, { useCallback } from 'react'; | ||
import { IndexPatternField } from 'src/plugins/data/common'; | ||
import { useDrop } from '../../utils/drag_drop'; | ||
import { useTypedDispatch, useTypedSelector } from '../../utils/state_management'; | ||
import { | ||
addConfigSectionField, | ||
removeConfigSectionField, | ||
} from '../../utils/state_management/config_slice'; | ||
|
||
import './config_section.scss'; | ||
|
||
interface ConfigSectionProps { | ||
id: string; | ||
title: string; | ||
} | ||
|
||
export const ConfigSection = ({ title, id }: ConfigSectionProps) => { | ||
const dispatch = useTypedDispatch(); | ||
const { fields } = useTypedSelector((state) => state.config.configSections[id]); | ||
|
||
const dropHandler = useCallback( | ||
(field: IndexPatternField) => { | ||
dispatch( | ||
addConfigSectionField({ | ||
sectionId: id, | ||
field, | ||
}) | ||
); | ||
}, | ||
[dispatch, id] | ||
); | ||
const [dropProps, { isValidDropTarget, dragData }] = useDrop('dataPlane', dropHandler); | ||
|
||
const dropTargetString = dragData | ||
? dragData.type | ||
: i18n.translate('wizard.nav.dataTab.configPanel.dropTarget.placeholder', { | ||
defaultMessage: 'Click or drop to add', | ||
}); | ||
|
||
return ( | ||
<div className="wizConfigSection"> | ||
<EuiTitle size="xxxs"> | ||
<h3 className="wizConfigSection__title">{title}</h3> | ||
</EuiTitle> | ||
{fields.length ? ( | ||
fields.map((field, index) => ( | ||
<EuiPanel key={index} paddingSize="s" className="wizConfigSection__field"> | ||
<EuiText grow size="m"> | ||
{field.displayName} | ||
</EuiText> | ||
<EuiButtonIcon | ||
color="danger" | ||
iconType="cross" | ||
aria-label="clear-field" | ||
onClick={() => | ||
dispatch( | ||
removeConfigSectionField({ | ||
sectionId: id, | ||
field, | ||
}) | ||
) | ||
} | ||
/> | ||
</EuiPanel> | ||
)) | ||
) : ( | ||
<div | ||
className={`wizConfigSection__dropTarget ${isValidDropTarget && 'validDropTarget'}`} | ||
{...dropProps} | ||
> | ||
<EuiText size="s">{dropTargetString}</EuiText> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
47 changes: 47 additions & 0 deletions
47
src/plugins/wizard/public/application/components/data_tab/field_search.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,47 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@osd/i18n'; | ||
import { EuiFieldSearch, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { setSearchField } from '../../utils/state_management/datasource_slice'; | ||
import { useTypedDispatch } from '../../utils/state_management'; | ||
|
||
export interface Props { | ||
/** | ||
* the input value of the user | ||
*/ | ||
value?: string; | ||
} | ||
|
||
/** | ||
* Component is Wizard's side bar to search of available fields | ||
* Additionally there's a button displayed that allows the user to show/hide more filter fields | ||
*/ | ||
export function FieldSearch({ value }: Props) { | ||
const searchPlaceholder = i18n.translate('wizard.fieldChooser.searchPlaceHolder', { | ||
defaultMessage: 'Search field names', | ||
}); | ||
|
||
const dispatch = useTypedDispatch(); | ||
|
||
return ( | ||
<React.Fragment> | ||
<EuiFlexGroup responsive={false} gutterSize={'s'}> | ||
<EuiFlexItem> | ||
<EuiFieldSearch | ||
aria-label={searchPlaceholder} | ||
data-test-subj="fieldFilterSearchInput" | ||
compressed | ||
fullWidth | ||
onChange={(event) => dispatch(setSearchField(event.currentTarget.value))} | ||
placeholder={searchPlaceholder} | ||
value={value} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</React.Fragment> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/plugins/wizard/public/application/components/data_tab/field_selector.scss
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,10 @@ | ||
@import "../util"; | ||
|
||
.wizFieldSelector { | ||
@include scrollNavParent(auto 1fr); | ||
padding: $euiSizeS; | ||
} | ||
|
||
.wizFieldSelector__fieldGroups { | ||
overflow-y: auto; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this come from the theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently dont have this value (or similar) in EUI. The UI is still being updated. Will address all hardcoded colors in the fit and finish issue when we go over the styles for the whole app. We will either have to add these values in EUI or update our styles to follow EUI.