Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Business Attributes: UI Show|Hide Feature Flag Implementation | Modified Test Cases #31

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public CompletableFuture<AppConfig> get(final DataFetchingEnvironment environmen
final FeatureFlagsConfig featureFlagsConfig =
FeatureFlagsConfig.builder()
.setShowSearchFiltersV2(_featureFlags.isShowSearchFiltersV2())
.setBusinessAttributeEntityEnabled(_featureFlags.isBusinessAttributeEntityEnabled())
.setReadOnlyModeEnabled(_featureFlags.isReadOnlyModeEnabled())
.setShowBrowseV2(_featureFlags.isShowBrowseV2())
.setShowAcrylInfo(_featureFlags.isShowAcrylInfo())
Expand Down
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/app.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ type FeatureFlagsConfig {
If this is off, Domains appear "flat" again.
"""
nestedDomainsEnabled: Boolean!

"""
Whether business attribute entity should be shown
"""
businessAttributeEntityEnabled: Boolean!
}

"""
Expand Down
18 changes: 15 additions & 3 deletions datahub-web-react/src/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,10 @@ export const businessAttribute = {
terms: [
{
term: {
urn: 'urn:li:glossaryTerm:1'
urn: 'urn:li:glossaryTerm:1',
type: EntityType.GlossaryTerm,
hierarchicalName: 'SampleHierarchicalName',
name: 'SampleName',
},
associatedUrn: 'urn:li:businessAttribute:ba1'
}
Expand All @@ -1475,15 +1478,19 @@ export const businessAttribute = {
{
tag: {
urn: 'urn:li:tag:abc-sample-tag',
__typename: 'Tag'
__typename: 'Tag',
type: EntityType.Tag,
name: 'abc-sample-tag',
},
__typename: 'TagAssociation',
associatedUrn: 'urn:li:businessAttribute:ba1'
},
{
tag: {
urn: 'urn:li:tag:TestTag',
__typename: 'Tag'
__typename: 'Tag',
type: EntityType.Tag,
name: 'TestTag',
},
__typename: 'TagAssociation',
associatedUrn: 'urn:li:businessAttribute:ba1'
Expand All @@ -1494,16 +1501,19 @@ export const businessAttribute = {
{
key: 'prop2',
value: 'val2',
associatedUrn: 'urn:li:businessAttribute:ba1',
__typename: 'CustomPropertiesEntry'
},
{
key: 'prop1',
value: 'val1',
associatedUrn: 'urn:li:businessAttribute:ba1',
__typename: 'CustomPropertiesEntry'
},
{
key: 'prop3',
value: 'val3',
associatedUrn: 'urn:li:businessAttribute:ba1',
__typename: 'CustomPropertiesEntry'
}
]
Expand Down Expand Up @@ -3615,6 +3625,8 @@ export const mocks = [
manageGlobalViews: true,
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
createBusinessAttributes: true,
manageBusinessAttributes: true,
},
},
},
Expand Down
15 changes: 13 additions & 2 deletions datahub-web-react/src/app/SearchRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ManageIngestionPage } from './ingest/ManageIngestionPage';
import GlossaryRoutes from './glossary/GlossaryRoutes';
import { SettingsPage } from './settings/SettingsPage';
import DomainRoutes from './domain/DomainRoutes';
import { useIsNestedDomainsEnabled } from './useAppConfig';
import { useBusinessAttributesFlag, useIsAppConfigContextLoaded, useIsNestedDomainsEnabled } from './useAppConfig';
import { ManageDomainsPage } from './domain/ManageDomainsPage';
import { BusinessAttributes } from './businessAttribute/BusinessAttributes';
/**
Expand All @@ -25,6 +25,9 @@ export const SearchRoutes = (): JSX.Element => {
? entityRegistry.getEntitiesForSearchRoutes()
: entityRegistry.getNonGlossaryEntities();

const businessAttributesFlag = useBusinessAttributesFlag();
const appConfigContextLoaded = useIsAppConfigContextLoaded();

return (
<SearchablePage>
<Switch>
Expand All @@ -50,7 +53,15 @@ export const SearchRoutes = (): JSX.Element => {
<Route path={PageRoutes.INGESTION} render={() => <ManageIngestionPage />} />
<Route path={PageRoutes.SETTINGS} render={() => <SettingsPage />} />
<Route path={`${PageRoutes.GLOSSARY}*`} render={() => <GlossaryRoutes />} />
<Route path={PageRoutes.BUSINESS_ATTRIBUTE} render={() => <BusinessAttributes />} />
<Route path={PageRoutes.BUSINESS_ATTRIBUTE} render={() => {
if (!appConfigContextLoaded) {
return null;
}
if (businessAttributesFlag) {
return <BusinessAttributes />;
}
return <NoPageFound />;
}}/>
<Route component={NoPageFound} />
</Switch>
</SearchablePage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const BusinessAttributes = () => {

const totalBusinessAttributes = businessAttributeData?.listBusinessAttributes?.total || 0;
const businessAttributes = useMemo(
() => businessAttributeData?.listBusinessAttributes?.businessAttributes || [],
() => (businessAttributeData?.listBusinessAttributes?.businessAttributes || []) as BusinessAttribute[],
[businessAttributeData],
);

Expand All @@ -136,7 +136,7 @@ export const BusinessAttributes = () => {
businessAttributeRefetch?.();
}, 2000);
};
const tableData = businessAttributes;
const tableData = businessAttributes || [];
const tableColumns = [
{
width: '20%',
Expand All @@ -151,6 +151,7 @@ export const BusinessAttributes = () => {
title: 'Description',
dataIndex: ['properties', 'description'],
key: 'description',
width: '20%',
// render: (description: string) => description || '',
render: descriptionRender,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ describe('handleAccessRoles', () => {
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
manageTokens: true,
createBusinessAttributes: true,
manageBusinessAttributes: true,
__typename: 'PlatformPrivileges',
},
__typename: 'AuthenticatedUser',
Expand Down Expand Up @@ -159,6 +161,8 @@ describe('handleAccessRoles', () => {
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
manageTokens: true,
createBusinessAttributes: true,
manageBusinessAttributes: true,
__typename: 'PlatformPrivileges',
},
__typename: 'AuthenticatedUser',
Expand Down Expand Up @@ -252,6 +256,8 @@ describe('handleAccessRoles', () => {
manageOwnershipTypes: true,
manageGlobalAnnouncements: true,
manageTokens: true,
createBusinessAttributes: true,
manageBusinessAttributes: true,
__typename: 'PlatformPrivileges',
},
__typename: 'AuthenticatedUser',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import translateFieldPath from '../../../../dataset/profile/schema/utils/transla
import PropertiesColumn from './components/PropertiesColumn';
import SchemaFieldDrawer from './components/SchemaFieldDrawer/SchemaFieldDrawer';
import useBusinessAttributeRenderer from './utils/useBusinessAttributeRenderer';
import { useBusinessAttributesFlag } from '../../../../../useAppConfig';

const TableContainer = styled.div`
overflow: inherit;
Expand Down Expand Up @@ -90,6 +91,7 @@ export default function SchemaTable({
hasProperties,
inputFields,
}: Props): JSX.Element {
const businessAttributesFlag = useBusinessAttributesFlag();
const hasUsageStats = useMemo(() => (usageStats?.aggregations?.fields?.length || 0) > 0, [usageStats]);
const [tableHeight, setTableHeight] = useState(0);
const [selectedFkFieldPath, setSelectedFkFieldPath] = useState<null | {
Expand Down Expand Up @@ -217,9 +219,12 @@ export default function SchemaTable({
descriptionColumn,
tagColumn,
termColumn,
businessAttributeColumn,
];

if (businessAttributesFlag) {
allColumns = [...allColumns, businessAttributeColumn];
}

if (hasProperties) {
allColumns = [...allColumns, propertiesColumn];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SchemaField } from '../../../../../../../../types.generated';
import useBusinessAttributeRenderer from '../../utils/useBusinessAttributeRenderer';
import { SectionHeader, StyledDivider } from './components';
import SchemaEditableContext from '../../../../../../../shared/SchemaEditableContext';
import { useBusinessAttributesFlag } from '../../../../../../../useAppConfig';

interface Props {
expandedField: SchemaField;
Expand All @@ -15,7 +16,9 @@ export default function FieldAttribute({ expandedField }: Props) {
isSchemaEditable,
);

return (
const businessAttributesFlag = useBusinessAttributesFlag();

return businessAttributesFlag ? (
<>
<SectionHeader>Business Attribute</SectionHeader>
{/* pass in globalTags since this is a shared component, tags will not be shown or used */}
Expand All @@ -24,5 +27,5 @@ export default function FieldAttribute({ expandedField }: Props) {
</div>
<StyledDivider />
</>
);
) : null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function SchemaFieldDrawer({
<FieldTags expandedField={expandedField} editableSchemaMetadata={editableSchemaMetadata} />
<FieldTerms expandedField={expandedField} editableSchemaMetadata={editableSchemaMetadata} />
<FieldProperties expandedField={expandedField} />
<FieldAttribute expandedField={expandedField} editableSchemaMetadata={editableSchemaMetadata} />
<FieldAttribute expandedField={expandedField} />
</MetadataSections>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EntityType, SchemaField } from '../../../../../../../types.generated';
import { useRefetch } from '../../../../EntityContext';
import { useSchemaRefetch } from '../SchemaContext';
import BusinessAttributeGroup from '../../../../../../shared/businessAttribute/BusinessAttributeGroup';
import { useBusinessAttributesFlag } from '../../../../../../useAppConfig';

export default function useBusinessAttributeRenderer(
filterText: string,
Expand All @@ -11,15 +12,17 @@ export default function useBusinessAttributeRenderer(
const refetch = useRefetch();
const schemaRefetch = useSchemaRefetch();

const businessAttributesFlag = useBusinessAttributesFlag();

const refresh: any = () => {
refetch?.();
schemaRefetch?.();
};

return (businessAttribute: string, record: SchemaField): JSX.Element => {
return (
return (businessAttribute: string, record: SchemaField): JSX.Element | null => {
return businessAttributesFlag ? (
<BusinessAttributeGroup
businessAttribute={record?.schemaFieldEntity?.businessAttributes?.businessAttribute|| undefined}
businessAttribute={record?.schemaFieldEntity?.businessAttributes?.businessAttribute || undefined}
canRemove={canEdit}
buttonProps={{ size: 'small' }}
canAddAttribute={canEdit}
Expand All @@ -29,6 +32,6 @@ export default function useBusinessAttributeRenderer(
highlightText={filterText}
refetch={refresh}
/>
);
) : null;
};
}
24 changes: 21 additions & 3 deletions datahub-web-react/src/app/home/HomePageRecommendations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
HOME_PAGE_PLATFORMS_ID,
} from '../onboarding/config/HomePageOnboardingConfig';
import { useToggleEducationStepIdsAllowList } from '../onboarding/useToggleEducationStepIdsAllowList';
import { useBusinessAttributesFlag } from '../useAppConfig';

const PLATFORMS_MODULE_ID = 'Platforms';
const MOST_POPULAR_MODULE_ID = 'HighUsageEntities';
Expand Down Expand Up @@ -104,6 +105,8 @@ export const HomePageRecommendations = ({ user }: Props) => {
const browseEntityList = entityRegistry.getBrowseEntityTypes();
const userUrn = user?.urn;

const businessAttributesFlag = useBusinessAttributesFlag();

const showSimplifiedHomepage = user?.settings?.appearance?.showSimplifiedHomepage;

const { data: entityCountData } = useGetEntityCountsQuery({
Expand Down Expand Up @@ -182,7 +185,22 @@ export const HomePageRecommendations = ({ user }: Props) => {
{orderedEntityCounts.map(
(entityCount) =>
entityCount &&
entityCount.count !== 0 && (
entityCount.count !== 0 &&
entityCount.entityType !== EntityType.BusinessAttribute &&
(
<BrowseEntityCard
key={entityCount.entityType}
entityType={entityCount.entityType}
count={entityCount.count}
/>
),
)}
{orderedEntityCounts.map(
(entityCount) =>
entityCount &&
entityCount.count !== 0 &&
entityCount.entityType === EntityType.BusinessAttribute &&
businessAttributesFlag && (
<BrowseEntityCard
key={entityCount.entityType}
entityType={entityCount.entityType}
Expand All @@ -194,11 +212,11 @@ export const HomePageRecommendations = ({ user }: Props) => {
(entityCount) => entityCount.entityType === EntityType.GlossaryTerm,
) && <BrowseEntityCard entityType={EntityType.GlossaryTerm} count={0} />}
</BrowseCardContainer>
) : (
) : (
<NoMetadataContainer>
<NoMetadataEmpty description="No Metadata Found 😢" />
</NoMetadataContainer>
)}
)}
</RecommendationContainer>
)}
{recommendationModules &&
Expand Down
8 changes: 5 additions & 3 deletions datahub-web-react/src/app/shared/admin/HeaderLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@ant-design/icons';
import { Link } from 'react-router-dom';
import { Button, Dropdown, Menu, Tooltip } from 'antd';
import { useAppConfig } from '../../useAppConfig';
import { useAppConfig, useBusinessAttributesFlag } from '../../useAppConfig';
import { ANTD_GRAY } from '../../entity/shared/constants';
import { HOME_PAGE_INGESTION_ID } from '../../onboarding/config/HomePageOnboardingConfig';
import { useToggleEducationStepIdsAllowList } from '../../onboarding/useToggleEducationStepIdsAllowList';
Expand Down Expand Up @@ -67,6 +67,8 @@ export function HeaderLinks(props: Props) {
const me = useUserContext();
const { config } = useAppConfig();

const businessAttributesFlag = useBusinessAttributesFlag();

const isAnalyticsEnabled = config?.analyticsConfig.enabled;
const isIngestionEnabled = config?.managedIngestionConfig.enabled;

Expand Down Expand Up @@ -120,7 +122,7 @@ export function HeaderLinks(props: Props) {
<NavTitleDescription>Manage related groups of data assets</NavTitleDescription>
</Link>
</MenuItem>
<MenuItem key="2">
{businessAttributesFlag && ( <MenuItem key="2">
<Link to="/business-attribute">
<NavTitleContainer>
<GlobalOutlined
Expand All @@ -133,7 +135,7 @@ export function HeaderLinks(props: Props) {
</NavTitleContainer>
<NavTitleDescription>Universal field for data consistency</NavTitleDescription>
</Link>
</MenuItem>
</MenuItem>)}
</Menu>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default function EditBusinessAttributeModal({
variables: {
input: {
businessAttributeUrn: urn,
resourceUrn: resources[0],
resourceUrn: resources,
},
},
})
Expand Down Expand Up @@ -229,11 +229,11 @@ export default function EditBusinessAttributeModal({
variables: {
input: {
businessAttributeUrn: urn,
resourceUrn: {
resourceUrn: [{
resourceUrn: resources[0].resourceUrn,
subResource: resources[0].subResource,
subResourceType: resources[0].subResourceType,
},
}],
},
},
})
Expand Down
Loading
Loading