mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 01:15:08 +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 && (
|
{entityType === EntityType.TABLE && onUpdateRetentionPeriod && (
|
||||||
<RetentionPeriod
|
<RetentionPeriod
|
||||||
permissions={permissions}
|
hasPermission={permissions.EditAll && !dataAsset.deleted}
|
||||||
retentionPeriod={(dataAsset as Table).retentionPeriod}
|
retentionPeriod={(dataAsset as Table).retentionPeriod}
|
||||||
onUpdate={onUpdateRetentionPeriod}
|
onUpdate={onUpdateRetentionPeriod}
|
||||||
/>
|
/>
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
import { act, fireEvent, render, screen } from '@testing-library/react';
|
import { act, fireEvent, render, screen } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { NO_DATA_PLACEHOLDER } from '../../../constants/constants';
|
import { NO_DATA_PLACEHOLDER } from '../../../constants/constants';
|
||||||
import { OperationPermission } from '../../../context/PermissionProvider/PermissionProvider.interface';
|
|
||||||
import RetentionPeriod from './RetentionPeriod.component';
|
import RetentionPeriod from './RetentionPeriod.component';
|
||||||
import { RetentionPeriodProps } from './RetentionPeriod.interface';
|
import { RetentionPeriodProps } from './RetentionPeriod.interface';
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ const mockOnUpdate = jest.fn();
|
|||||||
const mockRetentionPeriodProps: RetentionPeriodProps = {
|
const mockRetentionPeriodProps: RetentionPeriodProps = {
|
||||||
retentionPeriod: undefined,
|
retentionPeriod: undefined,
|
||||||
onUpdate: mockOnUpdate,
|
onUpdate: mockOnUpdate,
|
||||||
permissions: { EditAll: true } as OperationPermission,
|
hasPermission: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Test Retention Period Component', () => {
|
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', () => {
|
it('Should not render Retention Period Component if has no permission', () => {
|
||||||
const permissions = { EditAll: false } as OperationPermission;
|
|
||||||
render(
|
render(
|
||||||
<RetentionPeriod
|
<RetentionPeriod {...mockRetentionPeriodProps} hasPermission={false} />
|
||||||
{...mockRetentionPeriodProps}
|
|
||||||
permissions={permissions}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -158,5 +153,8 @@ describe('Test Retention Period Component', () => {
|
|||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
|
||||||
expect(screen.getByText(NO_DATA_PLACEHOLDER)).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 = ({
|
const RetentionPeriod = ({
|
||||||
retentionPeriod,
|
retentionPeriod,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
permissions,
|
hasPermission,
|
||||||
}: RetentionPeriodProps) => {
|
}: RetentionPeriodProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = useForm();
|
const [form] = useForm();
|
||||||
@ -70,7 +70,7 @@ const RetentionPeriod = ({
|
|||||||
value={retentionPeriod ?? NO_DATA_PLACEHOLDER}
|
value={retentionPeriod ?? NO_DATA_PLACEHOLDER}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{permissions?.EditAll && (
|
{hasPermission && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={t('label.edit-entity', {
|
title={t('label.edit-entity', {
|
||||||
entity: t('label.retention-period'),
|
entity: t('label.retention-period'),
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { OperationPermission } from '../../../context/PermissionProvider/PermissionProvider.interface';
|
|
||||||
|
|
||||||
export interface RetentionPeriodProps {
|
export interface RetentionPeriodProps {
|
||||||
retentionPeriod?: string;
|
retentionPeriod?: string;
|
||||||
onUpdate: (retentionPeriod: string) => Promise<void>;
|
onUpdate: (retentionPeriod: string) => Promise<void>;
|
||||||
permissions: OperationPermission;
|
hasPermission: boolean;
|
||||||
}
|
}
|
||||||
|
@ -348,28 +348,29 @@ const SchemaTable = ({
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
) : null}
|
) : null}
|
||||||
{(tablePermissions?.EditAll ||
|
{(tablePermissions?.EditAll ||
|
||||||
tablePermissions?.EditDisplayName) && (
|
tablePermissions?.EditDisplayName) &&
|
||||||
<Tooltip
|
!isReadOnly && (
|
||||||
placement="right"
|
<Tooltip
|
||||||
title={t('label.edit-entity', {
|
placement="right"
|
||||||
entity: t('label.display-name'),
|
title={t('label.edit-entity', {
|
||||||
})}>
|
entity: t('label.display-name'),
|
||||||
<Button
|
})}>
|
||||||
className="cursor-pointer hover-cell-icon w-fit-content"
|
<Button
|
||||||
data-testid="edit-displayName-button"
|
className="cursor-pointer hover-cell-icon w-fit-content"
|
||||||
style={{
|
data-testid="edit-displayName-button"
|
||||||
color: DE_ACTIVE_COLOR,
|
style={{
|
||||||
padding: 0,
|
color: DE_ACTIVE_COLOR,
|
||||||
border: 'none',
|
padding: 0,
|
||||||
background: 'transparent',
|
border: 'none',
|
||||||
}}
|
background: 'transparent',
|
||||||
onClick={() => handleEditDisplayNameClick(record)}>
|
}}
|
||||||
<IconEdit
|
onClick={() => handleEditDisplayNameClick(record)}>
|
||||||
style={{ color: DE_ACTIVE_COLOR, ...ICON_DIMENSION }}
|
<IconEdit
|
||||||
/>
|
style={{ color: DE_ACTIVE_COLOR, ...ICON_DIMENSION }}
|
||||||
</Button>
|
/>
|
||||||
</Tooltip>
|
</Button>
|
||||||
)}
|
</Tooltip>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -250,4 +250,21 @@ describe('Test EntityTable Component', () => {
|
|||||||
expect(columnDisplayName[0].textContent).toBe('Comments');
|
expect(columnDisplayName[0].textContent).toBe('Comments');
|
||||||
expect(columnName[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