mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 01:15:08 +00:00
* added sort option in custom property table * add comparision for displayName also, instead of just name * added columnSorter utils fn * fix type issue * added unit test for columnSorter method
This commit is contained in:
parent
5e290d6d14
commit
ba32ef1817
@ -23,7 +23,7 @@ import { CUSTOM_PROPERTIES_DOCS } from '../../constants/docs.constants';
|
|||||||
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
|
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
|
||||||
import { ERROR_PLACEHOLDER_TYPE, OPERATION } from '../../enums/common.enum';
|
import { ERROR_PLACEHOLDER_TYPE, OPERATION } from '../../enums/common.enum';
|
||||||
import { CustomProperty } from '../../generated/entity/type';
|
import { CustomProperty } from '../../generated/entity/type';
|
||||||
import { getEntityName } from '../../utils/EntityUtils';
|
import { columnSorter, getEntityName } from '../../utils/EntityUtils';
|
||||||
import RichTextEditorPreviewer from '../common/RichTextEditor/RichTextEditorPreviewer';
|
import RichTextEditorPreviewer from '../common/RichTextEditor/RichTextEditorPreviewer';
|
||||||
import ConfirmationModal from '../Modals/ConfirmationModal/ConfirmationModal';
|
import ConfirmationModal from '../Modals/ConfirmationModal/ConfirmationModal';
|
||||||
import { ModalWithMarkdownEditor } from '../Modals/ModalWithMarkdownEditor/ModalWithMarkdownEditor';
|
import { ModalWithMarkdownEditor } from '../Modals/ModalWithMarkdownEditor/ModalWithMarkdownEditor';
|
||||||
@ -89,6 +89,7 @@ export const CustomPropertyTable: FC<CustomPropertyTableProp> = ({
|
|||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
render: (_, record) => getEntityName(record),
|
render: (_, record) => getEntityName(record),
|
||||||
|
sorter: columnSorter,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('label.type'),
|
title: t('label.type'),
|
||||||
|
@ -28,7 +28,7 @@ import {
|
|||||||
} from '../../../generated/entity/type';
|
} from '../../../generated/entity/type';
|
||||||
import { getTypeByFQN } from '../../../rest/metadataTypeAPI';
|
import { getTypeByFQN } from '../../../rest/metadataTypeAPI';
|
||||||
import { getEntityExtentionDetailsFromEntityType } from '../../../utils/CustomProperties/CustomProperty.utils';
|
import { getEntityExtentionDetailsFromEntityType } from '../../../utils/CustomProperties/CustomProperty.utils';
|
||||||
import { getEntityName } from '../../../utils/EntityUtils';
|
import { columnSorter, getEntityName } from '../../../utils/EntityUtils';
|
||||||
import {
|
import {
|
||||||
getChangedEntityNewValue,
|
getChangedEntityNewValue,
|
||||||
getDiffByFieldName,
|
getDiffByFieldName,
|
||||||
@ -172,6 +172,7 @@ export const CustomPropertyTable = <T extends ExtentionEntitiesKeys>({
|
|||||||
key: 'name',
|
key: 'name',
|
||||||
width: 200,
|
width: 200,
|
||||||
render: (_, record) => getEntityName(record),
|
render: (_, record) => getEntityName(record),
|
||||||
|
sorter: columnSorter,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('label.value'),
|
title: t('label.value'),
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { highlightEntityNameAndDescription } from './EntityUtils';
|
import { columnSorter, highlightEntityNameAndDescription } from './EntityUtils';
|
||||||
import {
|
import {
|
||||||
entityWithoutNameAndDescHighlight,
|
entityWithoutNameAndDescHighlight,
|
||||||
highlightedEntityDescription,
|
highlightedEntityDescription,
|
||||||
@ -19,13 +19,29 @@ import {
|
|||||||
} from './mocks/EntityUtils.mock';
|
} from './mocks/EntityUtils.mock';
|
||||||
|
|
||||||
describe('EntityUtils unit tests', () => {
|
describe('EntityUtils unit tests', () => {
|
||||||
it('highlightEntityNameAndDescription method should return the entity with highlighted name and description', () => {
|
describe('highlightEntityNameAndDescription method', () => {
|
||||||
const highlightedEntity = highlightEntityNameAndDescription(
|
it('highlightEntityNameAndDescription method should return the entity with highlighted name and description', () => {
|
||||||
entityWithoutNameAndDescHighlight,
|
const highlightedEntity = highlightEntityNameAndDescription(
|
||||||
mockHighlights
|
entityWithoutNameAndDescHighlight,
|
||||||
);
|
mockHighlights
|
||||||
|
);
|
||||||
|
|
||||||
expect(highlightedEntity.displayName).toBe(highlightedEntityDisplayName);
|
expect(highlightedEntity.displayName).toBe(highlightedEntityDisplayName);
|
||||||
expect(highlightedEntity.description).toBe(highlightedEntityDescription);
|
expect(highlightedEntity.description).toBe(highlightedEntityDescription);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('columnSorter method', () => {
|
||||||
|
it('columnSorter method should return 1 if the 2nd column should be come before 1st column', () => {
|
||||||
|
const result = columnSorter({ name: 'name2' }, { name: 'name1' });
|
||||||
|
|
||||||
|
expect(result).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('columnSorter method should return -1 if the 1st column should be come before 2nd column', () => {
|
||||||
|
const result = columnSorter({ name: 'name1' }, { name: 'name2' });
|
||||||
|
|
||||||
|
expect(result).toBe(-1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1790,3 +1790,13 @@ export const highlightEntityNameAndDescription = (
|
|||||||
description: entityDescription,
|
description: entityDescription,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const columnSorter = (
|
||||||
|
col1: { name: string; displayName?: string },
|
||||||
|
col2: { name: string; displayName?: string }
|
||||||
|
) => {
|
||||||
|
const name1 = getEntityName(col1);
|
||||||
|
const name2 = getEntityName(col2);
|
||||||
|
|
||||||
|
return name1.localeCompare(name2);
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user