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

Updating content due to UX feedback from users #937

Merged
merged 7 commits into from
Jan 22, 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
39 changes: 32 additions & 7 deletions src/components/inputs/PrefixedName/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import {
} from '@mui/material';
import useValidatePrefix from 'components/inputs/PrefixedName/useValidatePrefix';
import AlertBox from 'components/shared/AlertBox';
import { capitalize } from 'lodash';
import { useMemo } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import { useMount } from 'react-use';
import { hasLength } from 'utils/misc-utils';
import { PrefixedName_Change } from './types';

export interface Props {
label: string | null;
entityType?: string;
allowBlankName?: boolean;
allowEndSlash?: boolean;
defaultPrefix?: boolean;
Expand All @@ -39,11 +42,13 @@ export interface Props {
const DESCRIPTION_ID = 'prefixed-name-description';
const INPUT_ID = 'prefixed-name-input';

// eslint-disable-next-line complexity
function PrefixedName({
allowBlankName,
allowEndSlash,
defaultPrefix,
disabled,
entityType,
hideErrorMessage,
label,
onChange,
Expand Down Expand Up @@ -86,13 +91,33 @@ function PrefixedName({
const variantString = standardVariant ? 'standard' : 'outlined';

// For rendering help and errors - based on JSONForms approach
const description = showDescription
? intl.formatMessage({
id: singleOption
? 'prefixedName.description.singlePrefix'
: 'prefixedName.description',
})
: null;
const description = useMemo(() => {
if (!showDescription) {
return null;
}

const messageKey =
singleOption || prefix.length > 0
? entityType
? 'prefixedName.description.singlePrefix'
: 'prefixedName.description.singlePrefix.noEntityType'
: name.length > 0
? 'prefixedName.description.noPrefix'
: 'prefixedName.description';

return intl.formatMessage(
{ id: messageKey },
{ entityType: entityType ? capitalize(entityType) : null }
);
}, [
entityType,
intl,
name.length,
prefix.length,
showDescription,
singleOption,
]);

const firstFormHelperText = description
? description
: showErrors
Expand Down
3 changes: 3 additions & 0 deletions src/forms/renderers/CatalogName/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { WithOptionLabel } from '@jsonforms/material-renderers/lib/mui-controls/
import { withJsonFormsOneOfEnumProps } from '@jsonforms/react';
import PrefixedName from 'components/inputs/PrefixedName';
import { PrefixedName_Change } from 'components/inputs/PrefixedName/types';
import { useEntityType } from 'context/EntityContext';
import { useEntityWorkflow_Editing } from 'context/Workflow';
import { useCallback } from 'react';

Expand All @@ -53,6 +54,7 @@ const CatalogNameTypeRenderer = ({
uischema,
}: ControlProps & OwnPropsOfEnum & WithOptionLabel) => {
const isEdit = useEntityWorkflow_Editing();
const entityType = useEntityType();

const updateFunction = useCallback<PrefixedName_Change>(
(prefixedName) => {
Expand All @@ -65,6 +67,7 @@ const CatalogNameTypeRenderer = ({
<PrefixedName
disabled={!enabled}
label={`${uischema.label}`}
entityType={entityType}
onChange={updateFunction}
required={required}
showDescription
Expand Down
11 changes: 7 additions & 4 deletions src/lang/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const CommonMessages: ResolvedIntlConfig['messages'] = {
'common.readOnly': `Read-Only`,
'common.failedFetch': `Unable to reach server`,
'common.missingError': `Something went wrong`,
'common.exampleName': `marketing_data`,

// Aria
'aria.openExpand': `show more`,
Expand Down Expand Up @@ -1006,9 +1007,9 @@ const Workflows: ResolvedIntlConfig['messages'] = {
'workflows.autoDiscovery.update.failed': `Schema evolution update failed`,

'workflows.sourceCapture.header': `Link Capture`,
'workflows.sourceCapture.cta': `link capture`,
'workflows.sourceCapture.cta': `Source From Capture`,
'workflows.sourceCapture.cta.edit': `Edit Source Capture`,
'workflows.sourceCapture.cta.loading': `${CommonMessages['common.loading']}`,
'workflows.sourceCapture.cta.edit': `edit capture`,
'workflows.sourceCapture.selected.none': `no linked capture`,
'workflows.sourceCapture.optin.message': `Select a capture to link to your materialization. Collections added to your capture will automatically be added to your materialization.`,
'workflows.sourceCapture.optin.message2': `Removing this will not remove associated collections.`,
Expand Down Expand Up @@ -1284,8 +1285,10 @@ const UpdateEntity: ResolvedIntlConfig['messages'] = {
};

const PrefixedName: ResolvedIntlConfig['messages'] = {
'prefixedName.description': `Select a prefix from the drop-down and add a unique name. (ex: acmeCo/marketing_data)`,
'prefixedName.description.singlePrefix': `Prefix already selected. Please add a unique name. (ex: marketing_data)`,
'prefixedName.description': `Select a prefix from the drop-down and add a unique name. (ex: ${CommonMessages['common.exampleName']})`,
'prefixedName.description.noPrefix': `Please select a prefix from the drop-down.`,
'prefixedName.description.singlePrefix': `Give your {entityType} a unique name. (ex: ${CommonMessages['common.exampleName']})`,
'prefixedName.description.singlePrefix.noEntityType': `Please add a unique name. (ex: ${CommonMessages['common.exampleName']})`,
};

const CustomErrors: ResolvedIntlConfig['messages'] = {
Expand Down