Skip to content

Commit

Permalink
FIX Update LinkField if Elemental version status was updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Apr 2, 2024
1 parent d0c44eb commit fefaa4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions client/src/components/LinkField/LinkField.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const LinkField = ({
ownerRelation,
excludeLinkTextField = false,
inHistoryViewer,
versionStatus = '',
}) => {
const [data, setData] = useState({});
const [editingID, setEditingID] = useState(0);
Expand Down Expand Up @@ -171,7 +172,7 @@ const LinkField = ({
setIsSorting(false);
})
}
}, [editingID, value && value.length, forceFetch]);
}, [editingID, value && value.length, forceFetch, versionStatus]);

// Create refs for each LinkPickerTitle button so they can be focused when the editing modal is closed via keyboard
let refCount = 0;
Expand Down Expand Up @@ -520,9 +521,25 @@ const mapDispatchToProps = (dispatch) => ({
},
});

const mapStateToProps = function(state, ownProps) {
const formData = state.elemental && state.elemental[ownProps.formid] ? state.elemental[ownProps.formid] : {};
let status = '';
if (formData.isPublished === false) {
status = 'Draft';
} else if (formData.isLiveVersion === false) {
status = 'Modified';
} else {
status = 'Publised';
}

return {
versionStatus: status
};
};

export { LinkField as Component };

export default compose(
fieldHolder,
connect(null, mapDispatchToProps)
connect(mapStateToProps, mapDispatchToProps)
)(LinkField);
6 changes: 5 additions & 1 deletion tests/behat/features/linkfield-in-elemental.feature
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ I want to be able to work with LinkField and MultiLinkField in Elemental Block

# Test that user can publish the page with links

When I press the "Publish" button
When I press the "View actions" button
Then I click on the ".element-editor__actions-publish" element
And I wait for 2 seconds
Then I click on the ".element-editor__element" element
And I should not see "Draft" in the "#Form_ElementForm_1_PageElements_1_OneLink_Holder" element
Expand All @@ -99,6 +100,9 @@ I want to be able to work with LinkField and MultiLinkField in Elemental Block
And I wait for 2 seconds
And I should see "All about us" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-first" element
And I should see "Modified" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-first" element
Then I press the "Publish" button
Then I click on the ".element-editor__element" element
And I should not see "Modified" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder" element

# Test that user can delete the link

Expand Down

0 comments on commit fefaa4c

Please sign in to comment.