Skip to content

Commit

Permalink
Fix page layouts, clean up unused code (#63992)
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Apr 20, 2020
1 parent 197b7a5 commit 6e17b88
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
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';

0 comments on commit 6e17b88

Please sign in to comment.