Skip to content

Commit

Permalink
fix(wren-ui): see an error when editing a relationship in the defined…
Browse files Browse the repository at this point in the history
… relationships step of onboarding (#872)
  • Loading branch information
fredalai authored Nov 15, 2024
1 parent 0774299 commit a70dac0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 4 additions & 2 deletions wren-ui/src/components/modals/RelationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Props = ModalAction<RelationFieldValue, RelationFormValues> & {
model: string;
loading?: boolean;
relations: SelectedRecommendRelations;
isRecommendMode?: boolean;
};

export default function RelationModal(props: Props) {
Expand All @@ -49,6 +50,7 @@ export default function RelationModal(props: Props) {
relations,
visible,
formMode,
isRecommendMode,
} = props;
const [form] = Form.useForm();

Expand Down Expand Up @@ -113,7 +115,7 @@ export default function RelationModal(props: Props) {
rules={[
({ getFieldValue }) => ({
validator: createRelationshipFromFieldValidator(
isUpdateMode,
isUpdateMode || isRecommendMode,
relations,
getFieldValue,
),
Expand All @@ -136,7 +138,7 @@ export default function RelationModal(props: Props) {
rules={[
({ getFieldValue }) => ({
validator: createRelationshipToFieldValidator(
isUpdateMode,
isUpdateMode || isRecommendMode,
relations,
getFieldValue,
),
Expand Down
15 changes: 8 additions & 7 deletions wren-ui/src/components/pages/setup/DefineRelations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface SelectedRecommendRelations {
interface Props {
fetching: boolean;
recommendRelations: SelectedRecommendRelations;
recommendNameMappping: Record<string, string>;
recommendNameMapping: Record<string, string>;
onNext: (data: { relations: SelectedRecommendRelations }) => void;
onBack: () => void;
onSkip: () => void;
Expand All @@ -53,7 +53,7 @@ interface EditableRelationTableProps {
}) => void;
onDeleteRow: (modelName: string, selectedRelation: RelationsDataType) => void;
relations: RelationsDataType[];
recommendNameMappping: Record<string, string>;
recommendNameMapping: Record<string, string>;
}

function EditableRelationTable(props: EditableRelationTableProps) {
Expand All @@ -63,7 +63,7 @@ function EditableRelationTable(props: EditableRelationTableProps) {
onSetRelation,
onDeleteRow,
relations,
recommendNameMappping,
recommendNameMapping,
} = props;

const columns: ColumnsType<RelationsDataType> = [
Expand Down Expand Up @@ -130,12 +130,12 @@ function EditableRelationTable(props: EditableRelationTableProps) {
<ModelRelationSelectionTable
columns={columns}
dataSource={relations}
tableTitle={recommendNameMappping[modelName]}
tableTitle={recommendNameMapping[modelName]}
extra={(onCollapseOpen) => (
<Button
onClick={(event) => {
onSetRelation({ modelName });
onCollapseOpen(event, recommendNameMappping[modelName]);
onCollapseOpen(event, recommendNameMapping[modelName]);
}}
size="small"
title="Add relationship"
Expand All @@ -156,7 +156,7 @@ export default function DefineRelations(props: Props) {
const {
fetching,
recommendRelations,
recommendNameMappping,
recommendNameMapping,
onBack,
onNext,
onSkip,
Expand Down Expand Up @@ -298,7 +298,7 @@ export default function DefineRelations(props: Props) {
relations={relations}
onSetRelation={onSetRelation}
onDeleteRow={onDeleteRow}
recommendNameMappping={recommendNameMappping}
recommendNameMapping={recommendNameMapping}
/>
),
)}
Expand Down Expand Up @@ -361,6 +361,7 @@ export default function DefineRelations(props: Props) {
: undefined
}
relations={relations}
isRecommendMode={Boolean(selectedRelation?.defaultValue)}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions wren-ui/src/hooks/useSetupRelations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ export default function useSetupRelations() {
});

acc['recommendRelations'][referenceName] = newRelations;
acc['recommendNameMappping'][referenceName] = displayName;
acc['recommendNameMapping'][referenceName] = displayName;
return acc;
},
{
recommendRelations: {},
recommendNameMappping: {},
recommendNameMapping: {},
},
),
[autoGenerateRelation],
Expand Down

0 comments on commit a70dac0

Please sign in to comment.