mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-23 17:30:35 +00:00
MINOR: fix the header in deleted team feed (#16317)
* fix the header in deleted team feed * added unit test
This commit is contained in:
parent
42defd2433
commit
cfe86267ee
@ -11,7 +11,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EntityType } from '../enums/entity.enum';
|
|
||||||
import { CardStyle } from '../generated/entity/feed/thread';
|
import { CardStyle } from '../generated/entity/feed/thread';
|
||||||
|
|
||||||
export const EntityRegExPattern = /<#E::([^<>]+?)::([^<>]+?)(?:::([^<>]+?))?>/;
|
export const EntityRegExPattern = /<#E::([^<>]+?)::([^<>]+?)(?:::([^<>]+?))?>/;
|
||||||
@ -99,10 +98,3 @@ export const ASSET_CARD_STYLES = [
|
|||||||
CardStyle.EntitySoftDeleted,
|
CardStyle.EntitySoftDeleted,
|
||||||
CardStyle.EntityDeleted,
|
CardStyle.EntityDeleted,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const NON_DATA_ASSET_ENTITIES = [
|
|
||||||
EntityType.TEAM,
|
|
||||||
EntityType.BOT,
|
|
||||||
EntityType.APPLICATION,
|
|
||||||
EntityType.EVENT_SUBSCRIPTION,
|
|
||||||
];
|
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
* 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 { FQN_SEPARATOR_CHAR } from '../constants/char.constants';
|
import { FQN_SEPARATOR_CHAR } from '../constants/char.constants';
|
||||||
import { EntityType, FqnPart } from '../enums/entity.enum';
|
import { EntityType, FqnPart } from '../enums/entity.enum';
|
||||||
|
import { CardStyle, FieldOperation } from '../generated/entity/feed/thread';
|
||||||
import { getPartialNameFromTableFQN } from './CommonUtils';
|
import { getPartialNameFromTableFQN } from './CommonUtils';
|
||||||
import {
|
import {
|
||||||
entityDisplayName,
|
entityDisplayName,
|
||||||
@ -20,6 +20,7 @@ import {
|
|||||||
getEntityField,
|
getEntityField,
|
||||||
getEntityFQN,
|
getEntityFQN,
|
||||||
getEntityType,
|
getEntityType,
|
||||||
|
getFeedHeaderTextFromCardStyle,
|
||||||
suggestions,
|
suggestions,
|
||||||
} from './FeedUtils';
|
} from './FeedUtils';
|
||||||
|
|
||||||
@ -162,3 +163,114 @@ describe('Feed Utils', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getFeedHeaderTextFromCardStyle', () => {
|
||||||
|
it('should return element for created application', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Added,
|
||||||
|
CardStyle.EntityCreated,
|
||||||
|
undefined,
|
||||||
|
EntityType.APPLICATION
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('label.installed-lowercase');
|
||||||
|
expect(stringResult).toContain('label.app-lowercase');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element for deleted application', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Deleted,
|
||||||
|
CardStyle.EntityDeleted,
|
||||||
|
undefined,
|
||||||
|
EntityType.APPLICATION
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('label.uninstalled-lowercase');
|
||||||
|
expect(stringResult).toContain('label.app-lowercase');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element for created team', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Added,
|
||||||
|
CardStyle.EntityCreated,
|
||||||
|
undefined,
|
||||||
|
EntityType.TEAM
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('label.added-lowercase');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element for soft deleted team', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Deleted,
|
||||||
|
CardStyle.EntitySoftDeleted,
|
||||||
|
undefined,
|
||||||
|
EntityType.TEAM
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('label.soft-deleted-lowercase');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element for deleted team', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Deleted,
|
||||||
|
CardStyle.EntityDeleted,
|
||||||
|
undefined,
|
||||||
|
EntityType.TEAM
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('label.deleted-lowercase');
|
||||||
|
expect(stringResult).toContain('text-danger');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element for created CustomProperties', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Added,
|
||||||
|
CardStyle.CustomProperties,
|
||||||
|
undefined,
|
||||||
|
EntityType.TABLE
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('message.feed-custom-property-header');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element element for created testCaseResult', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Added,
|
||||||
|
CardStyle.TestCaseResult,
|
||||||
|
undefined,
|
||||||
|
EntityType.TEST_CASE
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('message.feed-test-case-header');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return element for updated description', () => {
|
||||||
|
const result = getFeedHeaderTextFromCardStyle(
|
||||||
|
FieldOperation.Updated,
|
||||||
|
CardStyle.Description,
|
||||||
|
undefined,
|
||||||
|
EntityType.TABLE
|
||||||
|
);
|
||||||
|
|
||||||
|
const stringResult = JSON.stringify(result);
|
||||||
|
|
||||||
|
expect(stringResult).toContain('message.feed-field-action-entity-header');
|
||||||
|
expect(stringResult).toContain('label.description');
|
||||||
|
expect(stringResult).toContain('label.updated-lowercase');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -36,7 +36,6 @@ import {
|
|||||||
hashtagRegEx,
|
hashtagRegEx,
|
||||||
linkRegEx,
|
linkRegEx,
|
||||||
mentionRegEx,
|
mentionRegEx,
|
||||||
NON_DATA_ASSET_ENTITIES,
|
|
||||||
teamsLinkRegEx,
|
teamsLinkRegEx,
|
||||||
} from '../constants/Feeds.constants';
|
} from '../constants/Feeds.constants';
|
||||||
import { EntityType, FqnPart, TabSpecificField } from '../enums/entity.enum';
|
import { EntityType, FqnPart, TabSpecificField } from '../enums/entity.enum';
|
||||||
@ -807,27 +806,12 @@ export const getFeedHeaderTextFromCardStyle = (
|
|||||||
case CardStyle.EntityCreated:
|
case CardStyle.EntityCreated:
|
||||||
case CardStyle.EntityDeleted:
|
case CardStyle.EntityDeleted:
|
||||||
case CardStyle.EntitySoftDeleted:
|
case CardStyle.EntitySoftDeleted:
|
||||||
if (NON_DATA_ASSET_ENTITIES.includes(entityType as EntityType)) {
|
if (entityType === EntityType.APPLICATION) {
|
||||||
return entityType === EntityType.APPLICATION ? (
|
return (
|
||||||
<Typography.Text>
|
<Typography.Text>
|
||||||
{getActionLabelFromCardStyle(cardStyle, true)}{' '}
|
{getActionLabelFromCardStyle(cardStyle, true)}{' '}
|
||||||
{i18next.t('label.app-lowercase')}
|
{i18next.t('label.app-lowercase')}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
) : (
|
|
||||||
<Transi18next
|
|
||||||
i18nKey="message.feed-entity-action-header"
|
|
||||||
renderElement={<Typography.Text className="font-bold" />}
|
|
||||||
values={{
|
|
||||||
entity: i18next.t(
|
|
||||||
`label.${
|
|
||||||
entityType === EntityType.EVENT_SUBSCRIPTION
|
|
||||||
? 'alert'
|
|
||||||
: entityType
|
|
||||||
}-lowercase`
|
|
||||||
),
|
|
||||||
action: getActionLabelFromCardStyle(cardStyle),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user