2018-03-26 00:46:45 +05:30
|
|
|
// @flow
|
2018-05-05 12:13:43 +05:30
|
|
|
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-11-04 11:52:04 +05:30
|
|
|
resetClientId: () => void, // notify parent to remove clientId from current location.href
|
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>,
|
2018-11-10 14:33:47 +05:30
|
|
|
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,
|
2018-11-04 11:52:04 +05:30
|
|
|
clientId,
|
|
|
|
resetClientId
|
2018-11-04 11:01:31 +05:30
|
|
|
} = 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}
|
2018-11-04 11:52:04 +05:30
|
|
|
resetClientId={resetClientId}
|
2018-11-04 11:01:31 +05:30
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 (
|
2018-11-10 14:33:47 +05:30
|
|
|
<div data-e2e="noApps" className={styles.emptyState}>
|
2018-11-04 11:01:31 +05:30
|
|
|
<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"
|
2018-11-10 14:33:47 +05:30
|
|
|
data-e2e="newApp"
|
2018-11-04 11:01:31 +05:30
|
|
|
label={messages.addNew}
|
|
|
|
color={COLOR_GREEN}
|
|
|
|
className={styles.emptyStateActionButton}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2018-03-26 00:46:45 +05:30
|
|
|
}
|