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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers';

import { CustomizeSpace } from './customize_space';
import { SpaceValidator } from '../../lib';
import { SectionPanel } from '../section_panel';

const validator = new SpaceValidator({ shouldValidate: true });

Expand All @@ -29,6 +30,29 @@ test('renders correctly', () => {
expect(wrapper).toMatchSnapshot();
});

test('allows title prop', () => {
const space = {
id: 'space-3',
name: 'Space 3',
initials: 'S3',
color: '#FEEDED',
customAvatarInitials: true,
customAvatarColor: true,
};
const changeHandler = jest.fn();

const wrapper = shallowWithIntl(
<CustomizeSpace
title="Cool Customize Space Title"
space={space}
editingExistingSpace={true}
validator={validator}
onChange={changeHandler}
/>
);
expect(wrapper.find(SectionPanel).prop('title')).toBe('Cool Customize Space Title');
});

test('updates identifier, initials and color when name is changed', () => {
const space = {
id: 'space-1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Props {
space: FormValues;
editingExistingSpace: boolean;
onChange: (space: FormValues) => void;
title?: string;
}

interface State {
Expand All @@ -51,14 +52,11 @@ export class CustomizeSpace extends Component<Props, State> {
};

public render() {
const { validator, editingExistingSpace, space } = this.props;
const { validator, editingExistingSpace, space, title } = this.props;
const { name = '', description = '' } = space;
const panelTitle = i18n.translate('xpack.spaces.management.manageSpacePage.generalTitle', {
defaultMessage: 'General',
});

return (
<SectionPanel title={panelTitle} dataTestSubj="generalPanel">
<SectionPanel title={title} dataTestSubj="generalPanel">
<EuiDescribedFormGroup
title={
<EuiTitle size="xs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export class ManageSpacePage extends Component<Props, State> {
return (
<div data-test-subj="spaces-edit-page">
<CustomizeSpace
title={i18n.translate('xpack.spaces.management.manageSpacePage.generalTitle', {
defaultMessage: 'General',
})}
space={this.state.space}
onChange={this.onSpaceChange}
editingExistingSpace={this.editingExistingSpace()}
Expand All @@ -198,7 +201,14 @@ export class ManageSpacePage extends Component<Props, State> {
{!!this.props.allowSolutionVisibility && (
<>
<EuiSpacer size="l" />
<SolutionView space={this.state.space} onChange={this.onSpaceChange} />
<SolutionView
space={this.state.space}
onChange={this.onSpaceChange}
sectionTitle={i18n.translate(
'xpack.spaces.management.manageSpacePage.navigationTitle',
{ defaultMessage: 'Navigation' }
)}
/>
</>
)}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ test('it renders without blowing up', () => {
expect(wrapper).toMatchSnapshot();
});

test('it renders without optional title', () => {
const wrapper = shallowWithIntl(
<SectionPanel iconType="wrench">
<p>child</p>
</SectionPanel>
);

expect(wrapper).toMatchSnapshot();
});

test('it renders children', () => {
const wrapper = mountWithIntl(
<SectionPanel iconType="logoElasticsearch" title="Elasticsearch">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import React, { Component, Fragment } from 'react';

interface Props {
iconType?: IconType;
title: string | ReactNode;
title?: string | ReactNode;
dataTestSubj?: string;
}

Expand All @@ -27,6 +27,10 @@ export class SectionPanel extends Component<Props, {}> {
}

public getTitle = () => {
if (!this.props.title) {
return null;
}

return (
<EuiFlexGroup alignItems={'baseline'} gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>
Expand All @@ -52,7 +56,7 @@ export class SectionPanel extends Component<Props, {}> {
public getForm = () => {
return (
<Fragment>
<EuiSpacer />
{this.props.title ? <EuiSpacer /> : null}
{this.props.children}
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,14 @@ const getOptions = ({ size }: EuiThemeComputed): Array<EuiSuperSelectOption<Solu
interface Props {
space: Partial<Space>;
onChange: (space: Partial<Space>) => void;
sectionTitle?: string;
}

export const SolutionView: FunctionComponent<Props> = ({ space, onChange }) => {
export const SolutionView: FunctionComponent<Props> = ({ space, onChange, sectionTitle }) => {
const { euiTheme } = useEuiTheme();

return (
<SectionPanel
title={i18n.translate('xpack.spaces.management.manageSpacePage.navigationTitle', {
defaultMessage: 'Navigation',
})}
dataTestSubj="navigationPanel"
>
<SectionPanel title={sectionTitle} dataTestSubj="navigationPanel">
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="xs">
Expand Down