Skip to content

Commit

Permalink
Add skeleton to include operators in the dashboard (#1555)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Mar 4, 2020
1 parent 60fa172 commit 8b2861b
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 9 deletions.
1 change: 1 addition & 0 deletions chart/kubeapps/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,4 @@ authProxy:
## These are used to switch on in development features or new features not yet released.
featureFlags:
reposPerNamespace: false
operators: false
3 changes: 2 additions & 1 deletion dashboard/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"oauthLoginURI": "/oauth2/start",
"oauthLogoutURI": "/oauth2/sign_out",
"featureFlags": {
"reposPerNamespace": false
"reposPerNamespace": false,
"operators": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const makeStore = (
namespace: "",
appVersion: "",
oauthLogoutURI: "",
featureFlags: { reposPerNamespace: false },
featureFlags: { reposPerNamespace: false, operators: false },
};
return mockStore({ auth, config });
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react";
import { connect } from "react-redux";
import { RouteComponentProps } from "react-router";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import { IStoreState } from "../../shared/types";

function mapStateToProps(
{ apps, namespace, charts }: IStoreState,
{ location }: RouteComponentProps<{}>,
) {
return {};
}

function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>) {
return {};
}

class Comp extends React.Component {
public render() {
return <h1>This component has not been built yet</h1>;
}
}

export default connect(mapStateToProps, mapDispatchToProps)(Comp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import OperatorInstanceCreateContainer from "./OperatorInstanceCreateContainer";

export default OperatorInstanceCreateContainer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react";
import { connect } from "react-redux";
import { RouteComponentProps } from "react-router";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import { IStoreState } from "../../shared/types";

function mapStateToProps(
{ apps, namespace, charts }: IStoreState,
{ location }: RouteComponentProps<{}>,
) {
return {};
}

function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>) {
return {};
}

class Comp extends React.Component {
public render() {
return <h1>This component has not been built yet</h1>;
}
}

export default connect(mapStateToProps, mapDispatchToProps)(Comp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import OperatorInstanceViewContainer from "./OperatorInstanceViewContainer";

export default OperatorInstanceViewContainer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react";
import { connect } from "react-redux";
import { RouteComponentProps } from "react-router";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import { IStoreState } from "../../shared/types";

function mapStateToProps(
{ apps, namespace, charts }: IStoreState,
{ location }: RouteComponentProps<{}>,
) {
return {};
}

function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>) {
return {};
}

class Comp extends React.Component {
public render() {
return <h1>This component has not been built yet</h1>;
}
}

export default connect(mapStateToProps, mapDispatchToProps)(Comp);
3 changes: 3 additions & 0 deletions dashboard/src/containers/OperatorViewContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import OperatorViewContainer from "./OperatorViewContainer";

export default OperatorViewContainer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react";
import { connect } from "react-redux";
import { RouteComponentProps } from "react-router";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import { IStoreState } from "../../shared/types";

function mapStateToProps(
{ apps, namespace, charts }: IStoreState,
{ location }: RouteComponentProps<{}>,
) {
return {};
}

function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>) {
return {};
}

class Comp extends React.Component {
public render() {
return <h1>This component has not been built yet</h1>;
}
}

export default connect(mapStateToProps, mapDispatchToProps)(Comp);
3 changes: 3 additions & 0 deletions dashboard/src/containers/OperatorsListContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import OperatorsListContainer from "./OperatorsListContainer";

export default OperatorsListContainer;
4 changes: 2 additions & 2 deletions dashboard/src/containers/RoutesContainer/Routes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("Routes depending on feature flags", () => {
{...emptyRouteComponentProps}
namespace={namespace}
authenticated={true}
featureFlags={{ reposPerNamespace: false }}
featureFlags={{ reposPerNamespace: false, operators: false }}
/>
</StaticRouter>,
)
Expand All @@ -112,7 +112,7 @@ describe("Routes depending on feature flags", () => {
{...emptyRouteComponentProps}
namespace={namespace}
authenticated={true}
featureFlags={{ reposPerNamespace: true }}
featureFlags={{ reposPerNamespace: true, operators: false }}
/>
</StaticRouter>,
)
Expand Down
17 changes: 15 additions & 2 deletions dashboard/src/containers/RoutesContainer/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import AppViewContainer from "../../containers/AppViewContainer";
import CatalogContainer from "../../containers/CatalogContainer";
import ChartViewContainer from "../../containers/ChartViewContainer";
import LoginFormContainer from "../../containers/LoginFormContainer";
import OperatorInstanceCreateContainer from "../../containers/OperatorInstanceCreateContainer";
import OperatorInstanceViewContainer from "../../containers/OperatorInstanceViewContainer";
import OperatorsListContainer from "../../containers/OperatorsListContainer";
import OperatorViewContainer from "../../containers/OperatorViewContainer";
import PrivateRouteContainer from "../../containers/PrivateRouteContainer";
import RepoListContainer from "../../containers/RepoListContainer";
import ServiceBrokerListContainer from "../../containers/ServiceBrokerListContainer";
Expand Down Expand Up @@ -45,20 +49,29 @@ interface IRoutesProps extends IRouteComponentPropsAndRouteProps {
authenticated: boolean;
featureFlags: {
reposPerNamespace: boolean;
operators: boolean;
};
}

class Routes extends React.Component<IRoutesProps> {
public static defaultProps = {
featureFlags: { reposPerNamespace: false },
featureFlags: { reposPerNamespace: false, operators: false },
};
public render() {
// The path used for AppRepository list depends on a feature flag.
// TODO(mnelson, #1256) Remove when feature becomes default.
const reposPath = this.props.featureFlags.reposPerNamespace
? "/config/ns/:namespace/repos"
: "/config/repos";

if (this.props.featureFlags.operators) {
// Add routes related to operators
Object.assign(privateRoutes, {
"/operators/ns/:namespace": OperatorsListContainer,
"/operators/ns/:namespace/:operator": OperatorViewContainer,
"/operators-instances/ns/:namespace/:instanceName": OperatorInstanceViewContainer,
"/operators-instances/ns/:namespace/new/:operator/:instanceType": OperatorInstanceCreateContainer,
});
}
return (
<Switch>
<Route exact={true} path="/" render={this.rootNamespacedRedirect} />
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/reducers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const initialState: IConfigState = {
authProxyEnabled: false,
oauthLoginURI: "",
oauthLogoutURI: "",
featureFlags: { reposPerNamespace: true },
featureFlags: { reposPerNamespace: true, operators: true },
};

const configReducer = (state: IConfigState = initialState, action: ConfigAction): IConfigState => {
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/shared/Auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("Auth", () => {
oauthLogoutURI,
namespace: "ns",
appVersion: "2",
featureFlags: { reposPerNamespace: false },
featureFlags: { reposPerNamespace: false, operators: false },
});

expect(mockedAssign).toBeCalledWith(oauthLogoutURI);
Expand All @@ -185,7 +185,7 @@ describe("Auth", () => {
oauthLogoutURI: "",
namespace: "ns",
appVersion: "2",
featureFlags: { reposPerNamespace: false },
featureFlags: { reposPerNamespace: false, operators: false },
});

expect(mockedAssign).toBeCalledWith("/oauth2/sign_out");
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/shared/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IConfig {
error?: Error;
featureFlags: {
reposPerNamespace: boolean;
operators: boolean;
};
}

Expand Down

0 comments on commit 8b2861b

Please sign in to comment.