Skip to content

Commit

Permalink
improve structure of components and containers (#717)
Browse files Browse the repository at this point in the history
* move Service Catalog and related containers into their own dirs

* improve consistency in Service Catalog and related components file naming
  • Loading branch information
prydonius authored Oct 10, 2018
1 parent b5014fa commit 859ecb6
Show file tree
Hide file tree
Showing 37 changed files with 106 additions and 48 deletions.
7 changes: 5 additions & 2 deletions dashboard/src/components/BindingList/BindingList.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as React from "react";

import { IServiceBindingWithSecret } from "../../shared/ServiceBinding";
import { BindingEntry } from "./BindingListEntry";
import BindingEntry from "./BindingListEntry";

interface IBindingList {
bindingsWithSecrets: IServiceBindingWithSecret[];
removeBinding: (name: string, namespace: string) => Promise<boolean>;
}

export class BindingList extends React.Component<IBindingList> {
class BindingList extends React.Component<IBindingList> {
public render() {
const { removeBinding, bindingsWithSecrets } = this.props;
return (
Expand Down Expand Up @@ -40,3 +41,5 @@ export class BindingList extends React.Component<IBindingList> {
);
}
}

export default BindingList;
10 changes: 6 additions & 4 deletions dashboard/src/components/BindingList/BindingListEntry.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import * as React from "react";
import { IServiceBindingWithSecret } from "../../shared/ServiceBinding";

import { RemoveBindingButton } from "../InstanceView/RemoveBindingButton";
import BindingDetails from "./BindingDetails";
import RemoveBindingButton from "./RemoveBindingButton";

interface IBindingEntryProps {
interface IBindingListEntryProps {
bindingWithSecret: IServiceBindingWithSecret;
removeBinding: (name: string, namespace: string) => Promise<boolean>;
}

interface IBindingEntryState {
interface IBindingListEntryState {
isExpanded: boolean;
}

export class BindingEntry extends React.Component<IBindingEntryProps, IBindingEntryState> {
class BindingListEntry extends React.Component<IBindingListEntryProps, IBindingListEntryState> {
public state = {
isExpanded: false,
};
Expand Down Expand Up @@ -62,3 +62,5 @@ export class BindingEntry extends React.Component<IBindingEntryProps, IBindingEn

private toggleExpand = async () => this.setState({ isExpanded: !this.state.isExpanded });
}

export default BindingListEntry;
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from "react";

import { IServiceBindingWithSecret } from "../../shared/ServiceBinding";

interface IRemoveBindingButtonProps {
bindingWithSecret: IServiceBindingWithSecret;
removeBinding: (name: string, ns: string) => Promise<boolean>;
}

export class RemoveBindingButton extends React.Component<IRemoveBindingButtonProps> {
class RemoveBindingButton extends React.Component<IRemoveBindingButtonProps> {
public render() {
return (
<div className="RemoveBindingButton">
Expand All @@ -29,3 +30,5 @@ export class RemoveBindingButton extends React.Component<IRemoveBindingButtonPro
removeBinding(name, namespace);
};
}

export default RemoveBindingButton;
3 changes: 3 additions & 0 deletions dashboard/src/components/BindingList/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import BindingList from "./BindingList";

export default BindingList;
4 changes: 3 additions & 1 deletion dashboard/src/components/ClassList/ClassList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const RequiredRBACRoles: IRBACRole[] = [
},
];

export default class ClassList extends React.Component<IClassListProps> {
class ClassList extends React.Component<IClassListProps> {
public componentDidMount() {
this.props.getClasses();
}
Expand Down Expand Up @@ -109,3 +109,5 @@ export default class ClassList extends React.Component<IClassListProps> {
);
}
}

export default ClassList;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { definedNamespaces } from "../../shared/Namespace";
import { IServicePlan } from "../../shared/ServiceCatalog";
import { ForbiddenError, IRBACRole } from "../../shared/types";
import { PermissionsErrorAlert, UnexpectedErrorAlert } from "../ErrorAlert";
import ProvisionButton from "../ProvisionButton";
import ProvisionButton from "./ProvisionButton";

const RequiredRBACRoles: IRBACRole[] = [
{
Expand Down Expand Up @@ -43,7 +43,7 @@ interface IClassViewProps {
namespace: string;
}

export class ClassView extends React.Component<IClassViewProps> {
class ClassView extends React.Component<IClassViewProps> {
public componentDidMount() {
this.props.getClasses();
this.props.getPlans();
Expand Down Expand Up @@ -149,3 +149,5 @@ export class ClassView extends React.Component<IClassViewProps> {
);
}
}

export default ClassView;
3 changes: 3 additions & 0 deletions dashboard/src/components/ClassView/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ClassView from "./ClassView";

export default ClassView;
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const RequiredRBACRoles: { [s: string]: IRBACRole[] } = {
],
};

export class AppRepoList extends React.Component<IAppRepoListProps> {
class AppRepoList extends React.Component<IAppRepoListProps> {
public componentDidMount() {
this.props.fetchRepos();
}
Expand Down Expand Up @@ -108,3 +108,5 @@ export class AppRepoList extends React.Component<IAppRepoListProps> {
);
}
}

export default AppRepoList;
3 changes: 3 additions & 0 deletions dashboard/src/components/Config/AppRepoList/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AppRepoList from "./AppRepoList";

export default AppRepoList;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ServiceBrokersNotFoundAlert,
UnexpectedErrorAlert,
} from "../../ErrorAlert";
import SyncButton from "../../SyncButton";
import SyncButton from "./SyncButton";

import "./ServiceBrokerList.css";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { IServiceBroker } from "../../shared/ServiceCatalog";
import { IServiceBroker } from "../../../shared/ServiceCatalog";

interface ISyncButtonProps {
broker: IServiceBroker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface IServiceCatalogProps {
sync: (broker: IServiceBroker) => Promise<any>;
}

export class ServiceCatalogView extends React.Component<IServiceCatalogProps> {
class ServiceCatalog extends React.Component<IServiceCatalogProps> {
public async componentDidMount() {
this.props.checkCatalogInstalled();
this.props.getBrokers();
Expand All @@ -38,3 +38,5 @@ export class ServiceCatalogView extends React.Component<IServiceCatalogProps> {
);
}
}

export default ServiceCatalog;
3 changes: 3 additions & 0 deletions dashboard/src/components/Config/ServiceCatalog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ServiceCatalog from "./ServiceCatalog";

export default ServiceCatalog;
3 changes: 3 additions & 0 deletions dashboard/src/components/ConfirmDialog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ConfirmDialog from "./ConfirmDialog";

export default ConfirmDialog;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { shallow } from "enzyme";
import * as React from "react";

import { MessageAlert } from "../ErrorAlert";
import { InstanceListView, InstanceListViewProps } from "./index";
import InstanceListView, { InstanceListViewProps } from "./InstanceListView";

it("renders the warning for alpha feature", () => {
const wrapper = shallow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface InstanceListViewProps {
namespace: string;
}

export interface InstanceListViewState {
interface InstanceListViewState {
filter: string;
}

Expand Down Expand Up @@ -195,3 +195,5 @@ export class InstanceListView extends React.PureComponent<
});
};
}

export default InstanceListView;
3 changes: 3 additions & 0 deletions dashboard/src/components/InstanceListView/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import InstanceListView from "./InstanceListView";

export default InstanceListView;
7 changes: 3 additions & 4 deletions dashboard/src/components/InstanceView/AddBindingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ const RequiredRBACRoles: IRBACRole[] = [
},
];

export class AddBindingButton extends React.Component<
IAddBindingButtonProps,
IAddBindingButtonState
> {
class AddBindingButton extends React.Component<IAddBindingButtonProps, IAddBindingButtonState> {
public state = {
bindingName: `${this.props.instanceRefName}-binding`,
displayNameForm: true,
Expand Down Expand Up @@ -156,3 +153,5 @@ export class AddBindingButton extends React.Component<
};
}
}

export default AddBindingButton;
10 changes: 6 additions & 4 deletions dashboard/src/components/InstanceView/InstanceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { IServiceBindingWithSecret } from "../../shared/ServiceBinding";
import { IServicePlan } from "../../shared/ServiceCatalog";
import { IServiceInstance } from "../../shared/ServiceInstance";
import { ForbiddenError, IRBACRole, NotFoundError } from "../../shared/types";
import { BindingList } from "../BindingList/BindingList";
import BindingList from "../BindingList";
import Card, { CardContent, CardGrid, CardIcon } from "../Card";
import DeprovisionButton from "../DeprovisionButton";
import { NotFoundErrorAlert, PermissionsErrorAlert, UnexpectedErrorAlert } from "../ErrorAlert";
import { AddBindingButton } from "./AddBindingButton";
import AddBindingButton from "./AddBindingButton";
import DeprovisionButton from "./DeprovisionButton";

interface IInstanceViewProps {
errors: {
Expand Down Expand Up @@ -83,7 +83,7 @@ const RequiredRBACRoles: { [s: string]: IRBACRole[] } = {
],
};

export class InstanceView extends React.Component<IInstanceViewProps> {
class InstanceView extends React.Component<IInstanceViewProps> {
public componentDidMount() {
this.props.getCatalog(this.props.namespace);
}
Expand Down Expand Up @@ -259,3 +259,5 @@ export class InstanceView extends React.Component<IInstanceViewProps> {
getCatalog(namespace);
};
}

export default InstanceView;
3 changes: 3 additions & 0 deletions dashboard/src/components/InstanceView/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import InstanceView from "./InstanceView";

export default InstanceView;
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import actions from "../actions";
import actions from "../../actions";

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

interface IRouteProps {
match: {
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/containers/ClassListContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ClassListContainer from "./ClassListContainer";

export default ClassListContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import actions from "../actions";
import actions from "../../actions";

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

interface IRouteProps {
match: {
Expand Down Expand Up @@ -55,7 +55,7 @@ function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>)
};
}

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

export default ClassViewContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { RouteComponentProps } from "react-router";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import actions from "../actions";
import { InstanceListView } from "../components/InstanceListView";
import { IStoreState } from "../shared/types";
import actions from "../../actions";
import InstanceListView from "../../components/InstanceListView";
import { IStoreState } from "../../shared/types";

function mapStateToProps(
{ catalog, namespace }: IStoreState,
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/containers/InstanceListViewContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import InstanceListViewContainer from "./InstanceListViewContainer";

export default InstanceListViewContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import actions from "../actions";
import { InstanceView } from "../components/InstanceView/InstanceView";
import { IServiceInstance } from "../shared/ServiceInstance";
import { IStoreState } from "../shared/types";
import actions from "../../actions";
import InstanceView from "../../components/InstanceView";
import { IServiceInstance } from "../../shared/ServiceInstance";
import { IStoreState } from "../../shared/types";

interface IRouteProps {
match: {
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/containers/InstanceViewContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import InstanceViewContainer from "./InstanceViewContainer";

export default InstanceViewContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import actions from "../actions";
import { AppRepoList } from "../components/Config/AppRepoList";
import { IStoreState } from "../shared/types";
import actions from "../../actions";
import AppRepoList from "../../components/Config/AppRepoList";
import { IStoreState } from "../../shared/types";

function mapStateToProps({ repos, config }: IStoreState) {
return {
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/containers/RepoListContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import RepoListContainer from "./RepoListContainer";

export default RepoListContainer;
4 changes: 2 additions & 2 deletions dashboard/src/containers/RoutesContainer/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import AppView from "../../containers/AppViewContainer";
import ChartList from "../../containers/ChartListContainer";
import ChartView from "../../containers/ChartViewContainer";
import ClassListContainer from "../../containers/ClassListContainer";
import { ClassViewContainer } from "../../containers/ClassView";
import ClassViewContainer from "../../containers/ClassViewContainer";
import InstanceListViewContainer from "../../containers/InstanceListViewContainer";
import InstanceView from "../../containers/InstanceView";
import InstanceView from "../../containers/InstanceViewContainer";
import LoginFormContainer from "../../containers/LoginFormContainer";
import PrivateRouteContainer from "../../containers/PrivateRouteContainer";
import RepoListContainer from "../../containers/RepoListContainer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";

import actions from "../actions";
import { ServiceCatalogView } from "../components/Config/ServiceCatalog";
import { IServiceBroker } from "../shared/ServiceCatalog";
import { IStoreState } from "../shared/types";
import actions from "../../actions";
import ServiceCatalog from "../../components/Config/ServiceCatalog";
import { IServiceBroker } from "../../shared/ServiceCatalog";
import { IStoreState } from "../../shared/types";

function mapStateToProps({ catalog }: IStoreState) {
return {
Expand All @@ -28,4 +28,4 @@ function mapDispatchToProps(dispatch: ThunkDispatch<IStoreState, null, Action>)
export default connect(
mapStateToProps,
mapDispatchToProps,
)(ServiceCatalogView);
)(ServiceCatalog);
3 changes: 3 additions & 0 deletions dashboard/src/containers/ServiceCatalogContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ServiceCatalogContainer from "./ServiceCatalogContainer";

export default ServiceCatalogContainer;

0 comments on commit 859ecb6

Please sign in to comment.