feat: add go back to site button (#2538)
This commit is contained in:
parent
ab5860f58e
commit
f206e7e5a1
@ -76,6 +76,7 @@ export default class BitbucketAuthenticationPage extends React.Component {
|
|||||||
loginDisabled={inProgress}
|
loginDisabled={inProgress}
|
||||||
loginErrorMessage={this.state.loginError}
|
loginErrorMessage={this.state.loginError}
|
||||||
logoUrl={config.get('logo_url')}
|
logoUrl={config.get('logo_url')}
|
||||||
|
siteUrl={config.get('site_url')}
|
||||||
renderButtonContent={() => (
|
renderButtonContent={() => (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<LoginButtonIcon type="bitbucket" />
|
<LoginButtonIcon type="bitbucket" />
|
||||||
|
@ -157,6 +157,7 @@ export default class GitGatewayAuthenticationPage extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<AuthenticationPage
|
<AuthenticationPage
|
||||||
logoUrl={config.get('logo_url')}
|
logoUrl={config.get('logo_url')}
|
||||||
|
siteUrl={config.get('site_url')}
|
||||||
renderPageContent={() => (
|
renderPageContent={() => (
|
||||||
<AuthForm onSubmit={this.handleLogin}>
|
<AuthForm onSubmit={this.handleLogin}>
|
||||||
{!error ? null : <ErrorMessage>{error}</ErrorMessage>}
|
{!error ? null : <ErrorMessage>{error}</ErrorMessage>}
|
||||||
|
@ -133,6 +133,7 @@ export default class GitHubAuthenticationPage extends React.Component {
|
|||||||
loginDisabled={inProgress || findingFork || requestingFork}
|
loginDisabled={inProgress || findingFork || requestingFork}
|
||||||
loginErrorMessage={loginError}
|
loginErrorMessage={loginError}
|
||||||
logoUrl={config.get('logo_url')}
|
logoUrl={config.get('logo_url')}
|
||||||
|
siteUrl={config.get('site_url')}
|
||||||
{...this.getAuthenticationPageRenderArgs()}
|
{...this.getAuthenticationPageRenderArgs()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -70,6 +70,7 @@ export default class GitLabAuthenticationPage extends React.Component {
|
|||||||
loginDisabled={inProgress}
|
loginDisabled={inProgress}
|
||||||
loginErrorMessage={this.state.loginError}
|
loginErrorMessage={this.state.loginError}
|
||||||
logoUrl={config.get('logo_url')}
|
logoUrl={config.get('logo_url')}
|
||||||
|
siteUrl={config.get('site_url')}
|
||||||
renderButtonContent={() => (
|
renderButtonContent={() => (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<LoginButtonIcon type="gitlab" /> {inProgress ? 'Logging in...' : 'Login with GitLab'}
|
<LoginButtonIcon type="gitlab" /> {inProgress ? 'Logging in...' : 'Login with GitLab'}
|
||||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Icon, buttons, shadows } from 'netlify-cms-ui-default';
|
import { Icon, buttons, shadows, GoBackButton } from 'netlify-cms-ui-default';
|
||||||
|
|
||||||
const StyledAuthenticationPage = styled.section`
|
const StyledAuthenticationPage = styled.section`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -57,7 +57,7 @@ export default class AuthenticationPage extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { inProgress } = this.props;
|
const { config, inProgress } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledAuthenticationPage>
|
<StyledAuthenticationPage>
|
||||||
@ -65,6 +65,7 @@ export default class AuthenticationPage extends React.Component {
|
|||||||
<LoginButton disabled={inProgress} onClick={this.handleLogin}>
|
<LoginButton disabled={inProgress} onClick={this.handleLogin}>
|
||||||
{inProgress ? 'Logging in...' : 'Login'}
|
{inProgress ? 'Logging in...' : 'Login'}
|
||||||
</LoginButton>
|
</LoginButton>
|
||||||
|
{config.get('site_url') && <GoBackButton href={config.get('site_url')}></GoBackButton>}
|
||||||
</StyledAuthenticationPage>
|
</StyledAuthenticationPage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import Icon from './Icon';
|
import Icon from './Icon';
|
||||||
import { buttons, shadows } from './styles';
|
import { buttons, shadows } from './styles';
|
||||||
|
import { GoBackButton } from './GoBackButton';
|
||||||
|
|
||||||
const StyledAuthenticationPage = styled.section`
|
const StyledAuthenticationPage = styled.section`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -67,6 +68,7 @@ const AuthenticationPage = ({
|
|||||||
renderButtonContent,
|
renderButtonContent,
|
||||||
renderPageContent,
|
renderPageContent,
|
||||||
logoUrl,
|
logoUrl,
|
||||||
|
siteUrl,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<StyledAuthenticationPage>
|
<StyledAuthenticationPage>
|
||||||
@ -78,6 +80,7 @@ const AuthenticationPage = ({
|
|||||||
{renderButtonContent()}
|
{renderButtonContent()}
|
||||||
</LoginButton>
|
</LoginButton>
|
||||||
)}
|
)}
|
||||||
|
{siteUrl && <GoBackButton href={siteUrl} />}
|
||||||
{logoUrl ? <NetlifyCreditIcon size="100px" type="netlify-cms" /> : null}
|
{logoUrl ? <NetlifyCreditIcon size="100px" type="netlify-cms" /> : null}
|
||||||
</StyledAuthenticationPage>
|
</StyledAuthenticationPage>
|
||||||
);
|
);
|
||||||
@ -86,6 +89,7 @@ const AuthenticationPage = ({
|
|||||||
AuthenticationPage.propTypes = {
|
AuthenticationPage.propTypes = {
|
||||||
onLogin: PropTypes.func,
|
onLogin: PropTypes.func,
|
||||||
logoUrl: PropTypes.string,
|
logoUrl: PropTypes.string,
|
||||||
|
siteUrl: PropTypes.string,
|
||||||
loginDisabled: PropTypes.bool,
|
loginDisabled: PropTypes.bool,
|
||||||
loginErrorMessage: PropTypes.node,
|
loginErrorMessage: PropTypes.node,
|
||||||
renderButtonContent: PropTypes.func,
|
renderButtonContent: PropTypes.func,
|
||||||
|
31
packages/netlify-cms-ui-default/src/GoBackButton.js
Normal file
31
packages/netlify-cms-ui-default/src/GoBackButton.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import styled from '@emotion/styled';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { colorsRaw } from './styles.js';
|
||||||
|
import Icon from './Icon';
|
||||||
|
|
||||||
|
const GoBackButtonStyle = styled.a`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
margin-top: 50px;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
font-size: 14px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ButtonText = styled.p`
|
||||||
|
color: ${colorsRaw.gray};
|
||||||
|
margin: 0 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default class GoBackButton extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<GoBackButtonStyle href={this.props.href}>
|
||||||
|
<Icon type="arrow" size="small" />
|
||||||
|
<ButtonText>Go back to site</ButtonText>
|
||||||
|
</GoBackButtonStyle>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import Toggle, { ToggleContainer, ToggleBackground, ToggleHandle } from './Toggl
|
|||||||
import AuthenticationPage from './AuthenticationPage';
|
import AuthenticationPage from './AuthenticationPage';
|
||||||
import WidgetPreviewContainer from './WidgetPreviewContainer';
|
import WidgetPreviewContainer from './WidgetPreviewContainer';
|
||||||
import ObjectWidgetTopBar from './ObjectWidgetTopBar';
|
import ObjectWidgetTopBar from './ObjectWidgetTopBar';
|
||||||
|
import GoBackButton from './GoBackButton';
|
||||||
import {
|
import {
|
||||||
fonts,
|
fonts,
|
||||||
colorsRaw,
|
colorsRaw,
|
||||||
@ -76,4 +77,5 @@ export {
|
|||||||
effects,
|
effects,
|
||||||
reactSelectStyles,
|
reactSelectStyles,
|
||||||
GlobalStyles,
|
GlobalStyles,
|
||||||
|
GoBackButton,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user