mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 17:04:54 +00:00
remove retenion period and displayName edit button if table is deleted (#15653)
This commit is contained in:
parent
834720c445
commit
c56a1533d8
@ -410,7 +410,7 @@ export const DataAssetsHeader = ({
|
||||
|
||||
{entityType === EntityType.TABLE && onUpdateRetentionPeriod && (
|
||||
<RetentionPeriod
|
||||
permissions={permissions}
|
||||
hasPermission={permissions.EditAll && !dataAsset.deleted}
|
||||
retentionPeriod={(dataAsset as Table).retentionPeriod}
|
||||
onUpdate={onUpdateRetentionPeriod}
|
||||
/>
|
||||
|
@ -14,7 +14,6 @@
|
||||
import { act, fireEvent, render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { NO_DATA_PLACEHOLDER } from '../../../constants/constants';
|
||||
import { OperationPermission } from '../../../context/PermissionProvider/PermissionProvider.interface';
|
||||
import RetentionPeriod from './RetentionPeriod.component';
|
||||
import { RetentionPeriodProps } from './RetentionPeriod.interface';
|
||||
|
||||
@ -34,7 +33,7 @@ const mockOnUpdate = jest.fn();
|
||||
const mockRetentionPeriodProps: RetentionPeriodProps = {
|
||||
retentionPeriod: undefined,
|
||||
onUpdate: mockOnUpdate,
|
||||
permissions: { EditAll: true } as OperationPermission,
|
||||
hasPermission: true,
|
||||
};
|
||||
|
||||
describe('Test Retention Period Component', () => {
|
||||
@ -145,12 +144,8 @@ describe('Test Retention Period Component', () => {
|
||||
});
|
||||
|
||||
it('Should not render Retention Period Component if has no permission', () => {
|
||||
const permissions = { EditAll: false } as OperationPermission;
|
||||
render(
|
||||
<RetentionPeriod
|
||||
{...mockRetentionPeriodProps}
|
||||
permissions={permissions}
|
||||
/>
|
||||
<RetentionPeriod {...mockRetentionPeriodProps} hasPermission={false} />
|
||||
);
|
||||
|
||||
expect(
|
||||
@ -158,5 +153,8 @@ describe('Test Retention Period Component', () => {
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByText(NO_DATA_PLACEHOLDER)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByTestId('edit-retention-period-button')
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ import { RetentionPeriodProps } from './RetentionPeriod.interface';
|
||||
const RetentionPeriod = ({
|
||||
retentionPeriod,
|
||||
onUpdate,
|
||||
permissions,
|
||||
hasPermission,
|
||||
}: RetentionPeriodProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [form] = useForm();
|
||||
@ -70,7 +70,7 @@ const RetentionPeriod = ({
|
||||
value={retentionPeriod ?? NO_DATA_PLACEHOLDER}
|
||||
/>
|
||||
|
||||
{permissions?.EditAll && (
|
||||
{hasPermission && (
|
||||
<Tooltip
|
||||
title={t('label.edit-entity', {
|
||||
entity: t('label.retention-period'),
|
||||
|
@ -11,10 +11,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { OperationPermission } from '../../../context/PermissionProvider/PermissionProvider.interface';
|
||||
|
||||
export interface RetentionPeriodProps {
|
||||
retentionPeriod?: string;
|
||||
onUpdate: (retentionPeriod: string) => Promise<void>;
|
||||
permissions: OperationPermission;
|
||||
hasPermission: boolean;
|
||||
}
|
||||
|
@ -348,28 +348,29 @@ const SchemaTable = ({
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
{(tablePermissions?.EditAll ||
|
||||
tablePermissions?.EditDisplayName) && (
|
||||
<Tooltip
|
||||
placement="right"
|
||||
title={t('label.edit-entity', {
|
||||
entity: t('label.display-name'),
|
||||
})}>
|
||||
<Button
|
||||
className="cursor-pointer hover-cell-icon w-fit-content"
|
||||
data-testid="edit-displayName-button"
|
||||
style={{
|
||||
color: DE_ACTIVE_COLOR,
|
||||
padding: 0,
|
||||
border: 'none',
|
||||
background: 'transparent',
|
||||
}}
|
||||
onClick={() => handleEditDisplayNameClick(record)}>
|
||||
<IconEdit
|
||||
style={{ color: DE_ACTIVE_COLOR, ...ICON_DIMENSION }}
|
||||
/>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
tablePermissions?.EditDisplayName) &&
|
||||
!isReadOnly && (
|
||||
<Tooltip
|
||||
placement="right"
|
||||
title={t('label.edit-entity', {
|
||||
entity: t('label.display-name'),
|
||||
})}>
|
||||
<Button
|
||||
className="cursor-pointer hover-cell-icon w-fit-content"
|
||||
data-testid="edit-displayName-button"
|
||||
style={{
|
||||
color: DE_ACTIVE_COLOR,
|
||||
padding: 0,
|
||||
border: 'none',
|
||||
background: 'transparent',
|
||||
}}
|
||||
onClick={() => handleEditDisplayNameClick(record)}>
|
||||
<IconEdit
|
||||
style={{ color: DE_ACTIVE_COLOR, ...ICON_DIMENSION }}
|
||||
/>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
@ -250,4 +250,21 @@ describe('Test EntityTable Component', () => {
|
||||
expect(columnDisplayName[0].textContent).toBe('Comments');
|
||||
expect(columnName[0].textContent).toBe('comments');
|
||||
});
|
||||
|
||||
it('should not render edit displayName button is table is deleted', async () => {
|
||||
render(
|
||||
<EntityTableV1
|
||||
{...mockEntityTableProp}
|
||||
isReadOnly
|
||||
tableColumns={[...columnsWithDisplayName]}
|
||||
/>,
|
||||
{
|
||||
wrapper: MemoryRouter,
|
||||
}
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.queryByTestId('edit-displayName-button')
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user