2022-02-09 16:15:07 +01:00
|
|
|
import { useMemo, useState } from 'react';
|
2022-02-04 12:45:08 +01:00
|
|
|
import { CircularProgress } from '@material-ui/core';
|
|
|
|
import { Warning } from '@material-ui/icons';
|
2022-03-28 10:49:59 +02:00
|
|
|
import { AppsLinkList, styles as commonStyles } from 'component/common';
|
2022-02-23 15:08:44 +01:00
|
|
|
import { SearchField } from 'component/common/SearchField/SearchField';
|
2022-03-28 10:49:59 +02:00
|
|
|
import PageContent from 'component/common/PageContent/PageContent';
|
2022-05-02 12:52:33 +02:00
|
|
|
import { HeaderTitle } from 'component/common/HeaderTitle/HeaderTitle';
|
2022-03-28 10:49:59 +02:00
|
|
|
import useApplications from 'hooks/api/getters/useApplications/useApplications';
|
2022-05-02 12:52:33 +02:00
|
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
2022-02-04 12:45:08 +01:00
|
|
|
|
2022-02-10 10:36:53 +01:00
|
|
|
export const ApplicationList = () => {
|
2022-02-10 10:05:50 +01:00
|
|
|
const { applications, loading } = useApplications();
|
2022-02-04 16:26:51 +01:00
|
|
|
const [filter, setFilter] = useState('');
|
2022-02-04 12:45:08 +01:00
|
|
|
|
2022-02-04 16:26:51 +01:00
|
|
|
const filteredApplications = useMemo(() => {
|
|
|
|
const regExp = new RegExp(filter, 'i');
|
|
|
|
return filter
|
|
|
|
? applications?.filter(a => regExp.test(a.appName))
|
|
|
|
: applications;
|
|
|
|
}, [applications, filter]);
|
|
|
|
|
2022-02-10 10:36:53 +01:00
|
|
|
const renderNoApplications = () => (
|
2022-02-09 16:15:07 +01:00
|
|
|
<>
|
2022-02-04 16:26:51 +01:00
|
|
|
<section style={{ textAlign: 'center' }}>
|
2022-04-21 08:26:49 +02:00
|
|
|
<Warning titleAccess="Warning" /> <br />
|
2022-02-04 16:26:51 +01:00
|
|
|
<br />
|
|
|
|
Oh snap, it does not seem like you have connected any
|
|
|
|
applications. To connect your application to Unleash you will
|
|
|
|
require a Client SDK.
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
You can read more about how to use Unleash in your application
|
|
|
|
in the{' '}
|
|
|
|
<a href="https://docs.getunleash.io/docs/sdks/">
|
|
|
|
documentation.
|
|
|
|
</a>
|
|
|
|
</section>
|
2022-02-09 16:15:07 +01:00
|
|
|
</>
|
2022-02-04 16:26:51 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
if (!filteredApplications) {
|
2022-02-04 12:45:08 +01:00
|
|
|
return <CircularProgress variant="indeterminate" />;
|
|
|
|
}
|
2022-02-04 16:26:51 +01:00
|
|
|
|
2022-02-04 12:45:08 +01:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className={commonStyles.searchField}>
|
2022-02-17 09:19:01 +01:00
|
|
|
<SearchField initialValue={filter} updateValue={setFilter} />
|
2022-02-04 12:45:08 +01:00
|
|
|
</div>
|
|
|
|
<PageContent headerContent={<HeaderTitle title="Applications" />}>
|
|
|
|
<div className={commonStyles.fullwidth}>
|
2022-02-10 10:05:50 +01:00
|
|
|
<ConditionallyRender
|
|
|
|
condition={filteredApplications.length > 0}
|
|
|
|
show={<AppsLinkList apps={filteredApplications} />}
|
|
|
|
elseShow={
|
|
|
|
<ConditionallyRender
|
|
|
|
condition={loading}
|
|
|
|
show={<div>...loading</div>}
|
2022-02-10 10:36:53 +01:00
|
|
|
elseShow={renderNoApplications()}
|
2022-02-10 10:05:50 +01:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
2022-02-04 12:45:08 +01:00
|
|
|
</div>
|
|
|
|
</PageContent>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|