Skip to content
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

[D&D] Type Service Contributions #1402

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/wizard/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"savedObjects",
"embeddable",
"dashboard",
"visualizations"
"visualizations",
"opensearchUiShared"
],
"optionalPlugins": []
}
4 changes: 2 additions & 2 deletions src/plugins/wizard/public/application/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
padding: 0;
display: grid;
grid-template-rows: min-content 1fr;
grid-template-columns: 420px 1fr;
grid-template-columns: 470px 1fr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to avoid making changes with pixels. could we use rem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the width of the side-panel. That unfortunately is not a good spot to use rem units which are more useful for fonts since we want the sizing to depend on the sizing of the parent element. This was changed to match the updated mocks.

grid-template-areas:
"topNav topNav"
"sideNav workspace"
;
height: calc(100vh - #{$osdHeaderOffset}); // TODO: update 190px to correct offset variable
height: calc(100vh - #{$osdHeaderOffset});
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "util";
@import "../util";

.wizSidenav {
@include scrollNavParent(auto 1fr);
Expand Down
30 changes: 9 additions & 21 deletions src/plugins/wizard/public/application/components/side_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@

import React from 'react';
import { i18n } from '@osd/i18n';

import { EuiFormLabel, EuiTabbedContent, EuiTabbedContentTab } from '@elastic/eui';

import { DataTab } from './data_tab';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { WizardServices } from '../../types';
import { StyleTab } from './style_tab';

import './side_nav.scss';
import { useTypedDispatch, useTypedSelector } from '../utils/state_management';
import { setIndexPattern } from '../utils/state_management/datasource_slice';
import { useVisualizationType } from '../utils/use';

export const SideNav = () => {
const {
Expand All @@ -27,23 +23,15 @@ export const SideNav = () => {
const { IndexPatternSelect } = data.ui;
const { indexPattern } = useTypedSelector((state) => state.dataSource);
const dispatch = useTypedDispatch();
const {
contributions: { containers },
} = useVisualizationType();

const tabs: EuiTabbedContentTab[] = [
{
id: 'data-tab',
name: i18n.translate('wizard.nav.dataTab.title', {
defaultMessage: 'Data',
}),
content: <DataTab />,
},
{
id: 'style-tab',
name: i18n.translate('wizard.nav.styleTab.title', {
defaultMessage: 'Style',
}),
content: <StyleTab />,
},
];
const tabs: EuiTabbedContentTab[] = containers.sidePanel.map(({ id, name, Component }) => ({
id,
name,
content: Component,
}));

return (
<section className="wizSidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
grid-gap: $euiSizeM;
padding: $euiSizeM;
background-color: $euiColorEmptyShade;
}

.wizWorkspace__empty {
height: 100%;
&__empty {
height: 100%;
}
}
10 changes: 3 additions & 7 deletions src/plugins/wizard/public/application/components/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
import React, { FC, useState, useMemo } from 'react';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { WizardServices } from '../../types';
import { useTypedDispatch, useTypedSelector } from '../utils/state_management';
import { useTypedDispatch } from '../utils/state_management';
import { setActiveVisualization } from '../utils/state_management/visualization_slice';
import { useVisualizationType } from '../utils/use';

import './workspace.scss';

Expand Down Expand Up @@ -49,17 +50,12 @@ export const Workspace: FC = ({ children }) => {

const TypeSelectorPopover = () => {
const [isPopoverOpen, setPopover] = useState(false);
const { activeVisualization: activeVisualizationId } = useTypedSelector(
(state) => state.visualization
);
const {
services: { types },
} = useOpenSearchDashboards<WizardServices>();
const dispatch = useTypedDispatch();

// TODO: Error if no active visualization
const activeVisualization = types.get(activeVisualizationId || '');
const visualizationTypes = types.all();
const activeVisualization = useVisualizationType();

const onButtonClick = () => {
setPopover(!isPopoverOpen);
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/wizard/public/application/contributions/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { CommonItemTypes } from './containers/common/items';
import { DataTabItemTypes } from './containers/data_tab/items';

export const ItemTypes = {
...CommonItemTypes,
...DataTabItemTypes,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './types';

export { Select } from './select';
export { TextInput } from './text_input';
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, { useMemo } from 'react';
import { EuiFormRow, EuiSuperSelect } from '@elastic/eui';
import { WizardServices } from 'src/plugins/wizard/public';
import { useOpenSearchDashboards } from '../../../../../../../opensearch_dashboards_react/public';
import { useTypedSelector } from '../../../../utils/state_management';
import { SelectContribution } from './types';

interface SelectProps extends Omit<SelectContribution<string>, 'type'> {
value: string;
}

export const Select = ({ label, options, onChange, value, ...rest }: SelectProps) => {
const rootState = useTypedSelector((state) => state);
const { services } = useOpenSearchDashboards<WizardServices>();
const selectOptions = useMemo(
() => (typeof options === 'function' ? options(rootState, services) : options),
[options, rootState, services]
);
// const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);

return (
<EuiFormRow
label={label}
// error={errorMessage}
// isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
>
<EuiSuperSelect
fullWidth
onChange={(newValue) => {
onChange?.(newValue);
}}
// isInvalid={isInvalid}
valueOfSelected={value || ''}
data-test-subj="select"
options={selectOptions}
/>
</EuiFormRow>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiFormRow, EuiFieldText } from '@elastic/eui';
import { InputContribution } from './types';

interface InputProps extends Omit<InputContribution, 'type'> {
value: string;
}

export const TextInput = ({ label, onChange, value, ...rest }: InputProps) => {
// const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);

return (
<EuiFormRow
label={label}
// error={errorMessage}
// isInvalid={isInvalid}
fullWidth
data-test-subj={rest['data-test-subj']}
describedByIds={rest.idAria ? [rest.idAria] : undefined}
>
<EuiFieldText
fullWidth
onChange={(event) => {
onChange?.(event.target.value);
}}
// isInvalid={isInvalid}
value={value || ''}
data-test-subj="text_input"
/>
</EuiFormRow>
);
};
Loading