Skip to content

Commit

Permalink
feat(ui) Add finishing touches to the structured props feature (datah…
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 authored Dec 16, 2024
1 parent ca6f435 commit d5e379a
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ export class SchemaFieldPropertiesEntity implements Entity<SchemaFieldEntity> {
// Currently unused.
getPathName = () => 'schemaField';

// Currently unused.
getEntityName = () => 'schemaField';
getEntityName = () => 'Column';

// Currently unused.
getCollectionName = () => 'schemaFields';
getCollectionName = () => 'Columns';

// Currently unused.
renderProfile = (_: string) => <></>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const DeprecatedContainer = styled.div`
justify-content: center;
align-items: center;
color: #cd0d24;
margin-left: 0px;
margin-right: 8px;
padding-top: 8px;
padding-bottom: 8px;
padding-right: 4px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React from 'react';
import styled from 'styled-components';
import { ANTD_GRAY_V2 } from '../../../constants';

const MultiStringWrapper = styled.div``;

const StyledInput = styled(Input)`
width: 75%;
min-width: 350px;
Expand All @@ -29,10 +31,11 @@ const DeleteButton = styled(Button)`

interface Props {
selectedValues: any[];
inputType?: string;
updateSelectedValues: (values: any[]) => void;
}

export default function MultipleStringInput({ selectedValues, updateSelectedValues }: Props) {
export default function MultipleOpenEndedInput({ selectedValues, updateSelectedValues, inputType = 'text' }: Props) {
function updateInput(text: string, index: number) {
const updatedValues =
selectedValues.length > 0 ? selectedValues.map((value, i) => (i === index ? text : value)) : [text];
Expand All @@ -53,14 +56,14 @@ export default function MultipleStringInput({ selectedValues, updateSelectedValu
}

return (
<div>
<MultiStringWrapper>
{selectedValues.length > 1 &&
selectedValues.map((selectedValue, index) => {
const key = `${index}`;
return (
<InputWrapper key={key}>
<StyledInput
type="text"
type={inputType}
value={selectedValue}
onChange={(e) => updateInput(e.target.value, index)}
/>
Expand All @@ -70,14 +73,14 @@ export default function MultipleStringInput({ selectedValues, updateSelectedValu
})}
{selectedValues.length <= 1 && (
<StyledInput
type="text"
type={inputType}
value={selectedValues[0] || ''}
onChange={(e) => updateInput(e.target.value, 0)}
/>
)}
<StyledButton type="link" onClick={addNewValue}>
+ Add More
</StyledButton>
</div>
</MultiStringWrapper>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Input } from 'antd';
import React, { ChangeEvent } from 'react';
import styled from 'styled-components';
import { PropertyCardinality } from '@src/types.generated';
import { ANTD_GRAY_V2 } from '../../../constants';
import MultipleOpenEndedInput from './MultipleOpenEndedInput';

const StyledInput = styled(Input)`
border: 1px solid ${ANTD_GRAY_V2[6]};
Expand All @@ -10,15 +12,31 @@ const StyledInput = styled(Input)`

interface Props {
selectedValues: any[];
cardinality?: PropertyCardinality | null;
updateSelectedValues: (values: string[] | number[]) => void;
}

export default function NumberInput({ selectedValues, updateSelectedValues }: Props) {
export default function NumberInput({ selectedValues, cardinality, updateSelectedValues }: Props) {
function updateInput(event: ChangeEvent<HTMLInputElement>) {
const number = Number(event.target.value);
updateSelectedValues([number]);
}

function updateMultipleValues(values: string[] | number[]) {
const numbers = values.map((v) => Number(v));
updateSelectedValues(numbers);
}

if (cardinality === PropertyCardinality.Multiple) {
return (
<MultipleOpenEndedInput
selectedValues={selectedValues}
updateSelectedValues={updateMultipleValues}
inputType="number"
/>
);
}

return (
<StyledInput
type="number"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { ChangeEvent } from 'react';
import styled from 'styled-components';
import { ANTD_GRAY_V2 } from '../../../constants';
import { PropertyCardinality } from '../../../../../../types.generated';
import MultipleStringInput from './MultipleStringInput';
import MultipleOpenEndedInput from './MultipleOpenEndedInput';

const StyledInput = styled(Input)`
width: 75%;
Expand All @@ -24,8 +24,15 @@ export default function StringInput({ selectedValues, cardinality, updateSelecte
}

if (cardinality === PropertyCardinality.Multiple) {
return <MultipleStringInput selectedValues={selectedValues} updateSelectedValues={updateSelectedValues} />;
return <MultipleOpenEndedInput selectedValues={selectedValues} updateSelectedValues={updateSelectedValues} />;
}

return <StyledInput type="text" value={selectedValues[0] || ''} onChange={updateInput} />;
return (
<StyledInput
type="text"
value={selectedValues[0] || ''}
onChange={updateInput}
data-testid="structured-property-string-value-input"
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export default function StructuredPropertyInput({
<DateInput selectedValues={selectedValues} updateSelectedValues={updateSelectedValues} />
)}
{!allowedValues && valueType.info.type === StdDataType.Number && (
<NumberInput selectedValues={selectedValues} updateSelectedValues={updateSelectedValues} />
<NumberInput
selectedValues={selectedValues}
cardinality={cardinality}
updateSelectedValues={updateSelectedValues}
/>
)}
{!allowedValues && valueType.info.type === StdDataType.Urn && (
<UrnInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const TitleWrapper = styled.div`
display: flex;
justify-content: left;
align-items: center;
gap: 8px;
.ant-typography-edit-content {
padding-top: 7px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { useEntityData, useRefetch } from '../../../EntityContext';
import { useGlossaryEntityData } from '../../../GlossaryEntityContext';

export const EntityTitle = styled(Typography.Title)`
margin-right: 10px;
&&& {
margin-bottom: 0;
word-break: break-all;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const AllowedValuesDrawer = ({
setTimeout(() => scrollToBottom(), 0);
}}
color="violet"
type="button"
>
Add
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ const DisplayPreferences = ({
clickable={false}
/>
&nbsp;is already being shown on asset previews, but only one property is allowed at a time.
Do you want to replace the current property? This will hide PropVal on all asset previews.
Do you want to replace the current property? This will hide {getDisplayName(badgeProperty)}{' '}
on all asset previews.
</p>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const StructuredPropsDrawer = ({
form.validateFields().then(() => {
const createInput = {
...form.getFieldsValue(),
qualifiedName: form.getFieldValue('qualifiedName') || undefined,
valueType: valueTypes.find((type) => type.value === form.getFieldValue('valueType'))?.urn,
allowedValues,
cardinality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const addToCache = (existingProperties, newProperty) => {
allowedValues: newProperty.definition.allowedValues,
created: newProperty.definition.created,
lastModified: newProperty.definition.lastModified,
filterStatus: newProperty.definition.filterStatus,
},
settings: {
isHidden: newProperty.settings.isHidden,
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/preview/DefaultPreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const TitleContainer = styled.div`
const EntityTitleContainer = styled.div`
display: flex;
align-items: center;
gap: 8px;
`;

const EntityTitle = styled(Typography.Text)<{ $titleSizePx?: number }>`
Expand All @@ -77,7 +78,6 @@ const EntityTitle = styled(Typography.Text)<{ $titleSizePx?: number }>`
}
&&& {
margin-right 8px;
font-size: ${(props) => props.$titleSizePx || 16}px;
font-weight: 600;
vertical-align: middle;
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ fragment facetFields on FacetMetadata {
entity {
urn
type
...entityDisplayNameFields
... on Tag {
name
properties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public class PoliciesConfig {
MANAGE_BUSINESS_ATTRIBUTE_PRIVILEGE,
MANAGE_CONNECTIONS_PRIVILEGE,
MANAGE_STRUCTURED_PROPERTIES_PRIVILEGE,
VIEW_STRUCTURED_PROPERTIES_PAGE_PRIVILEGE,
MANAGE_DOCUMENTATION_FORMS_PRIVILEGE,
MANAGE_FEATURES_PRIVILEGE,
MANAGE_SYSTEM_OPERATIONS_PRIVILEGE);
Expand Down

0 comments on commit d5e379a

Please sign in to comment.