Skip to content

Commit

Permalink
fix some entities not visible in Following widget (#17665)
Browse files Browse the repository at this point in the history
* fix some entities not visible in Following widget

* added some extra spacing in quick filter
  • Loading branch information
Ashish8689 authored and harshach committed Sep 2, 2024
1 parent 882ed98 commit 28c7eaf
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
*/
import { test } from '@playwright/test';
import { toLower } from 'lodash';
import { ContainerClass } from '../../support/entity/ContainerClass';
import { DashboardClass } from '../../support/entity/DashboardClass';
import { MlModelClass } from '../../support/entity/MlModelClass';
import { PipelineClass } from '../../support/entity/PipelineClass';
import { SearchIndexClass } from '../../support/entity/SearchIndexClass';
import { TableClass } from '../../support/entity/TableClass';
import { TopicClass } from '../../support/entity/TopicClass';
import { ContainerClass } from '../../../support/entity/ContainerClass';
import { DashboardClass } from '../../../support/entity/DashboardClass';
import { MlModelClass } from '../../../support/entity/MlModelClass';
import { PipelineClass } from '../../../support/entity/PipelineClass';
import { SearchIndexClass } from '../../../support/entity/SearchIndexClass';
import { TableClass } from '../../../support/entity/TableClass';
import { TopicClass } from '../../../support/entity/TopicClass';
import {
createNewPage,
getEntityTypeSearchIndexMapping,
redirectToHomePage,
} from '../../utils/common';
import { checkDataAssetWidget } from '../../utils/entity';
} from '../../../utils/common';
import { checkDataAssetWidget } from '../../../utils/entity';

const entities = [
TableClass,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Page, test as base } from '@playwright/test';
import { ApiEndpointClass } from '../../../support/entity/ApiEndpointClass';
import { ContainerClass } from '../../../support/entity/ContainerClass';
import { DashboardClass } from '../../../support/entity/DashboardClass';
import { DashboardDataModelClass } from '../../../support/entity/DashboardDataModelClass';
import { MlModelClass } from '../../../support/entity/MlModelClass';
import { PipelineClass } from '../../../support/entity/PipelineClass';
import { SearchIndexClass } from '../../../support/entity/SearchIndexClass';
import { StoredProcedureClass } from '../../../support/entity/StoredProcedureClass';
import { TableClass } from '../../../support/entity/TableClass';
import { TopicClass } from '../../../support/entity/TopicClass';
import { UserClass } from '../../../support/user/UserClass';
import { performAdminLogin } from '../../../utils/admin';
import { redirectToHomePage } from '../../../utils/common';
import {
followEntity,
validateFollowedEntityToWidget,
} from '../../../utils/entity';

const entities = [
TableClass,
DashboardClass,
PipelineClass,
TopicClass,
ContainerClass,
MlModelClass,
SearchIndexClass,
ApiEndpointClass,
DashboardDataModelClass,
StoredProcedureClass,
] as const;

const adminUser = new UserClass();

const test = base.extend<{ adminPage: Page }>({
adminPage: async ({ browser }, use) => {
const adminPage = await browser.newPage();
await adminUser.login(adminPage);
await use(adminPage);
await adminPage.close();
},
});

entities.forEach((EntityClass) => {
const entity = new EntityClass();

test.describe(entity.getType(), () => {
test.beforeAll('Setup pre-requests', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);

await adminUser.create(apiContext);
await adminUser.setAdminRole(apiContext);
await entity.create(apiContext);
await afterAction();
});

test.afterAll('Cleanup', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);
await entity.delete(apiContext);
await afterAction();
});

