Skip to content

Commit

Permalink
#6185 – Make SGroups expandable while placed within a chain (#6208)
Browse files Browse the repository at this point in the history
* #6185 – Make SGroups expandable while placed within a chain

* #6185 – Fix UI tests
  • Loading branch information
svvald authored Dec 25, 2024
1 parent 07d3cf3 commit c48ec4b
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 19 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action, setExpandSGroup } from 'ketcher-core';
import { Action, setExpandMonomerSGroup } from 'ketcher-core';
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { useAppContext } from 'src/hooks';
Expand Down Expand Up @@ -27,7 +27,7 @@ const useFunctionalGroupEoc = () => {

selectedFunctionalGroups?.forEach((functionalGroup) => {
action.mergeWith(
setExpandSGroup(molecule, functionalGroup.relatedSGroupId, {
setExpandMonomerSGroup(molecule, functionalGroup.relatedSGroupId, {
expanded: toExpand,
}),
);
Expand All @@ -47,17 +47,8 @@ const useFunctionalGroupEoc = () => {
),
);
}, []);
const disabled = useCallback(({ props }: Params) => {
const editor = getKetcherInstance().editor as Editor;
const molecule = editor.render.ctab.molecule;
return Boolean(
props?.functionalGroups?.every((functionalGroup) =>
functionalGroup?.relatedSGroup.isNotContractible(molecule),
),
);
}, []);

return [handler, hidden, disabled] as const;
return [handler, hidden] as const;
};

export default useFunctionalGroupEoc;
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@ import {
const FunctionalGroupMenuItems: FC<
MenuItemsProps<FunctionalGroupsContextMenuProps>
> = (props) => {
const [
handleExpandOrContract,
ExpandOrContractHidden,
ExpandOrContractDisabled,
] = useFunctionalGroupEoc();
const [handleExpandOrContract, ExpandOrContractHidden] =
useFunctionalGroupEoc();
const handleRemove = useFunctionalGroupRemove();

return (
<>
<Item
{...props}
disabled={(params) => ExpandOrContractDisabled(params)}
hidden={(params) => ExpandOrContractHidden(params, true)}
onClick={(params) => handleExpandOrContract(params, true)}
>
Expand Abbreviation
</Item>
<Item
{...props}
disabled={(params) => ExpandOrContractDisabled(params)}
hidden={(params) => ExpandOrContractHidden(params, false)}
onClick={(params) => handleExpandOrContract(params, false)}
>
Expand Down

0 comments on commit c48ec4b

Please sign in to comment.