Skip to content

Commit

Permalink
Merge branch 'pb-remove-0' of https://github.com/pinakipb2/datahub in…
Browse files Browse the repository at this point in the history
…to pb-remove-0
  • Loading branch information
pinakipb2 committed Aug 13, 2024
2 parents 91f31da + 1feb2c8 commit b5866f8
Show file tree
Hide file tree
Showing 26 changed files with 2,028 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { SchemaField, StdDataType } from '../../../../../../../../types.generate
import { SectionHeader, StyledDivider } from './components';
import { mapStructuredPropertyValues } from '../../../../Properties/useStructuredProperties';
import StructuredPropertyValue from '../../../../Properties/StructuredPropertyValue';
import { EditColumn } from '../../../../Properties/Edit/EditColumn';
import { useGetEntityWithSchema } from '../../useGetEntitySchema';

const PropertyTitle = styled.div`
font-size: 14px;
Expand All @@ -13,6 +15,8 @@ const PropertyTitle = styled.div`

const PropertyWrapper = styled.div`
margin-bottom: 12px;
display: flex;
justify-content: space-between;
`;

const PropertiesWrapper = styled.div`
Expand All @@ -29,6 +33,7 @@ interface Props {

export default function FieldProperties({ expandedField }: Props) {
const { schemaFieldEntity } = expandedField;
const { refetch } = useGetEntityWithSchema(true);

if (!schemaFieldEntity?.structuredProperties?.properties?.length) return null;

Expand All @@ -43,23 +48,33 @@ export default function FieldProperties({ expandedField }: Props) {
const hasMultipleValues = valuesData.length > 1;

return (
<PropertyWrapper>
<PropertyTitle>{structuredProp.structuredProperty.definition.displayName}</PropertyTitle>
{hasMultipleValues ? (
<StyledList>
{valuesData.map((value) => (
<li>
<PropertyWrapper key={structuredProp.structuredProperty.urn}>
<div>
<PropertyTitle>
{structuredProp.structuredProperty.definition.displayName}
</PropertyTitle>
{hasMultipleValues ? (
<StyledList>
{valuesData.map((value) => (
<li>
<StructuredPropertyValue value={value} isRichText={isRichText} />
</li>
))}
</StyledList>
) : (
<>
{valuesData.map((value) => (
<StructuredPropertyValue value={value} isRichText={isRichText} />
</li>
))}
</StyledList>
) : (
<>
{valuesData.map((value) => (
<StructuredPropertyValue value={value} isRichText={isRichText} />
))}
</>
)}
))}
</>
)}
</div>
<EditColumn
structuredProperty={structuredProp.structuredProperty}
associatedUrn={schemaFieldEntity.urn}
values={valuesData.map((v) => v.value) || []}
refetch={refetch}
/>
</PropertyWrapper>
);
})}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { Button } from 'antd';
import React, { useState } from 'react';
import { PropertyRow } from '../types';
import EditStructuredPropertyModal from './EditStructuredPropertyModal';
import { StructuredPropertyEntity } from '../../../../../../types.generated';

interface Props {
propertyRow: PropertyRow;
structuredProperty?: StructuredPropertyEntity;
associatedUrn?: string;
values?: (string | number | null)[];
refetch?: () => void;
}

export function EditColumn({ propertyRow }: Props) {
export function EditColumn({ structuredProperty, associatedUrn, values, refetch }: Props) {
const [isEditModalVisible, setIsEditModalVisible] = useState(false);

if (!propertyRow.structuredProperty || propertyRow.structuredProperty?.definition.immutable) {
if (!structuredProperty || structuredProperty?.definition.immutable) {
return null;
}

Expand All @@ -21,9 +24,11 @@ export function EditColumn({ propertyRow }: Props) {
</Button>
<EditStructuredPropertyModal
isOpen={isEditModalVisible}
propertyRow={propertyRow}
structuredProperty={propertyRow.structuredProperty}
structuredProperty={structuredProperty}
associatedUrn={associatedUrn}
values={values}
closeModal={() => setIsEditModalVisible(false)}
refetch={refetch}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Button, Modal, message } from 'antd';
import React from 'react';
import React, { useEffect, useMemo } from 'react';
import styled from 'styled-components';
import { PropertyRow } from '../types';
import StructuredPropertyInput from '../../../components/styled/StructuredProperty/StructuredPropertyInput';
import { PropertyValueInput, StructuredPropertyEntity } from '../../../../../../types.generated';
import { useUpsertStructuredPropertiesMutation } from '../../../../../../graphql/structuredProperties.generated';
Expand All @@ -17,19 +16,33 @@ const Description = styled.div`

