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

[7.x] Fix page layouts, clean up unused code (#63992) #64024

Merged
merged 1 commit into from
Apr 21, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Tabs = styled(EuiTabs)`
`;

export interface HeaderProps {
restrictHeaderWidth?: number;
maxWidth?: number;
leftColumn?: JSX.Element;
rightColumn?: JSX.Element;
rightColumnGrow?: EuiFlexItemProps['grow'];
Expand All @@ -52,10 +52,10 @@ export const Header: React.FC<HeaderProps> = ({
rightColumn,
rightColumnGrow,
tabs,
restrictHeaderWidth,
maxWidth,
}) => (
<Container>
<Wrapper maxWidth={restrictHeaderWidth}>
<Wrapper maxWidth={maxWidth}>
<HeaderColumns
leftColumn={leftColumn}
rightColumn={rightColumn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ const Page = styled(EuiPage)`

interface Props extends HeaderProps {
restrictWidth?: number;
restrictHeaderWidth?: number;
children?: React.ReactNode;
}

export const WithHeaderLayout: React.FC<Props> = ({ restrictWidth, children, ...rest }) => (
export const WithHeaderLayout: React.FC<Props> = ({
restrictWidth,
restrictHeaderWidth,
children,
...rest
}) => (
<Fragment>
<Header {...rest} />
<Header maxWidth={restrictHeaderWidth} {...rest} />
<Page restrictWidth={restrictWidth || 1200}>
<EuiPageBody>
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ import {
import { WithHeaderLayout } from '../../../../layouts';
import { AgentConfig, PackageInfo } from '../../../../types';
import { PackageIcon } from '../../../../components/package_icon';
import { CreateDatasourceFrom, CreateDatasourceStep } from '../types';
import { CreateDatasourceFrom } from '../types';

export const CreateDatasourcePageLayout: React.FunctionComponent<{
from: CreateDatasourceFrom;
basePath: string;
cancelUrl: string;
maxStep: CreateDatasourceStep | '';
agentConfig?: AgentConfig;
packageInfo?: PackageInfo;
}> = ({ from, basePath, cancelUrl, maxStep, agentConfig, packageInfo, children }) => {
}> = ({ from, cancelUrl, agentConfig, packageInfo, children }) => {
const leftColumn = (
<EuiFlexGroup direction="column" gutterSize="s" alignItems="flexStart">
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import {
} from '../../../hooks';
import { useLinks as useEPMLinks } from '../../epm/hooks';
import { CreateDatasourcePageLayout, ConfirmCreateDatasourceModal } from './components';
import { CreateDatasourceFrom, CreateDatasourceStep } from './types';
import { CreateDatasourceFrom } from './types';
import { DatasourceValidationResults, validateDatasource, validationHasErrors } from './services';
import { StepSelectPackage } from './step_select_package';
import { StepSelectConfig } from './step_select_config';
import { StepConfigureDatasource } from './step_configure_datasource';

import { StepDefineDatasource } from './step_define_datasource';

export const CreateDatasourcePage: React.FunctionComponent = () => {
Expand All @@ -43,11 +42,9 @@ export const CreateDatasourcePage: React.FunctionComponent = () => {
} = useConfig();
const {
params: { configId, pkgkey },
url: basePath,
} = useRouteMatch();
const history = useHistory();
const from: CreateDatasourceFrom = configId ? 'config' : 'package';
const [maxStep, setMaxStep] = useState<CreateDatasourceStep | ''>('');

// Agent config and package info states
const [agentConfig, setAgentConfig] = useState<AgentConfig>();
Expand Down Expand Up @@ -91,7 +88,6 @@ export const CreateDatasourcePage: React.FunctionComponent = () => {
} else {
setFormState('INVALID');
setPackageInfo(undefined);
setMaxStep('');
}

// eslint-disable-next-line no-console
Expand All @@ -105,7 +101,6 @@ export const CreateDatasourcePage: React.FunctionComponent = () => {
} else {
setFormState('INVALID');
setAgentConfig(undefined);
setMaxStep('');
}

// eslint-disable-next-line no-console
Expand Down Expand Up @@ -189,9 +184,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => {

const layoutProps = {
from,
basePath,
cancelUrl,
maxStep,
agentConfig,
packageInfo,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
*/

export type CreateDatasourceFrom = 'package' | 'config';
export type CreateDatasourceStep = 'selectConfig' | 'selectPackage' | 'configure' | 'review';