mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-11 16:31:57 +00:00
hide the import/export and bulk edit button in case of entity is delete (#20306)
This commit is contained in:
parent
7fa3e53403
commit
ba4549ca3f
@ -334,7 +334,7 @@ export const DatabaseSchemaTable = ({
|
|||||||
dataSource={schemas}
|
dataSource={schemas}
|
||||||
defaultVisibleColumns={DEFAULT_DATABASE_SCHEMA_VISIBLE_COLUMNS}
|
defaultVisibleColumns={DEFAULT_DATABASE_SCHEMA_VISIBLE_COLUMNS}
|
||||||
extraTableFilters={getBulkEditButton(
|
extraTableFilters={getBulkEditButton(
|
||||||
permissions.databaseSchema.EditAll,
|
permissions.databaseSchema.EditAll && !isDatabaseDeleted,
|
||||||
handleEditTable
|
handleEditTable
|
||||||
)}
|
)}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
|
|||||||
@ -625,7 +625,7 @@ const SchemaTable = () => {
|
|||||||
defaultVisibleColumns={DEFAULT_SCHEMA_TABLE_VISIBLE_COLUMNS}
|
defaultVisibleColumns={DEFAULT_SCHEMA_TABLE_VISIBLE_COLUMNS}
|
||||||
expandable={expandableConfig}
|
expandable={expandableConfig}
|
||||||
extraTableFilters={getBulkEditButton(
|
extraTableFilters={getBulkEditButton(
|
||||||
tablePermissions.EditAll,
|
tablePermissions.EditAll && !deleted,
|
||||||
handleEditTable
|
handleEditTable
|
||||||
)}
|
)}
|
||||||
locale={{
|
locale={{
|
||||||
|
|||||||
@ -106,9 +106,10 @@ const APICollectionPage: FunctionComponent = () => {
|
|||||||
entityUtilClassBase.getManageExtraOptions(
|
entityUtilClassBase.getManageExtraOptions(
|
||||||
EntityType.API_COLLECTION,
|
EntityType.API_COLLECTION,
|
||||||
decodedAPICollectionFQN,
|
decodedAPICollectionFQN,
|
||||||
apiCollectionPermission
|
apiCollectionPermission,
|
||||||
|
apiCollection?.deleted ?? false
|
||||||
),
|
),
|
||||||
[apiCollectionPermission, decodedAPICollectionFQN]
|
[apiCollectionPermission, decodedAPICollectionFQN, apiCollection?.deleted]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { currentVersion, apiCollectionId } = useMemo(
|
const { currentVersion, apiCollectionId } = useMemo(
|
||||||
|
|||||||
@ -128,9 +128,10 @@ const DatabaseDetails: FunctionComponent = () => {
|
|||||||
entityUtilClassBase.getManageExtraOptions(
|
entityUtilClassBase.getManageExtraOptions(
|
||||||
EntityType.DATABASE,
|
EntityType.DATABASE,
|
||||||
decodedDatabaseFQN,
|
decodedDatabaseFQN,
|
||||||
databasePermission
|
databasePermission,
|
||||||
|
database?.deleted ?? false
|
||||||
),
|
),
|
||||||
[decodedDatabaseFQN, databasePermission]
|
[decodedDatabaseFQN, databasePermission, database?.deleted]
|
||||||
);
|
);
|
||||||
const fetchDatabasePermission = async () => {
|
const fetchDatabasePermission = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@ -113,9 +113,14 @@ const DatabaseSchemaPage: FunctionComponent = () => {
|
|||||||
entityUtilClassBase.getManageExtraOptions(
|
entityUtilClassBase.getManageExtraOptions(
|
||||||
EntityType.DATABASE_SCHEMA,
|
EntityType.DATABASE_SCHEMA,
|
||||||
decodedDatabaseSchemaFQN,
|
decodedDatabaseSchemaFQN,
|
||||||
databaseSchemaPermission
|
databaseSchemaPermission,
|
||||||
|
databaseSchema?.deleted ?? false
|
||||||
),
|
),
|
||||||
[databaseSchemaPermission, decodedDatabaseSchemaFQN]
|
[
|
||||||
|
databaseSchemaPermission,
|
||||||
|
decodedDatabaseSchemaFQN,
|
||||||
|
databaseSchema?.deleted,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { version: currentVersion, id: databaseSchemaId = '' } = useMemo(
|
const { version: currentVersion, id: databaseSchemaId = '' } = useMemo(
|
||||||
|
|||||||
@ -261,7 +261,10 @@ function SchemaTablesTab({
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{getBulkEditButton(permissions.table.EditAll, handleEditTable)}
|
{getBulkEditButton(
|
||||||
|
permissions.table.EditAll && !databaseSchemaDetails.deleted,
|
||||||
|
handleEditTable
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -264,9 +264,15 @@ const ServiceDetailsPage: FunctionComponent = () => {
|
|||||||
? EntityType.DATABASE_SERVICE
|
? EntityType.DATABASE_SERVICE
|
||||||
: EntityType.ALL,
|
: EntityType.ALL,
|
||||||
decodedServiceFQN,
|
decodedServiceFQN,
|
||||||
servicePermission
|
servicePermission,
|
||||||
|
serviceDetails?.deleted ?? false
|
||||||
),
|
),
|
||||||
[servicePermission, decodedServiceFQN, serviceCategory]
|
[
|
||||||
|
servicePermission,
|
||||||
|
decodedServiceFQN,
|
||||||
|
serviceCategory,
|
||||||
|
serviceDetails?.deleted,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleShowDeleted = useCallback(
|
const handleShowDeleted = useCallback(
|
||||||
|
|||||||
@ -286,7 +286,8 @@ function ServiceMainTabContent({
|
|||||||
|
|
||||||
{entityType === EntityType.DATABASE_SERVICE &&
|
{entityType === EntityType.DATABASE_SERVICE &&
|
||||||
getBulkEditButton(
|
getBulkEditButton(
|
||||||
servicePermission.EditAll,
|
servicePermission.EditAll &&
|
||||||
|
!serviceDetails.deleted,
|
||||||
handleEditTable
|
handleEditTable
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -157,9 +157,10 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
entityUtilClassBase.getManageExtraOptions(
|
entityUtilClassBase.getManageExtraOptions(
|
||||||
EntityType.TABLE,
|
EntityType.TABLE,
|
||||||
tableFqn,
|
tableFqn,
|
||||||
tablePermissions
|
tablePermissions,
|
||||||
|
tableDetails?.deleted ?? false
|
||||||
),
|
),
|
||||||
[tablePermissions, tableFqn]
|
[tablePermissions, tableFqn, tableDetails?.deleted]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { viewUsagePermission, viewTestCasePermission } = useMemo(
|
const { viewUsagePermission, viewTestCasePermission } = useMemo(
|
||||||
|
|||||||
@ -177,7 +177,11 @@ describe('Database Util', () => {
|
|||||||
EditAll: true,
|
EditAll: true,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
|
|
||||||
const result = ExtraDatabaseDropdownOptions('databaseFqn', permission);
|
const result = ExtraDatabaseDropdownOptions(
|
||||||
|
'databaseFqn',
|
||||||
|
permission,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].key).toBe('import-button');
|
expect(result[0].key).toBe('import-button');
|
||||||
@ -189,7 +193,11 @@ describe('Database Util', () => {
|
|||||||
EditAll: false,
|
EditAll: false,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
|
|
||||||
const result = ExtraDatabaseDropdownOptions('databaseFqn', permission);
|
const result = ExtraDatabaseDropdownOptions(
|
||||||
|
'databaseFqn',
|
||||||
|
permission,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].key).toBe('export-button');
|
expect(result[0].key).toBe('export-button');
|
||||||
@ -201,7 +209,11 @@ describe('Database Util', () => {
|
|||||||
EditAll: true,
|
EditAll: true,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
|
|
||||||
const result = ExtraDatabaseDropdownOptions('databaseFqn', permission);
|
const result = ExtraDatabaseDropdownOptions(
|
||||||
|
'databaseFqn',
|
||||||
|
permission,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(2);
|
expect(result).toHaveLength(2);
|
||||||
expect(result[0].key).toBe('import-button');
|
expect(result[0].key).toBe('import-button');
|
||||||
@ -213,7 +225,26 @@ describe('Database Util', () => {
|
|||||||
ViewAll: false,
|
ViewAll: false,
|
||||||
EditAll: false,
|
EditAll: false,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
const result = ExtraDatabaseDropdownOptions('databaseFqn', permission);
|
const result = ExtraDatabaseDropdownOptions(
|
||||||
|
'databaseFqn',
|
||||||
|
permission,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toHaveLength(0);
|
||||||
|
expect(result).toStrictEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not render any buttons when the entity is deleted', () => {
|
||||||
|
const permission = {
|
||||||
|
ViewAll: true,
|
||||||
|
EditAll: true,
|
||||||
|
} as OperationPermission;
|
||||||
|
const result = ExtraDatabaseDropdownOptions(
|
||||||
|
'databaseFqn',
|
||||||
|
permission,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(0);
|
expect(result).toHaveLength(0);
|
||||||
expect(result).toStrictEqual([]);
|
expect(result).toStrictEqual([]);
|
||||||
|
|||||||
@ -222,7 +222,8 @@ export const getDatabaseWidgetsFromKey = (widgetConfig: WidgetConfig) => {
|
|||||||
|
|
||||||
export const ExtraDatabaseDropdownOptions = (
|
export const ExtraDatabaseDropdownOptions = (
|
||||||
fqn: string,
|
fqn: string,
|
||||||
permission: OperationPermission
|
permission: OperationPermission,
|
||||||
|
deleted: boolean
|
||||||
) => {
|
) => {
|
||||||
const { showModal } = useEntityExportModalProvider();
|
const { showModal } = useEntityExportModalProvider();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -230,7 +231,7 @@ export const ExtraDatabaseDropdownOptions = (
|
|||||||
const { ViewAll, EditAll } = permission;
|
const { ViewAll, EditAll } = permission;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...(EditAll
|
...(EditAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
@ -252,7 +253,7 @@ export const ExtraDatabaseDropdownOptions = (
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(ViewAll
|
...(ViewAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
@ -43,7 +43,8 @@ describe('ExtraDatabaseSchemaDropdownOptions', () => {
|
|||||||
|
|
||||||
const result = ExtraDatabaseSchemaDropdownOptions(
|
const result = ExtraDatabaseSchemaDropdownOptions(
|
||||||
'databaseSchemaFqn',
|
'databaseSchemaFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
@ -58,7 +59,8 @@ describe('ExtraDatabaseSchemaDropdownOptions', () => {
|
|||||||
|
|
||||||
const result = ExtraDatabaseSchemaDropdownOptions(
|
const result = ExtraDatabaseSchemaDropdownOptions(
|
||||||
'databaseSchemaFqn',
|
'databaseSchemaFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
@ -73,7 +75,8 @@ describe('ExtraDatabaseSchemaDropdownOptions', () => {
|
|||||||
|
|
||||||
const result = ExtraDatabaseSchemaDropdownOptions(
|
const result = ExtraDatabaseSchemaDropdownOptions(
|
||||||
'databaseSchemaFqn',
|
'databaseSchemaFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(2);
|
expect(result).toHaveLength(2);
|
||||||
@ -88,7 +91,23 @@ describe('ExtraDatabaseSchemaDropdownOptions', () => {
|
|||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
const result = ExtraDatabaseSchemaDropdownOptions(
|
const result = ExtraDatabaseSchemaDropdownOptions(
|
||||||
'databaseSchemaFqn',
|
'databaseSchemaFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toHaveLength(0);
|
||||||
|
expect(result).toStrictEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not render any buttons when the entity is deleted', () => {
|
||||||
|
const permission = {
|
||||||
|
ViewAll: true,
|
||||||
|
EditAll: true,
|
||||||
|
} as OperationPermission;
|
||||||
|
const result = ExtraDatabaseSchemaDropdownOptions(
|
||||||
|
'databaseSchemaFqn',
|
||||||
|
permission,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(0);
|
expect(result).toHaveLength(0);
|
||||||
|
|||||||
@ -124,7 +124,8 @@ export const getDataBaseSchemaPageBaseTabs = ({
|
|||||||
|
|
||||||
export const ExtraDatabaseSchemaDropdownOptions = (
|
export const ExtraDatabaseSchemaDropdownOptions = (
|
||||||
fqn: string,
|
fqn: string,
|
||||||
permission: OperationPermission
|
permission: OperationPermission,
|
||||||
|
deleted: boolean
|
||||||
) => {
|
) => {
|
||||||
const { showModal } = useEntityExportModalProvider();
|
const { showModal } = useEntityExportModalProvider();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -132,7 +133,7 @@ export const ExtraDatabaseSchemaDropdownOptions = (
|
|||||||
const { ViewAll, EditAll } = permission;
|
const { ViewAll, EditAll } = permission;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...(EditAll
|
...(EditAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
@ -156,7 +157,7 @@ export const ExtraDatabaseSchemaDropdownOptions = (
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(ViewAll
|
...(ViewAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
@ -43,7 +43,8 @@ describe('ExtraDatabaseServiceDropdownOptions', () => {
|
|||||||
|
|
||||||
const result = ExtraDatabaseServiceDropdownOptions(
|
const result = ExtraDatabaseServiceDropdownOptions(
|
||||||
'databaseServiceFqn',
|
'databaseServiceFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
@ -58,7 +59,8 @@ describe('ExtraDatabaseServiceDropdownOptions', () => {
|
|||||||
|
|
||||||
const result = ExtraDatabaseServiceDropdownOptions(
|
const result = ExtraDatabaseServiceDropdownOptions(
|
||||||
'databaseServiceFqn',
|
'databaseServiceFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
@ -73,7 +75,8 @@ describe('ExtraDatabaseServiceDropdownOptions', () => {
|
|||||||
|
|
||||||
const result = ExtraDatabaseServiceDropdownOptions(
|
const result = ExtraDatabaseServiceDropdownOptions(
|
||||||
'databaseServiceFqn',
|
'databaseServiceFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(2);
|
expect(result).toHaveLength(2);
|
||||||
@ -88,7 +91,23 @@ describe('ExtraDatabaseServiceDropdownOptions', () => {
|
|||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
const result = ExtraDatabaseServiceDropdownOptions(
|
const result = ExtraDatabaseServiceDropdownOptions(
|
||||||
'databaseServiceFqn',
|
'databaseServiceFqn',
|
||||||
permission
|
permission,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toHaveLength(0);
|
||||||
|
expect(result).toStrictEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not render any buttons when the entity is deleted', () => {
|
||||||
|
const permission = {
|
||||||
|
ViewAll: true,
|
||||||
|
EditAll: true,
|
||||||
|
} as OperationPermission;
|
||||||
|
const result = ExtraDatabaseServiceDropdownOptions(
|
||||||
|
'databaseServiceFqn',
|
||||||
|
permission,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result).toHaveLength(0);
|
expect(result).toHaveLength(0);
|
||||||
|
|||||||
@ -307,7 +307,8 @@ export const getDatabaseConfig = (type: DatabaseServiceType) => {
|
|||||||
|
|
||||||
export const ExtraDatabaseServiceDropdownOptions = (
|
export const ExtraDatabaseServiceDropdownOptions = (
|
||||||
fqn: string,
|
fqn: string,
|
||||||
permission: OperationPermission
|
permission: OperationPermission,
|
||||||
|
deleted: boolean
|
||||||
) => {
|
) => {
|
||||||
const { showModal } = useEntityExportModalProvider();
|
const { showModal } = useEntityExportModalProvider();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -315,7 +316,7 @@ export const ExtraDatabaseServiceDropdownOptions = (
|
|||||||
const { ViewAll, EditAll } = permission;
|
const { ViewAll, EditAll } = permission;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...(EditAll
|
...(EditAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
@ -339,7 +340,7 @@ export const ExtraDatabaseServiceDropdownOptions = (
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(ViewAll
|
...(ViewAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
@ -375,20 +375,35 @@ class EntityUtilClassBase {
|
|||||||
public getManageExtraOptions(
|
public getManageExtraOptions(
|
||||||
_entityType: EntityType,
|
_entityType: EntityType,
|
||||||
_fqn: string,
|
_fqn: string,
|
||||||
_permission: OperationPermission
|
_permission: OperationPermission,
|
||||||
|
_deleted: boolean
|
||||||
): ItemType[] {
|
): ItemType[] {
|
||||||
// We are encoding here since we are getting the decoded fqn from the OSS code
|
// We are encoding here since we are getting the decoded fqn from the OSS code
|
||||||
const encodedFqn = getEncodedFqn(_fqn);
|
const encodedFqn = getEncodedFqn(_fqn);
|
||||||
switch (_entityType) {
|
switch (_entityType) {
|
||||||
case EntityType.TABLE:
|
case EntityType.TABLE:
|
||||||
return [...ExtraTableDropdownOptions(encodedFqn, _permission)];
|
return [
|
||||||
|
...ExtraTableDropdownOptions(encodedFqn, _permission, _deleted),
|
||||||
|
];
|
||||||
case EntityType.DATABASE:
|
case EntityType.DATABASE:
|
||||||
return [...ExtraDatabaseDropdownOptions(encodedFqn, _permission)];
|
return [
|
||||||
|
...ExtraDatabaseDropdownOptions(encodedFqn, _permission, _deleted),
|
||||||
|
];
|
||||||
case EntityType.DATABASE_SCHEMA:
|
case EntityType.DATABASE_SCHEMA:
|
||||||
return [...ExtraDatabaseSchemaDropdownOptions(encodedFqn, _permission)];
|
return [
|
||||||
|
...ExtraDatabaseSchemaDropdownOptions(
|
||||||
|
encodedFqn,
|
||||||
|
_permission,
|
||||||
|
_deleted
|
||||||
|
),
|
||||||
|
];
|
||||||
case EntityType.DATABASE_SERVICE:
|
case EntityType.DATABASE_SERVICE:
|
||||||
return [
|
return [
|
||||||
...ExtraDatabaseServiceDropdownOptions(encodedFqn, _permission),
|
...ExtraDatabaseServiceDropdownOptions(
|
||||||
|
encodedFqn,
|
||||||
|
_permission,
|
||||||
|
_deleted
|
||||||
|
),
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@ -79,7 +79,7 @@ describe('TableUtils', () => {
|
|||||||
EditAll: true,
|
EditAll: true,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
|
|
||||||
const result = ExtraTableDropdownOptions('tableFqn', permission);
|
const result = ExtraTableDropdownOptions('tableFqn', permission, false);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].key).toBe('import-button');
|
expect(result[0].key).toBe('import-button');
|
||||||
@ -91,7 +91,7 @@ describe('TableUtils', () => {
|
|||||||
EditAll: false,
|
EditAll: false,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
|
|
||||||
const result = ExtraTableDropdownOptions('tableFqn', permission);
|
const result = ExtraTableDropdownOptions('tableFqn', permission, false);
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].key).toBe('export-button');
|
expect(result[0].key).toBe('export-button');
|
||||||
@ -103,7 +103,7 @@ describe('TableUtils', () => {
|
|||||||
EditAll: true,
|
EditAll: true,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
|
|
||||||
const result = ExtraTableDropdownOptions('tableFqn', permission);
|
const result = ExtraTableDropdownOptions('tableFqn', permission, false);
|
||||||
|
|
||||||
expect(result).toHaveLength(2);
|
expect(result).toHaveLength(2);
|
||||||
expect(result[0].key).toBe('import-button');
|
expect(result[0].key).toBe('import-button');
|
||||||
@ -115,7 +115,18 @@ describe('TableUtils', () => {
|
|||||||
ViewAll: false,
|
ViewAll: false,
|
||||||
EditAll: false,
|
EditAll: false,
|
||||||
} as OperationPermission;
|
} as OperationPermission;
|
||||||
const result = ExtraTableDropdownOptions('tableFqn', permission);
|
const result = ExtraTableDropdownOptions('tableFqn', permission, false);
|
||||||
|
|
||||||
|
expect(result).toHaveLength(0);
|
||||||
|
expect(result).toStrictEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not render any buttons when the entity is deleted', () => {
|
||||||
|
const permission = {
|
||||||
|
ViewAll: true,
|
||||||
|
EditAll: true,
|
||||||
|
} as OperationPermission;
|
||||||
|
const result = ExtraTableDropdownOptions('tableFqn', permission, true);
|
||||||
|
|
||||||
expect(result).toHaveLength(0);
|
expect(result).toHaveLength(0);
|
||||||
expect(result).toStrictEqual([]);
|
expect(result).toStrictEqual([]);
|
||||||
|
|||||||
@ -1076,7 +1076,8 @@ export const getColumnOptionsFromTableColumn = (columns: Column[]) => {
|
|||||||
|
|
||||||
export const ExtraTableDropdownOptions = (
|
export const ExtraTableDropdownOptions = (
|
||||||
fqn: string,
|
fqn: string,
|
||||||
permission: OperationPermission
|
permission: OperationPermission,
|
||||||
|
deleted: boolean
|
||||||
) => {
|
) => {
|
||||||
const { showModal } = useEntityExportModalProvider();
|
const { showModal } = useEntityExportModalProvider();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@ -1084,7 +1085,7 @@ export const ExtraTableDropdownOptions = (
|
|||||||
const { ViewAll, EditAll } = permission;
|
const { ViewAll, EditAll } = permission;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...(EditAll
|
...(EditAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
@ -1106,7 +1107,7 @@ export const ExtraTableDropdownOptions = (
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(ViewAll
|
...(ViewAll && !deleted
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user