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

[Code]: add a toast for permission change in setup page #34901

Merged
merged 1 commit into from
Apr 10, 2019
Merged
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
103 changes: 72 additions & 31 deletions x-pack/plugins/code/public/components/admin_page/setup_guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import {
EuiButton,
EuiCallOut,
EuiGlobalToastList,
EuiPanel,
EuiSpacer,
EuiSteps,
EuiText,
EuiTitle,
} from '@elastic/eui';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import React from 'react';
import React, { Props } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
Expand Down Expand Up @@ -94,40 +95,80 @@ const steps = [
},
];

const SetupGuidePage = (props: { setupOk?: boolean }) => {
let setup = null;
if (props.setupOk !== undefined) {
setup = (
<React.Fragment>
{props.setupOk === false && (
<EuiCallOut title="Code instance not found." color="danger" iconType="cross">
<p>
Please follow the guide below to configure your Kibana instance and then refresh this
page.
</p>
</EuiCallOut>
)}
{props.setupOk === true && (
// TODO add link to learn more button
const toastMessage = (
<div>
<p>
We’ve made some changes to roles and permissions in Kibana. Read more about what these changes
mean for you below.{' '}
</p>
<EuiButton size="s" href="">Learn More</EuiButton>
</div>
);

class SetupGuidePage extends React.PureComponent<{ setupOk?: boolean }, { hideToast: boolean }> {
constructor(props: { setupOk?: boolean }) {
super(props);

this.state = {
hideToast: false,
};
}

public render() {
let setup = null;
if (this.props.setupOk !== undefined) {
setup = (
<div>
{!this.state.hideToast && (
<EuiGlobalToastList
toasts={[
{
title: 'Permission Changes',
color: 'primary',
iconType: 'iInCircle',
text: toastMessage,
id: '',
},
]}
dismissToast={() => {
this.setState({ hideToast: true });
}}
toastLifeTimeMs={10000}
/>
)}
<React.Fragment>
<EuiSpacer size="xs" />
<EuiButton iconType="sortLeft">
<Link to="/admin">Back To Project Dashboard</Link>
</EuiButton>
{this.props.setupOk === false && (
<EuiCallOut title="Code instance not found." color="danger" iconType="cross">
<p>
Please follow the guide below to configure your Kibana instance and then refresh
this page.
</p>
</EuiCallOut>
)}
{this.props.setupOk === true && (
<React.Fragment>
<EuiSpacer size="xs" />
<EuiButton iconType="sortLeft">
<Link to="/admin">Back To Project Dashboard</Link>
</EuiButton>
</React.Fragment>
)}
<EuiPanel>
<EuiTitle>
<h3>Getting started in Elastic Code</h3>
</EuiTitle>
<EuiSpacer />
<EuiSteps steps={steps} />
</EuiPanel>
</React.Fragment>
)}
<EuiPanel>
<EuiTitle>
<h3>Getting started in Elastic Code</h3>
</EuiTitle>
<EuiSpacer />
<EuiSteps steps={steps} />
</EuiPanel>
</React.Fragment>
);
</div>
);
}
return <Root>{setup}</Root>;
}
}

return <Root>{setup}</Root>;
};
const mapStateToProps = (state: RootState) => ({
setupOk: state.setup.ok,
});
Expand Down