interface Props {
isOpen: boolean;
propertyRow: PropertyRow;
structuredProperty: StructuredPropertyEntity;
associatedUrn?: string;
values?: (string | number | null)[];
closeModal: () => void;
refetch?: () => void;
}

export default function EditStructuredPropertyModal({ isOpen, propertyRow, structuredProperty, closeModal }: Props) {
const { refetch } = useEntityContext();
const urn = useMutationUrn();
const initialValues = propertyRow.values?.map((v) => v.value) || [];
const { selectedValues, selectSingleValue, toggleSelectedValue, updateSelectedValues } =
export default function EditStructuredPropertyModal({
isOpen,
structuredProperty,
associatedUrn,
values,
closeModal,
refetch,
}: Props) {
const { refetch: entityRefetch } = useEntityContext();
const mutationUrn = useMutationUrn();
const urn = associatedUrn || mutationUrn;
const initialValues = useMemo(() => values || [], [values]);
const { selectedValues, selectSingleValue, toggleSelectedValue, updateSelectedValues, setSelectedValues } =
useEditStructuredProperty(initialValues);
const [upsertStructuredProperties] = useUpsertStructuredPropertiesMutation();

useEffect(() => {
setSelectedValues(initialValues);
}, [isOpen, initialValues, setSelectedValues]);

function upsertProperties() {
message.loading('Updating...');
upsertStructuredProperties({
Expand All @@ -51,7 +64,11 @@ export default function EditStructuredPropertyModal({ isOpen, propertyRow, struc
},
})
.then(() => {
refetch();
if (refetch) {
refetch();
} else {
entityRefetch();
}
message.destroy();
message.success('Successfully updated structured property!');
closeModal();
Expand All @@ -67,7 +84,7 @@ export default function EditStructuredPropertyModal({ isOpen, propertyRow, struc

return (
<Modal
title={propertyRow.displayName}
title={structuredProperty.definition.displayName}
onCancel={closeModal}
open={isOpen}
width={650}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export const PropertiesTab = () => {
propertyTableColumns.push({
title: '',
width: '10%',
render: (propertyRow: PropertyRow) => <EditColumn propertyRow={propertyRow} />,
render: (propertyRow: PropertyRow) => (
<EditColumn
structuredProperty={propertyRow.structuredProperty}
values={propertyRow.values?.map((v) => v.value) || []}
/>
),
} as any);
}

Expand Down
22 changes: 22 additions & 0 deletions docs-website/adoptionStoriesIndexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@
"category": "B2B & B2C",
"description": "<i>“We looked around for data catalog tool, and DataHub was a clear winner.”</i> <br /> <br /> Zynga levels up data management using DataHub, highlighting its role in enhancing data management, tracing data lineage, and ensuring data quality."
},
{
"name": "Chime",
"slug": "chime",
"imageUrl": "/img/logos/companies/chime.png",
"imageSize": "default",
"link": "https://www.youtube.com/watch?v=GktS-XJhK30",
"linkType": "video",
"tagline": "A Story of schema, contracts, and data discovery",
"category": "Financial & Fintech",
"description": "<i>“At Chime, DataHub serves as our guide for navigating the complexities of data cataloging and discovery.”</i> <br /> <br /> Chime uses Datahub (DataHub Cloud) for ingesting metadata from diverse infrastructure components like Snowflake, Looker, Terraform, and so many others."
},
{
"name": "Checkout.com",
"slug": "checkout-com",
"imageUrl": "/img/logos/companies/checkout-com.svg",
"imageSize": "small",
"link": "https://www.youtube.com/watch?v=emkpKO0bTkI",
"linkType": "video",
"tagline": "Self-Serve Data Governance with DataHub Action Framework",
"category": "Financial & Fintech",
"description": "Discover how Checkout leverage DataHub for advanced data management and compliance, especially in managing sensitive data types."
},
{
"name": "MediaMarkt Saturn",
"slug": "mediamarkt-saturn",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b5866f8

Please sign in to comment.