-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds EmptyState with title
No Resource Found
This patch adds EmptyState with title `No Resource Found` if selected filter doesn't match to any resources Signed-off-by: Shiv Verma <shverma@redhat.com>
- Loading branch information
1 parent
d0849ef
commit f9b581f
Showing
3 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ | |
bottom: 0; | ||
margin: auto; | ||
} | ||
|
||
.hub-resource-emptystate__margin { | ||
margin-left: -12em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,43 @@ | ||
import React from 'react'; | ||
import { Gallery, Spinner } from '@patternfly/react-core'; | ||
import { useMst } from '../../store/root'; | ||
import { useObserver } from 'mobx-react'; | ||
import { | ||
EmptyState, | ||
EmptyStateIcon, | ||
EmptyStateVariant, | ||
Gallery, | ||
Spinner, | ||
Title | ||
} from '@patternfly/react-core'; | ||
import CubesIcon from '@patternfly/react-icons/dist/js/icons/cubes-icon'; | ||
import { useMst } from '../../store/root'; | ||
import { IResource } from '../../store/resource'; | ||
import Cards from '../../components/Cards'; | ||
import './Resources.css'; | ||
|
||
const Resources = () => { | ||
const { resources } = useMst(); | ||
|
||
const checkResources = (resources: IResource[]) => { | ||
return !resources.length ? ( | ||
<EmptyState variant={EmptyStateVariant.full} className="hub-resource-emptystate__margin"> | ||
<EmptyStateIcon icon={CubesIcon} /> | ||
<Title headingLevel="h5" size="md"> | ||
No Resource Found. | ||
</Title> | ||
</EmptyState> | ||
) : ( | ||
<Gallery hasGutter className="hub-resource"> | ||
<Cards items={resources} /> | ||
</Gallery> | ||
); | ||
}; | ||
|
||
return useObserver(() => | ||
resources.isLoading ? ( | ||
<Spinner className="hub-spinner" /> | ||
) : ( | ||
<React.Fragment> | ||
<Gallery hasGutter className="hub-resource"> | ||
<Cards items={resources.filteredResources} /> | ||
</Gallery> | ||
</React.Fragment> | ||
<React.Fragment>{checkResources(resources.filteredResources)}</React.Fragment> | ||
) | ||
); | ||
}; | ||
|
||
export default Resources; |