Skip to content

Commit d57dfe3

Browse files
authored
[Code] fix setup page (#32179)
1 parent 4511305 commit d57dfe3

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

x-pack/plugins/code/public/components/admin_page/setup_guide.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import {
1515
} from '@elastic/eui';
1616
import theme from '@elastic/eui/dist/eui_theme_light.json';
1717
import React from 'react';
18+
import { connect } from 'react-redux';
1819
import { Link } from 'react-router-dom';
1920
import styled from 'styled-components';
21+
import { RootState } from '../../reducers';
2022

2123
const Root = styled.div`
2224
padding: ${theme.euiSizeXxl} 0;
@@ -93,20 +95,20 @@ const steps = [
9395
},
9496
];
9597

96-
export const SetupGuide = (props: { setupFailed?: boolean }) => {
98+
const SetupGuidePage = (props: { setupOk?: boolean }) => {
9799
let setup = null;
98-
if (props.setupFailed !== undefined) {
100+
if (props.setupOk !== undefined) {
99101
setup = (
100102
<React.Fragment>
101-
{props.setupFailed && (
103+
{props.setupOk === false && (
102104
<EuiCallOut title="Code instance not found." color="danger" iconType="cross">
103105
<p>
104106
Please follow the guide below to configure your Kibana instance and then refresh this
105107
page.
106108
</p>
107109
</EuiCallOut>
108110
)}
109-
{props.setupFailed === false && (
111+
{props.setupOk === true && (
110112
<EuiButton iconType="sortLeft">
111113
<Link to="/admin">Back To Project Dashboard</Link>
112114
</EuiButton>
@@ -124,3 +126,8 @@ export const SetupGuide = (props: { setupFailed?: boolean }) => {
124126

125127
return <Root>{setup}</Root>;
126128
};
129+
const mapStateToProps = (state: RootState) => ({
130+
setupOk: state.setup.ok,
131+
});
132+
133+
export const SetupGuide = connect(mapStateToProps)(SetupGuidePage);

x-pack/plugins/code/public/components/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Search } from './search_page/search';
2020

2121
const Empty = () => null;
2222

23-
const RooComponent = (props: { setupOk: boolean }) => {
23+
const RooComponent = (props: { setupOk?: boolean }) => {
2424
if (props.setupOk) {
2525
return <Redirect to={'/admin'} />;
2626
}
@@ -44,7 +44,7 @@ export const App = () => {
4444
<Route path={ROUTES.ADMIN} component={Admin} />
4545
<Route path={ROUTES.SEARCH} component={Search} />
4646
<Route path={ROUTES.REPO} render={Empty} exact={true} />
47-
<Route path="/setup-guide" render={() => <SetupGuide setupFailed={false} />} exact={true} />
47+
<Route path={ROUTES.SETUP} component={SetupGuide} exact={true} />
4848
<Route path="*" component={NotFound} />
4949
</Switch>
5050
</Router>

x-pack/plugins/code/public/components/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { PathTypes } from '../common/types';
88

99
export const ROOT = '/';
10+
export const SETUP = '/setup-guide';
1011
const pathTypes = `:pathType(${PathTypes.blob}|${PathTypes.tree}|${PathTypes.blame}|${
1112
PathTypes.commits
1213
})`;

x-pack/plugins/code/public/reducers/setup.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import { handleActions } from 'redux-actions';
1010
import { checkSetupFailed, checkSetupSuccess } from '../actions';
1111

1212
export interface SetupState {
13-
ok: boolean;
13+
ok?: boolean;
1414
}
1515

16-
const initialState: SetupState = {
17-
ok: false,
18-
};
16+
const initialState: SetupState = {};
1917

2018
export const setup = handleActions(
2119
{

x-pack/plugins/code/public/sagas/patterns.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as ROUTES from '../components/routes';
1111
export const generatePattern = (path: string) => (action: Action<Match>) =>
1212
action.type === String(routeChange) && action.payload!.path === path;
1313
export const rootRoutePattern = generatePattern(ROUTES.ROOT);
14+
export const setupRoutePattern = generatePattern(ROUTES.SETUP);
1415
export const adminRoutePattern = generatePattern(ROUTES.ADMIN);
1516
export const repoRoutePattern = generatePattern(ROUTES.REPO);
1617
export const mainRoutePattern = (action: Action<Match>) =>

x-pack/plugins/code/public/sagas/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { call, put, takeEvery } from 'redux-saga/effects';
88
import { kfetch } from 'ui/kfetch';
99
import { checkSetupFailed, checkSetupSuccess } from '../actions';
10-
import { rootRoutePattern } from './patterns';
10+
import { rootRoutePattern, setupRoutePattern } from './patterns';
1111

1212
function* handleRootRoute() {
1313
try {
@@ -24,4 +24,5 @@ function requestSetup() {
2424

2525
export function* watchRootRoute() {
2626
yield takeEvery(rootRoutePattern, handleRootRoute);
27+
yield takeEvery(setupRoutePattern, handleRootRoute);
2728
}

0 commit comments

Comments
 (0)