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

FIX Update LinkField if Elemental version status was updated #268

Closed
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
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
Loading