2018-03-26 00:46:45 +05:30
|
|
|
// @flow
|
2018-05-05 12:13:43 +05:30
|
|
|
import type { Node } from 'react';
|
|
|
|
import type { OauthAppResponse } from 'services/api/oauth';
|
2018-03-26 00:46:45 +05:30
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
|
|
|
import { Helmet } from 'react-helmet';
|
2018-05-05 12:13:43 +05:30
|
|
|
import { LinkButton } from 'components/ui/form';
|
|
|
|
import { COLOR_GREEN, COLOR_BLUE } from 'components/ui';
|
2018-05-05 13:12:29 +05:30
|
|
|
import { ContactLink } from 'components/contact';
|
2018-03-26 00:46:45 +05:30
|
|
|
|
|
|
|
import styles from './applicationsIndex.scss';
|
|
|
|
import messages from './ApplicationsIndex.intl.json';
|
|
|
|
import cubeIcon from './icons/cube.svg';
|
|
|
|
import loadingCubeIcon from './icons/loading-cube.svg';
|
|
|
|
import toolsIcon from './icons/tools.svg';
|
2018-11-04 11:01:31 +05:30
|
|
|
import ApplicationsList from './list';
|
2018-03-26 00:46:45 +05:30
|
|
|
|
|
|
|
type Props = {
|
2018-05-05 13:12:29 +05:30
|
|
|
clientId?: ?string,
|
2018-03-26 00:46:45 +05:30
|
|
|
displayForGuest: bool,
|
|
|
|
applications: Array<OauthAppResponse>,
|
|
|
|
isLoading: bool,
|
2018-11-04 11:01:31 +05:30
|
|
|
deleteApp: string => Promise<any>,
|
|
|
|
resetApp: (string, bool) => Promise<any>
|
2018-03-26 00:46:45 +05:30
|
|
|
};
|
|
|
|
|
2018-11-04 11:01:31 +05:30
|
|
|
export default class ApplicationsIndex extends Component<Props> {
|
2018-03-26 00:46:45 +05:30
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className={styles.container}>
|
|
|
|
<div className={styles.welcomeContainer}>
|
2018-11-04 11:01:31 +05:30
|
|
|
<Message {...messages.accountsForDevelopers}>
|
2018-03-26 00:46:45 +05:30
|
|
|
{(pageTitle: string) => (
|
|
|
|
<h2 className={styles.welcomeTitle}>
|
|
|
|
<Helmet title={pageTitle} />
|
|
|
|
{pageTitle}
|
|
|
|
</h2>
|
|
|
|
)}
|
|
|
|
</Message>
|
|
|
|
<div className={styles.welcomeTitleDelimiter} />
|
|
|
|
<div className={styles.welcomeParagraph}>
|
2018-11-04 11:01:31 +05:30
|
|
|
<Message
|
|
|
|
{...messages.accountsAllowsYouYoUseOauth2}
|
|
|
|
values={{
|
|
|
|
ourDocumentation: (
|
|
|
|
<a
|
|
|
|
href="http://docs.ely.by/oauth.html"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
<Message
|
|
|
|
{...messages.ourDocumentation}
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
/>
|
2018-03-26 00:46:45 +05:30
|
|
|
</div>
|
|
|
|
<div className={styles.welcomeParagraph}>
|
2018-11-04 11:01:31 +05:30
|
|
|
<Message
|
|
|
|
{...messages.ifYouHaveAnyTroubles}
|
|
|
|
values={{
|
|
|
|
feedback: (
|
|
|
|
<ContactLink>
|
|
|
|
<Message {...messages.feedback} />
|
|
|
|
</ContactLink>
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
/>
|
2018-03-26 00:46:45 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2018-11-04 11:01:31 +05:30
|
|
|
{this.getContent()}
|
2018-03-26 00:46:45 +05:30
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-04 11:01:31 +05:30
|
|
|
getContent() {
|
|
|
|
const {
|
|
|
|
displayForGuest,
|
|
|
|
applications,
|
|
|
|
isLoading,
|
|
|
|
resetApp,
|
|
|
|
deleteApp,
|
|
|
|
clientId
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (displayForGuest) {
|
|
|
|
return <Guest />;
|
|
|
|
} else if (isLoading) {
|
|
|
|
return <Loader />;
|
|
|
|
} else if (applications.length > 0) {
|
|
|
|
return (
|
|
|
|
<ApplicationsList
|
|
|
|
applications={applications}
|
|
|
|
resetApp={resetApp}
|
|
|
|
deleteApp={deleteApp}
|
|
|
|
clientId={clientId}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <NoApps />;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function Loader() {
|
|
|
|
return (
|
|
|
|
<div className={styles.emptyState}>
|
|
|
|
<img src={loadingCubeIcon} className={styles.loadingStateIcon} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Guest() {
|
|
|
|
return (
|
|
|
|
<div className={styles.emptyState}>
|
|
|
|
<img src={toolsIcon} className={styles.emptyStateIcon} />
|
|
|
|
<div className={styles.emptyStateText}>
|
|
|
|
<div>
|
|
|
|
<Message {...messages.weDontKnowAnythingAboutYou} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<Message {...messages.youMustAuthToBegin} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<LinkButton
|
|
|
|
to="/login"
|
|
|
|
label={messages.authorization}
|
|
|
|
color={COLOR_BLUE}
|
|
|
|
className={styles.emptyStateActionButton}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function NoApps() {
|
|
|
|
return (
|
|
|
|
<div className={styles.emptyState}>
|
|
|
|
<img src={cubeIcon} className={styles.emptyStateIcon} />
|
|
|
|
<div className={styles.emptyStateText}>
|
|
|
|
<div>
|
|
|
|
<Message {...messages.youDontHaveAnyApplication} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<Message {...messages.shallWeStart} />
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-05-05 12:13:43 +05:30
|
|
|
|
2018-11-04 11:01:31 +05:30
|
|
|
<LinkButton
|
|
|
|
to="/dev/applications/new"
|
|
|
|
label={messages.addNew}
|
|
|
|
color={COLOR_GREEN}
|
|
|
|
className={styles.emptyStateActionButton}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2018-03-26 00:46:45 +05:30
|
|
|
}
|