test('Check followed entity present in following widget', async ({
adminPage,
}) => {
await redirectToHomePage(adminPage);

await entity.visitEntityPage(adminPage);

const entityName = entity.entityResponseData?.['displayName'];

await followEntity(adminPage, entity.endpoint);
await validateFollowedEntityToWidget(adminPage, entityName, true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
}, [fields]);

return (
<Space wrap className="explore-quick-filters-container" size={[4, 0]}>
<Space wrap className="explore-quick-filters-container" size={[8, 0]}>
{fields.map((field) => {
const hasNullOption = fieldsWithNullValues.includes(
field.key as EntityFields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
GlobalSettingsMenuCategory,
} from '../../../../constants/GlobalSettings.constants';
import { LandingPageWidgetKeys } from '../../../../enums/CustomizablePage.enum';
import { AssetsType, TabSpecificField } from '../../../../enums/entity.enum';
import { TabSpecificField } from '../../../../enums/entity.enum';
import { Document } from '../../../../generated/entity/docStore/document';
import { EntityReference } from '../../../../generated/entity/type';
import { useApplicationStore } from '../../../../hooks/useApplicationStore';
Expand Down Expand Up @@ -150,13 +150,9 @@ function CustomizeMyData({
});

if (userData) {
const includeData = Object.values(AssetsType);
const follows: EntityReference[] = userData.follows ?? [];
const includedFollowsData = follows.filter((data) =>
includeData.includes(data.type as AssetsType)
);
setFollowedDataCount(includedFollowsData.length);
setFollowedData(includedFollowsData.slice(0, 8));
setFollowedDataCount(follows.length);
setFollowedData(follows.slice(0, 8));
}
} catch (err) {
setFollowedData([]);
Expand Down
10 changes: 0 additions & 10 deletions openmetadata-ui/src/main/resources/ui/src/enums/entity.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@ export enum EntityType {
API_ENDPOINT = 'apiEndpoint',
}

export enum AssetsType {
TABLE = 'table',
TOPIC = 'topic',
DASHBOARD = 'dashboard',
PIPELINE = 'pipeline',
MLMODEL = 'mlmodel',
DASHBOARD_DATA_MODEL = 'dashboardDataModel',
STORED_PROCEDURE = 'storedProcedure',
}

export enum EntityLineageDirection {
TOP_BOTTOM = 'TB',
LEFT_RIGHT = 'LR',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ import Loader from '../../components/common/Loader/Loader';
import WelcomeScreen from '../../components/MyData/WelcomeScreen/WelcomeScreen.component';
import PageLayoutV1 from '../../components/PageLayoutV1/PageLayoutV1';
import { LOGGED_IN_USER_STORAGE_KEY } from '../../constants/constants';
import {
AssetsType,
EntityType,
TabSpecificField,
} from '../../enums/entity.enum';
import { EntityType, TabSpecificField } from '../../enums/entity.enum';
import { Thread } from '../../generated/entity/feed/thread';
import { PageType } from '../../generated/system/ui/page';
import { EntityReference } from '../../generated/type/entityReference';
Expand Down Expand Up @@ -124,13 +120,9 @@ const MyDataPage = () => {
});

if (userData) {
const includeData = Object.values(AssetsType);
const follows: EntityReference[] = userData.follows ?? [];
const includedFollowsData = follows.filter((data) =>
includeData.includes(data.type as AssetsType)
);
setFollowedDataCount(includedFollowsData.length);
setFollowedData(includedFollowsData.slice(0, 8));
setFollowedDataCount(follows.length);
setFollowedData(follows.slice(0, 8));
}
} catch (err) {
setFollowedData([]);
Expand Down
13 changes: 1 addition & 12 deletions openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ import {
} from '../constants/GlobalSettings.constants';
import { TAG_START_WITH } from '../constants/Tag.constants';
import { ResourceEntity } from '../context/PermissionProvider/PermissionProvider.interface';
import {
AssetsType,
EntityTabs,
EntityType,
FqnPart,
} from '../enums/entity.enum';
import { EntityTabs, EntityType, FqnPart } from '../enums/entity.enum';
import { ExplorePageTabs } from '../enums/Explore.enum';
import { SearchIndex } from '../enums/search.enum';
import { ServiceCategory, ServiceCategoryPlural } from '../enums/service.enum';
Expand Down Expand Up @@ -1220,12 +1215,6 @@ export const getTitleCase = (text?: string) => {
return text ? startCase(text) : '';
};

export const filterEntityAssets = (data: EntityReference[]) => {
const includedEntity = Object.values(AssetsType);

return data.filter((d) => includedEntity.includes(d.type as AssetsType));
};

export const getResourceEntityFromEntityType = (entityType: string) => {
switch (entityType) {
case EntityType.TABLE:
Expand Down

0 comments on commit 28c7eaf

Please sign in to comment.