minor domain fixes (#17407)

This commit is contained in:
Karan Hotchandani 2024-08-12 20:41:19 +05:30 committed by GitHub
parent 330b97a669
commit a654238634
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 113 additions and 41 deletions

View File

@ -69,7 +69,7 @@ export const AdvanceSearchProvider = ({
([, tabInfo]) => tabInfo.path === tab
);
if (isNil(tabInfo)) {
return SearchIndex.TABLE;
return SearchIndex.DATA_ASSET;
}
return tabInfo[0] as SearchIndex;

View File

@ -63,6 +63,7 @@ import {
} from '../../utils/BrowserNotificationUtils';
import { refreshPage } from '../../utils/CommonUtils';
import entityUtilClassBase from '../../utils/EntityUtilClassBase';
import { getEntityName } from '../../utils/EntityUtils';
import {
getEntityFQN,
getEntityType,
@ -472,6 +473,8 @@ const NavBar = ({
menu={{
items: domainOptions,
onClick: handleDomainChange,
className: 'domain-dropdown-menu',
defaultSelectedKeys: [activeDomain],
}}
placement="bottomRight"
trigger={['click']}>
@ -486,7 +489,9 @@ const NavBar = ({
</Col>
<Col className="flex-center">
<Typography.Text>
{activeDomainEntityRef?.displayName ?? activeDomain}
{activeDomainEntityRef
? getEntityName(activeDomainEntityRef)
: activeDomain}
</Typography.Text>
</Col>
<Col className="flex-center">

View File

@ -29,3 +29,8 @@
}
}
}
.domain-dropdown-menu {
max-height: 400px;
overflow-y: auto;
}

View File

@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Typography } from 'antd';
import { Tooltip, Typography } from 'antd';
import { AxiosError } from 'axios';
import classNames from 'classnames';
import { compare } from 'fast-json-patch';
@ -18,6 +18,7 @@ import { get, isEmpty, isUndefined } from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ReactComponent as DomainIcon } from '../../../assets/svg/ic-domain.svg';
import { ReactComponent as InheritIcon } from '../../../assets/svg/ic-inherit.svg';
import { DE_ACTIVE_COLOR } from '../../../constants/constants';
import { EntityReference } from '../../../generated/entity/type';
import {
@ -104,17 +105,37 @@ export const DomainLabel = ({
Array.isArray(activeDomain) &&
activeDomain.length > 0
) {
return activeDomain.map((domain, index) => (
<React.Fragment key={domain.id}>
{renderDomainLink(
domain,
domainDisplayName,
showDomainHeading,
textClassName
)}
{index < activeDomain.length - 1 && ', '}
</React.Fragment>
));
return activeDomain.map((domain) => {
const inheritedIcon = domain?.inherited ? (
<Tooltip
title={t('label.inherited-entity', {
entity: t('label.domain'),
})}>
<InheritIcon className="inherit-icon cursor-pointer" width={14} />
</Tooltip>
) : null;
return (
<div className="d-flex items-center gap-1" key={domain.id}>
<Typography.Text className="self-center text-xs whitespace-nowrap">
<DomainIcon
className="d-flex"
color={DE_ACTIVE_COLOR}
height={16}
name="folder"
width={16}
/>
</Typography.Text>
{renderDomainLink(
domain,
domainDisplayName,
showDomainHeading,
textClassName
)}
{inheritedIcon && <div className="d-flex">{inheritedIcon}</div>}
</div>
);
});
} else {
return (
<Typography.Text
@ -154,14 +175,7 @@ export const DomainLabel = ({
{selectableList}
</div>
<div className="d-flex items-center gap-1">
<DomainIcon
className="d-flex"
color={DE_ACTIVE_COLOR}
height={16}
name="folder"
width={16}
/>
<div className="d-flex items-center gap-1 flex-wrap">
{domainLink}
</div>
</>
@ -170,19 +184,9 @@ export const DomainLabel = ({
return (
<div
className="d-flex items-center gap-1"
className="d-flex items-center gap-1 flex-wrap"
data-testid="header-domain-container">
<Typography.Text className="self-center text-xs whitespace-nowrap">
<DomainIcon
className="d-flex"
color={DE_ACTIVE_COLOR}
height={16}
name="folder"
width={16}
/>
</Typography.Text>
{domainLink}
{selectableList}
</div>
);

View File

@ -60,14 +60,19 @@ export const useDomainStore = create<DomainStore>()(
selectDefault &&
!isAdmin &&
userDomainsObj.length > 0 &&
!get().activeDomain
get().activeDomain === DEFAULT_DOMAIN_VALUE
) {
set({ activeDomain: userDomainsObj[0].fullyQualifiedName });
get().updateActiveDomain(userDomainsObj[0].fullyQualifiedName ?? '');
}
},
updateActiveDomain: (activeDomainKey: string) => {
const currentUser = useApplicationStore.getState().currentUser;
const { isAdmin = false, domains = [] } = currentUser ?? {};
const userDomainsObj = isAdmin ? [] : domains;
const allDomains = isAdmin ? get().domains : userDomainsObj;
const activeDomainEntityRef = initializeDomainEntityRef(
get().domains,
allDomains as EntityReference[],
activeDomainKey
);
set({
@ -93,8 +98,13 @@ export const useDomainStore = create<DomainStore>()(
{
name: DOMAIN_STORAGE_KEY,
partialize: (state) => {
const currentUser = useApplicationStore.getState().currentUser;
const { isAdmin = false, domains = [] } = currentUser ?? {};
const userDomainsObj = isAdmin ? [] : domains;
const allDomains = isAdmin ? state.domains : userDomainsObj;
const activeDomainEntityRef = initializeDomainEntityRef(
state.domains,
allDomains as EntityReference[],
state.activeDomain
);

View File

@ -46,6 +46,7 @@ import {
INITIAL_PAGING_VALUE,
PAGE_SIZE,
pagingObject,
ROUTES,
} from '../../constants/constants';
import {
OPEN_METADATA,
@ -53,6 +54,7 @@ import {
} from '../../constants/Services.constant';
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
import { OperationPermission } from '../../context/PermissionProvider/PermissionProvider.interface';
import { ClientErrors } from '../../enums/Axios.enum';
import { ERROR_PLACEHOLDER_TYPE } from '../../enums/common.enum';
import {
EntityTabs,
@ -582,6 +584,9 @@ const ServiceDetailsPage: FunctionComponent = () => {
setShowDeleted(response.deleted ?? false);
} catch (error) {
// Error
if ((error as AxiosError)?.response?.status === ClientErrors.FORBIDDEN) {
history.replace(ROUTES.FORBIDDEN);
}
} finally {
setIsLoading(false);
}

View File

@ -109,6 +109,19 @@ class AdvancedSearchClassBase {
useAsyncSearch: true,
},
},
tableType: {
label: t('label.table-type'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.TABLE,
entityField: EntityFields.TABLE_TYPE,
}),
useAsyncSearch: true,
},
},
};
/**
@ -177,6 +190,24 @@ class AdvancedSearchClassBase {
},
};
/**
* Fields specific to Glossary
*/
glossaryQueryBuilderFields: Fields = {
status: {
label: t('label.status'),
type: 'select',
mainWidgetProps: this.mainWidgetProps,
fieldSettings: {
asyncFetch: this.autocomplete({
searchIndex: SearchIndex.GLOSSARY_TERM,
entityField: EntityFields.GLOSSARY_TERM_STATUS,
}),
useAsyncSearch: true,
},
},
};
/**
* Fields specific to dashboard
*/
@ -548,6 +579,18 @@ class AdvancedSearchClassBase {
...this.dataModelQueryBuilderFields,
...this.apiEndpointQueryBuilderFields,
},
[SearchIndex.DATA_ASSET]: {
...this.tableQueryBuilderFields,
...this.pipelineQueryBuilderFields,
...this.dashboardQueryBuilderFields,
...this.topicQueryBuilderFields,
...this.mlModelQueryBuilderFields,
...this.containerQueryBuilderFields,
...this.searchIndexQueryBuilderFields,
...this.dataModelQueryBuilderFields,
...this.apiEndpointQueryBuilderFields,
...this.glossaryQueryBuilderFields,
},
};
entitySearchIndex.forEach((index) => {

View File

@ -244,12 +244,12 @@ export const renderDomainLink = (
);
export const initializeDomainEntityRef = (
domains: Domain[],
domains: EntityReference[],
activeDomainKey: string
) => {
const domain = domains.find(
(item) => item.fullyQualifiedName === activeDomainKey
);
const domain = domains.find((item) => {
return item.fullyQualifiedName === activeDomainKey;
});
if (domain) {
return getEntityReferenceFromEntity(domain, EntityType.DOMAIN);
}