Skip to content

Commit

Permalink
Merge branch 'datahub-project:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
treff7es authored Dec 15, 2023
2 parents 02f9e6b + 0ea6145 commit f9ea188
Show file tree
Hide file tree
Showing 68 changed files with 3,847 additions and 1,884 deletions.
8 changes: 4 additions & 4 deletions datahub-web-react/src/app/AdminConsole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Menu } from 'antd';
import styled from 'styled-components';
import { BankOutlined, BarChartOutlined, MenuOutlined } from '@ant-design/icons';
import Sider from 'antd/lib/layout/Sider';
import { useGetAuthenticatedUser } from './useGetAuthenticatedUser';
import { useAppConfig } from './useAppConfig';
import { ANTD_GRAY } from './entity/shared/constants';
import { useUserContext } from './context/useUserContext';

const ToggleContainer = styled.div`
background-color: ${ANTD_GRAY[4]};
Expand All @@ -32,16 +32,16 @@ const ControlSlideOut = styled(Sider)`
* Container for all views behind an authentication wall.
*/
export const AdminConsole = (): JSX.Element => {
const me = useGetAuthenticatedUser();
const me = useUserContext();

const [adminConsoleOpen, setAdminConsoleOpen] = useState(false);
const { config } = useAppConfig();

const isAnalyticsEnabled = config?.analyticsConfig.enabled;
const isPoliciesEnabled = config?.policiesConfig.enabled;

const showAnalytics = (isAnalyticsEnabled && me && me.platformPrivileges.viewAnalytics) || false;
const showPolicyBuilder = (isPoliciesEnabled && me && me.platformPrivileges.managePolicies) || false;
const showAnalytics = (isAnalyticsEnabled && me && me?.platformPrivileges?.viewAnalytics) || false;
const showPolicyBuilder = (isPoliciesEnabled && me && me?.platformPrivileges?.managePolicies) || false;
const showAdminConsole = showAnalytics || showPolicyBuilder;

const onMenuItemClick = () => {
Expand Down
5 changes: 3 additions & 2 deletions datahub-web-react/src/app/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ export function getMergedTrackingOptions(options?: any) {

export default {
page: (data?: PageData, options?: any, callback?: (...params: any[]) => any) => {
const actorUrn = Cookies.get(CLIENT_AUTH_COOKIE) || undefined;
const modifiedData = {
...data,
type: EventType[EventType.PageViewEvent],
actorUrn: Cookies.get(CLIENT_AUTH_COOKIE) || undefined,
actorUrn,
timestamp: Date.now(),
date: new Date().toString(),
userAgent: navigator.userAgent,
browserId: getBrowserId(),
};
if (NODE_ENV === 'test') {
if (NODE_ENV === 'test' || !actorUrn) {
return null;
}
const trackingOptions = getMergedTrackingOptions(options);
Expand Down
6 changes: 3 additions & 3 deletions datahub-web-react/src/app/embed/EmbeddedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { VIEW_ENTITY_PAGE } from '../entity/shared/constants';
import { decodeUrn } from '../entity/shared/utils';
import CompactContext from '../shared/CompactContext';
import { useEntityRegistry } from '../useEntityRegistry';
import { useGetAuthenticatedUserUrn } from '../useGetAuthenticatedUser';
import analytics from '../analytics/analytics';
import { EventType } from '../analytics';
import { useUserContext } from '../context/useUserContext';

const EmbeddedPageWrapper = styled.div`
max-height: 100%;
Expand Down Expand Up @@ -39,11 +39,11 @@ export default function EmbeddedPage({ entityType }: Props) {
});
}, [entityType, urn]);

const authenticatedUserUrn = useGetAuthenticatedUserUrn();
const { urn : authenticatedUserUrn } = useUserContext();
const { data } = useGetGrantedPrivilegesQuery({
variables: {
input: {
actorUrn: authenticatedUserUrn,
actorUrn: authenticatedUserUrn as string,
resourceSpec: { resourceType: entityType, resourceUrn: urn },
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
useEntityQuery={useGetGlossaryTermQuery as any}
headerActionItems={new Set([EntityActionItem.BATCH_ADD_GLOSSARY_TERM])}
headerDropdownItems={
new Set([EntityMenuItems.UPDATE_DEPRECATION, EntityMenuItems.MOVE, EntityMenuItems.DELETE])
new Set([
EntityMenuItems.UPDATE_DEPRECATION,
EntityMenuItems.CLONE,
EntityMenuItems.MOVE,
EntityMenuItems.DELETE,
])
}
isNameEditable
hideBrowseBar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components/macro';
import { EditOutlined } from '@ant-design/icons';
import { message, Button, Input, Modal, Typography, Form, Collapse } from 'antd';
import DOMPurify from 'dompurify';
import { useHistory } from 'react-router';
import {
useCreateGlossaryTermMutation,
useCreateGlossaryNodeMutation,
Expand All @@ -16,6 +17,7 @@ import DescriptionModal from '../components/legacy/DescriptionModal';
import { validateCustomUrnId } from '../../../shared/textUtil';
import { useGlossaryEntityData } from '../GlossaryEntityContext';
import { getGlossaryRootToUpdate, updateGlossarySidebar } from '../../../glossary/utils';
import { getEntityPath } from '../containers/profile/utils';

const StyledItem = styled(Form.Item)`
margin-bottom: 0;
Expand All @@ -33,6 +35,7 @@ interface Props {
entityType: EntityType;
onClose: () => void;
refetchData?: () => void;
isCloning?: boolean;
}

function CreateGlossaryEntityModal(props: Props) {
Expand All @@ -43,15 +46,31 @@ function CreateGlossaryEntityModal(props: Props) {
const entityRegistry = useEntityRegistry();
const [stagedId, setStagedId] = useState<string | undefined>(undefined);
const [stagedName, setStagedName] = useState('');
const [selectedParentUrn, setSelectedParentUrn] = useState(entityData.urn);
const [selectedParentUrn, setSelectedParentUrn] = useState<string>(props.isCloning ? '' : entityData.urn);
const [documentation, setDocumentation] = useState('');
const [isDocumentationModalVisible, setIsDocumentationModalVisible] = useState(false);
const [createButtonDisabled, setCreateButtonDisabled] = useState(true);
const refetch = useRefetch();
const history = useHistory();

const [createGlossaryTermMutation] = useCreateGlossaryTermMutation();
const [createGlossaryNodeMutation] = useCreateGlossaryNodeMutation();

useEffect(() => {
if (props.isCloning && entityData.entityData) {
const { properties } = entityData.entityData;

if (properties?.name) {
setStagedName(properties.name);
form.setFieldValue('name', properties.name);
}

if (properties?.description) {
setDocumentation(properties.description);
}
}
}, [props.isCloning, entityData.entityData, form]);

function createGlossaryEntity() {
const mutation =
entityType === EntityType.GlossaryTerm ? createGlossaryTermMutation : createGlossaryNodeMutation;
Expand All @@ -67,7 +86,7 @@ function CreateGlossaryEntityModal(props: Props) {
},
},
})
.then(() => {
.then((res) => {
message.loading({ content: 'Updating...', duration: 2 });
setTimeout(() => {
analytics.event({
Expand All @@ -82,12 +101,19 @@ function CreateGlossaryEntityModal(props: Props) {
refetch();
if (isInGlossaryContext) {
// either refresh this current glossary node or the root nodes or root terms
const nodeToUpdate = entityData?.urn || getGlossaryRootToUpdate(entityType);
const nodeToUpdate = selectedParentUrn || getGlossaryRootToUpdate(entityType);
updateGlossarySidebar([nodeToUpdate], urnsToUpdate, setUrnsToUpdate);
}
if (refetchData) {
refetchData();
}
if (props.isCloning) {
const redirectUrn =
entityType === EntityType.GlossaryTerm
? res.data?.createGlossaryTerm
: res.data?.createGlossaryNode;
history.push(getEntityPath(entityType, redirectUrn, entityRegistry, false, false));
}
}, 2000);
})
.catch((e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
LinkOutlined,
MoreOutlined,
PlusOutlined,
CopyOutlined,
} from '@ant-design/icons';
import { Redirect } from 'react-router';
import { EntityType } from '../../../../types.generated';
Expand All @@ -32,6 +33,7 @@ export enum EntityMenuItems {
ADD_TERM_GROUP,
DELETE,
MOVE,
CLONE,
}

export const MenuIcon = styled(MoreOutlined)<{ fontSize?: number }>`
Expand Down Expand Up @@ -107,6 +109,7 @@ function EntityDropdown(props: Props) {

const [isCreateTermModalVisible, setIsCreateTermModalVisible] = useState(false);
const [isCreateNodeModalVisible, setIsCreateNodeModalVisible] = useState(false);
const [isCloneEntityModalVisible, setIsCloneEntityModalVisible] = useState<boolean>(false);
const [isDeprecationModalVisible, setIsDeprecationModalVisible] = useState(false);
const [isMoveModalVisible, setIsMoveModalVisible] = useState(false);

Expand Down Expand Up @@ -230,6 +233,17 @@ function EntityDropdown(props: Props) {
</Tooltip>
</StyledMenuItem>
)}
{menuItems.has(EntityMenuItems.CLONE) && (
<StyledMenuItem
key="6"
disabled={!entityData?.privileges?.canManageEntity}
onClick={() => setIsCloneEntityModalVisible(true)}
>
<MenuItem>
<CopyOutlined /> &nbsp;Clone
</MenuItem>
</StyledMenuItem>
)}
</Menu>
}
trigger={['click']}
Expand All @@ -250,6 +264,14 @@ function EntityDropdown(props: Props) {
refetchData={refetchForNodes}
/>
)}
{isCloneEntityModalVisible && (
<CreateGlossaryEntityModal
entityType={entityType}
onClose={() => setIsCloneEntityModalVisible(false)}
refetchData={entityType === EntityType.GlossaryTerm ? refetchForTerms : refetchForNodes}
isCloning
/>
)}
{isDeprecationModalVisible && (
<UpdateDeprecationModal
urns={[urn]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Pagination, Typography } from 'antd';
import { Pagination, Spin, Typography } from 'antd';
import { LoadingOutlined } from '@ant-design/icons';
import styled from 'styled-components';
import { FacetFilterInput, FacetMetadata, SearchResults as SearchResultType } from '../../../../../../types.generated';
Expand Down Expand Up @@ -61,7 +61,7 @@ const LoadingContainer = styled.div`
`;

const StyledLoading = styled(LoadingOutlined)`
font-size: 36px;
font-size: 32px;
color: ${ANTD_GRAY[7]};
padding-bottom: 18px;
]`;
Expand Down Expand Up @@ -128,7 +128,7 @@ export const EmbeddedListSearchResults = ({
<ResultContainer>
{loading && (
<LoadingContainer>
<StyledLoading />
<Spin indicator={<StyledLoading />} />
</LoadingContainer>
)}
{!loading && (
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/app/entity/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export type GenericEntityProperties = {
type?: EntityType;
name?: Maybe<string>;
properties?: Maybe<{
name?: Maybe<string>;
description?: Maybe<string>;
qualifiedName?: Maybe<string>;
sourceUrl?: Maybe<string>;
Expand Down
5 changes: 3 additions & 2 deletions datahub-web-react/src/app/lineage/LineageLoadingSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import styled from 'styled-components';
import { Spin } from 'antd';
import { LoadingOutlined } from '@ant-design/icons';
import { ANTD_GRAY } from '../entity/shared/constants';

Expand All @@ -13,15 +14,15 @@ const Container = styled.div`
`;

const StyledLoading = styled(LoadingOutlined)`
font-size: 36px;
font-size: 32px;
color: ${ANTD_GRAY[7]};
padding-bottom: 18px;
]`;

export default function LineageLoadingSection() {
return (
<Container>
<StyledLoading />
<Spin indicator={<StyledLoading />} />
</Container>
);
}
Loading

0 comments on commit f9ea188

Please sign in to comment.