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