From c2f0a975b5f4bff3928e6d02af85208616e0c544 Mon Sep 17 00:00:00 2001
From: Roger Batista
Date: Tue, 24 Sep 2024 12:15:01 +0200
Subject: [PATCH] Added global actions on empty screen
---
library/package.json | 2 +-
.../components/List/Content/Empty.styles.tsx | 8 ++++
library/src/components/List/Content/Empty.tsx | 48 ++++++++++++++++---
3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/library/package.json b/library/package.json
index c6f6201..2c350da 100644
--- a/library/package.json
+++ b/library/package.json
@@ -1,6 +1,6 @@
{
"name": "@irontec/ivoz-ui",
- "version": "1.5.1",
+ "version": "1.6.0",
"description": "UI library used in ivozprovider",
"license": "GPL-3.0",
"main": "index.js",
diff --git a/library/src/components/List/Content/Empty.styles.tsx b/library/src/components/List/Content/Empty.styles.tsx
index 2736435..d1823d5 100644
--- a/library/src/components/List/Content/Empty.styles.tsx
+++ b/library/src/components/List/Content/Empty.styles.tsx
@@ -22,5 +22,13 @@ export const StyledEmpty = styled(Empty)(() => {
'& img': {
maxWidth: '100%',
},
+
+ '& .empty-actions': {
+ display: 'flex',
+ flexDirection: 'row',
+ '& a': {
+ marginLeft: '8px',
+ },
+ },
};
});
diff --git a/library/src/components/List/Content/Empty.tsx b/library/src/components/List/Content/Empty.tsx
index 6de1e1a..a264ce9 100644
--- a/library/src/components/List/Content/Empty.tsx
+++ b/library/src/components/List/Content/Empty.tsx
@@ -3,8 +3,10 @@ import EntityService from '../../../services/entity/EntityService';
import _ from '../../../services/translations/translate';
import { SolidButton } from '../../shared/Button/Button.styles';
import { useTranslation } from 'react-i18next';
-import { Fade } from '@mui/material';
+import { Box, Fade } from '@mui/material';
import { useStoreState } from '../../../store';
+import { GlobalFunctionComponent, MultiSelectFunctionComponent } from 'router';
+import { MultiselectMoreChildEntityLinks } from './Shared/MultiselectMoreChildEntityLinks';
export interface EmptyProps {
entityService: EntityService;
@@ -16,7 +18,6 @@ export const Empty = (props: EmptyProps): JSX.Element => {
const { t } = useTranslation();
const entity = entityService.getEntity();
-
const parentRow = useStoreState((state) => state.list.parentRow);
const acls = entityService.getAcls(parentRow);
const { create = false } = acls;
@@ -30,6 +31,9 @@ export const Empty = (props: EmptyProps): JSX.Element => {
singularTitle = t(translationKey, { count: 1 }).toLowerCase();
pluralTitle = t(translationKey, { count: 2 }).toLowerCase();
}
+ const globalActions = Object.values(entity.customActions).filter(
+ (action) => action.global
+ );
return (
{
})}
{create && (
-
-
- {_('New {{entity}}', { entity: singularTitle })}
-
-
+
+ {globalActions &&
+ globalActions.length < 2 &&
+ globalActions
+ .map(
+ (item) =>
+ item.action as
+ | MultiSelectFunctionComponent
+ | GlobalFunctionComponent
+ )
+ .map((Action, key) => {
+ return (
+
+ );
+ })}
+ {globalActions && globalActions.length > 1 && (
+
+ )}
+
+
+
+ {_('New {{entity}}', { entity: singularTitle })}
+
+
+
)}