mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-14 00:19:16 +01:00
refactor: finish ApplicationList and add it to routes
This commit is contained in:
parent
fb403255ef
commit
f342d4d904
@ -1,5 +1,4 @@
|
|||||||
import React, { Component, useEffect } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { CircularProgress } from '@material-ui/core';
|
import { CircularProgress } from '@material-ui/core';
|
||||||
import { Warning } from '@material-ui/icons';
|
import { Warning } from '@material-ui/icons';
|
||||||
|
|
||||||
@ -10,28 +9,52 @@ import HeaderTitle from '../common/HeaderTitle';
|
|||||||
import useApplications from '../../hooks/api/getters/useApplications/useApplications';
|
import useApplications from '../../hooks/api/getters/useApplications/useApplications';
|
||||||
|
|
||||||
const ApplicationList = () => {
|
const ApplicationList = () => {
|
||||||
//missing useSettings
|
|
||||||
const { applications, refetchApplications } = useApplications();
|
const { applications, refetchApplications } = useApplications();
|
||||||
|
const [filter, setFilter] = useState('');
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refetchApplications();
|
refetchApplications();
|
||||||
|
// eslint-disable-next-line
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!applications) {
|
const filteredApplications = useMemo(() => {
|
||||||
|
const regExp = new RegExp(filter, 'i');
|
||||||
|
return filter
|
||||||
|
? applications?.filter(a => regExp.test(a.appName))
|
||||||
|
: applications;
|
||||||
|
}, [applications, filter]);
|
||||||
|
|
||||||
|
const Empty = () => (
|
||||||
|
<React.Fragment>
|
||||||
|
<section style={{ textAlign: 'center' }}>
|
||||||
|
<Warning /> <br />
|
||||||
|
<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>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!filteredApplications) {
|
||||||
return <CircularProgress variant="indeterminate" />;
|
return <CircularProgress variant="indeterminate" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={commonStyles.searchField}>
|
<div className={commonStyles.searchField}>
|
||||||
<SearchField
|
<SearchField value={filter} updateValue={setFilter} />
|
||||||
value={this.props.settings.filter}
|
|
||||||
updateValue={this.props.updateSetting.bind(this, 'filter')}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<PageContent headerContent={<HeaderTitle title="Applications" />}>
|
<PageContent headerContent={<HeaderTitle title="Applications" />}>
|
||||||
<div className={commonStyles.fullwidth}>
|
<div className={commonStyles.fullwidth}>
|
||||||
{applications.length > 0 ? (
|
{filteredApplications.length > 0 ? (
|
||||||
<AppsLinkList apps={applications} />
|
<AppsLinkList apps={filteredApplications} />
|
||||||
) : (
|
) : (
|
||||||
<Empty />
|
<Empty />
|
||||||
)}
|
)}
|
||||||
@ -42,29 +65,3 @@ const ApplicationList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default ApplicationList;
|
export default ApplicationList;
|
||||||
|
|
||||||
const Empty = () => (
|
|
||||||
<React.Fragment>
|
|
||||||
<section style={{ textAlign: 'center' }}>
|
|
||||||
<Warning /> <br />
|
|
||||||
<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>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
|
|
||||||
class ClientStrategies extends Component {
|
|
||||||
static propTypes = {
|
|
||||||
applications: PropTypes.array,
|
|
||||||
fetchAll: PropTypes.func.isRequired,
|
|
||||||
settings: PropTypes.object.isRequired,
|
|
||||||
updateSetting: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
@ -8,8 +8,8 @@ import useApplicationsApi from '../../hooks/api/actions/useApplicationsApi/useAp
|
|||||||
const ApplicationUpdate = ({ application }) => {
|
const ApplicationUpdate = ({ application }) => {
|
||||||
const { storeApplicationMetaData } = useApplicationsApi();
|
const { storeApplicationMetaData } = useApplicationsApi();
|
||||||
const { appName, icon, url, description } = application;
|
const { appName, icon, url, description } = application;
|
||||||
const [localUrl, setLocalUrl] = useState(url);
|
const [localUrl, setLocalUrl] = useState(url || '');
|
||||||
const [localDescription, setLocalDescription] = useState(description);
|
const [localDescription, setLocalDescription] = useState(description || '');
|
||||||
const commonStyles = useCommonStyles();
|
const commonStyles = useCommonStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -34,8 +34,7 @@ const EditApplication = () => {
|
|||||||
const { refetchApplication, application } = useApplication(name);
|
const { refetchApplication, application } = useApplication(name);
|
||||||
const { appName, url, description, icon = 'apps', createdAt } = application;
|
const { appName, url, description, icon = 'apps', createdAt } = application;
|
||||||
const { hasAccess } = useContext(AccessContext);
|
const { hasAccess } = useContext(AccessContext);
|
||||||
const { storeApplicationMetaData, deleteApplication } =
|
const { deleteApplication } = useApplicationsApi();
|
||||||
useApplicationsApi();
|
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [showDialog, setShowDialog] = useState(false);
|
const [showDialog, setShowDialog] = useState(false);
|
||||||
|
@ -7,7 +7,7 @@ import SearchIcon from '@material-ui/icons/Search';
|
|||||||
|
|
||||||
import { useStyles } from './styles';
|
import { useStyles } from './styles';
|
||||||
|
|
||||||
function SearchField({ updateValue, className }) {
|
function SearchField({ updateValue, className = '' }) {
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
|
||||||
const [localValue, setLocalValue] = useState('');
|
const [localValue, setLocalValue] = useState('');
|
||||||
|
@ -8,7 +8,6 @@ import HistoryPage from '../../page/history';
|
|||||||
import HistoryTogglePage from '../../page/history/toggle';
|
import HistoryTogglePage from '../../page/history/toggle';
|
||||||
import ShowArchive from '../../page/archive/show';
|
import ShowArchive from '../../page/archive/show';
|
||||||
import Archive from '../../page/archive';
|
import Archive from '../../page/archive';
|
||||||
import Applications from '../../page/applications';
|
|
||||||
import ContextFields from '../../page/context';
|
import ContextFields from '../../page/context';
|
||||||
import ListTagTypes from '../../page/tag-types';
|
import ListTagTypes from '../../page/tag-types';
|
||||||
import Addons from '../../page/addons';
|
import Addons from '../../page/addons';
|
||||||
@ -47,6 +46,7 @@ import CreateProject from '../project/Project/CreateProject/CreateProject';
|
|||||||
import CreateFeature from '../feature/CreateFeature/CreateFeature/CreateFeature';
|
import CreateFeature from '../feature/CreateFeature/CreateFeature/CreateFeature';
|
||||||
import EditFeature from '../feature/CreateFeature/EditFeature/EditFeature';
|
import EditFeature from '../feature/CreateFeature/EditFeature/EditFeature';
|
||||||
import EditApplication from '../application/EditApplication';
|
import EditApplication from '../application/EditApplication';
|
||||||
|
import ApplicationList from '../application/ApplicationList';
|
||||||
|
|
||||||
export const routes = [
|
export const routes = [
|
||||||
// Project
|
// Project
|
||||||
@ -203,7 +203,7 @@ export const routes = [
|
|||||||
{
|
{
|
||||||
path: '/applications',
|
path: '/applications',
|
||||||
title: 'Applications',
|
title: 'Applications',
|
||||||
component: Applications,
|
component: ApplicationList,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
layout: 'main',
|
layout: 'main',
|
||||||
menu: { mobile: true, advanced: true },
|
menu: { mobile: true, advanced: true },
|
||||||
|
Loading…
Reference in New Issue
Block a user