Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
add hideButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
abz53378 committed May 24, 2018
1 parent b0af5b1 commit 5ac4d9c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/index.js
Expand Up @@ -28,7 +28,8 @@ class CMSExample extends React.Component {
database: defaultApp.database()
});
this.state = {
login: false
login: false,
dataChanged: {}
};
}

Expand Down Expand Up @@ -95,6 +96,7 @@ class CMSExample extends React.Component {
layouts={{
Tabs
}}
hideButtons={true}
/> :
null
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Generator.js
Expand Up @@ -59,7 +59,8 @@ type Props = {
deploy?: Function,
reset?: Function,
onDeploy?: Function,
removeOnDeploy?: Function
removeOnDeploy?: Function,
hideButtons: boolean
}

type childrenProps = {
Expand Down Expand Up @@ -178,7 +179,7 @@ export default class Generator extends React.PureComponent<Props, State> {
}

const {component, ...restNodeData} = node;
const {params, goTo, baseUrl, routes, imageServiceConfigs, onDeploy, removeOnDeploy} = this.props;
const {params, goTo, baseUrl, routes, imageServiceConfigs, onDeploy, removeOnDeploy, hideButtons} = this.props;
if (component) {
return <node.component
{...restNodeData}
Expand All @@ -190,6 +191,7 @@ export default class Generator extends React.PureComponent<Props, State> {
params={params}
onDeploy={onDeploy}
removeOnDeploy={removeOnDeploy}
hideButtons={hideButtons}
goTo={path => {
goTo(`${baseUrl}/${path}`)}
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/index.js
Expand Up @@ -51,7 +51,8 @@ type Props = {
locale: string,
defaultLocale: string,
message: Object
}
},
hideButtons: boolean
}

type State = {
Expand Down Expand Up @@ -150,7 +151,8 @@ class CannerCMS extends React.Component<Props, State> {
baseUrl,
history,
afterDeploy,
intl = {}
intl = {},
hideButtons
} = this.props;
const {location, push} = history;
const {pathname} = location;
Expand Down Expand Up @@ -183,6 +185,7 @@ class CannerCMS extends React.Component<Props, State> {
baseUrl={baseUrl}
routes={routes}
params={params}
hideButtons={hideButtons}
/>
</Provider>
</IntlProvider>
Expand Down
7 changes: 4 additions & 3 deletions src/hocs/deploy.js
Expand Up @@ -14,7 +14,8 @@ type Props = {
path: string,
pattern: string,
controlDeployAndResetButtons: boolean,
rootValue: any
rootValue: any,
hideButtons: boolean
};

type State = {
Expand Down Expand Up @@ -78,7 +79,7 @@ export default function deploy(Com: React.ComponentType<*>) {
}

render() {
const {params, routes, refId, path, pattern, controlDeployAndResetButtons} = this.props;
const {params, routes, refId, path, pattern, controlDeployAndResetButtons, hideButtons} = this.props;
const buttonContainer = {
textAlign: 'right',
marginTop: 60
Expand All @@ -87,7 +88,7 @@ export default function deploy(Com: React.ComponentType<*>) {
const renderCancelButton = genCancelButton(this.reset, refId);
const isCreateOp = params.op === 'create';
const shouldRenderButtons = (routes.length === 1 || isRoutesEndAtMe({routes, path, pattern}) &&
isCreateOp) && !controlDeployAndResetButtons && refId.getPathArr().length <= routes.length;
isCreateOp) && !controlDeployAndResetButtons && !hideButtons && refId.getPathArr().length <= routes.length;
return <div>
{/* $FlowFixMe */}
<Com {...this.props}
Expand Down

0 comments on commit 5ac4d9c

Please sign in to comment.