Skip to content

Commit

Permalink
#5296 - Save Support for RDF Format (#5608)
Browse files Browse the repository at this point in the history
* #5296 - Implemented save to rdf, fixed view only 3d mode

* #5296 - reverted indigo version

* #5296 - updated test snapshot
  • Loading branch information
daniil-sloboda authored Oct 2, 2024
1 parent 93e32ab commit 6b76730
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ test.describe('Multi-Tailed Arrow Tool', () => {
await selectTopPanelButton(TopPanelButton.Save, page);
await expect(page.getByText('Save to Templates')).toBeDisabled();
await takeEditorScreenshot(page, {
masks: [page.getByTestId('mol-preview-area-text')],
masks: [page.getByTestId('rxn-preview-area-text')],
});
});

Expand Down
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
Expand Up @@ -157,6 +157,18 @@ const formatProperties: FormatPropertiesMap = {
['.'],
true,
),
rdf: new SupportedFormatProperties(
'RDF V2000',
ChemicalMimeType.RDF,
['.rdf'],
true,
),
rdfV3000: new SupportedFormatProperties(
'RDF V3000',
ChemicalMimeType.RDF,
['.rdf'],
true,
),
};

const imgFormatProperties = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export enum SupportedFormat {
idt = 'idt',
helm = 'helm',
unknown = 'unknown',
rdf = 'rdf',
rdfV3000 = 'rdfV3000',
}

export type FormatterFactoryOptions = Partial<
Expand Down
4 changes: 4 additions & 0 deletions packages/ketcher-core/src/domain/entities/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export class Struct {
return this.rxnArrows.size >= 1;
}

hasMultitailArrow(): boolean {
return this.multitailArrows.size >= 1;
}

hasRxnPluses(): boolean {
return this.rxnPluses.size > 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export enum ChemicalMimeType {
PEPTIDE = 'chemical/x-peptide-sequence',
IDT = 'chemical/x-idt',
HELM = 'chemical/x-helm',
RDF = 'chemical/x-rdf',
}

export interface WithStruct {
Expand Down
1 change: 1 addition & 0 deletions packages/ketcher-react/src/script/ui/action/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const config = {
},
miew: {
title: '3D Viewer',
enabledInViewOnly: true,
action: { dialog: 'miew' },
hidden: (options) => isHidden(options, 'miew'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class SaveDialog extends Component {
tabIndex: 0,
isLoading: true,
};
this.isRxn = this.props.struct.hasRxnArrow();
this.isRxn =
this.props.struct.hasRxnArrow() || this.props.struct.hasMultitailArrow();
this.textAreaRef = createRef();

const formats = !this.props.server
Expand All @@ -89,6 +90,8 @@ class SaveDialog extends Component {
this.isRxn ? 'rxnV3000' : 'molV3000',
'sdf',
'sdfV3000',
'rdf',
'rdfV3000',
'smarts',
'smiles',
'smilesExt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const initialState = {
editor: {
struct: () => ({
hasRxnArrow: () => false,
hasMultitailArrow: () => false,
isBlank: () => true,
atoms: { size: 0 },
bonds: { size: 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,26 @@ Object {
>
SDF V3000
</li>
<li
aria-selected="false"
class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gutters MuiMenuItem-root MuiMenuItem-gutters css-kk1bwy-MuiButtonBase-root-MuiMenuItem-root"
data-testid="RDF V2000-option"
data-value="rdf"
role="option"
tabindex="-1"
>
RDF V2000
</li>
<li
aria-selected="false"
class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gutters MuiMenuItem-root MuiMenuItem-gutters css-kk1bwy-MuiButtonBase-root-MuiMenuItem-root"
data-testid="RDF V3000-option"
data-value="rdfV3000"
role="option"
tabindex="-1"
>
RDF V3000
</li>
<li
aria-selected="false"
class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gutters MuiMenuItem-root MuiMenuItem-gutters css-kk1bwy-MuiButtonBase-root-MuiMenuItem-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* limitations under the License.
***************************************************************************/

import { lazy, Suspense, useCallback, useRef, useState } from 'react';
import { lazy, Suspense, useCallback, useMemo, useRef, useState } from 'react';
import { Dialog, LoadingCircles } from '../../../../components';
import {
FormatterFactory,
KetcherLogger,
ketcherProvider,
Struct,
StructService,
SupportedFormat,
Expand Down Expand Up @@ -121,6 +122,13 @@ const MiewDialog = ({
}: Props) => {
const miewRef = useRef<MiewAsType>();
const [isInitialized, setIsIsInitialized] = useState(false);
const ketcher = ketcherProvider.getKetcher();

const isDisabled = useMemo(() => {
return (
!isInitialized || ketcher?.editor.render.options.viewOnlyMode === true
);
}, [ketcher, isInitialized]);

const onMiewInit = useCallback(
(miew: MiewAsType) => {
Expand Down Expand Up @@ -163,7 +171,7 @@ const MiewDialog = ({
key="apply"
onClick={exportCML}
className={classes.applyButton}
disabled={!isInitialized}
disabled={isDisabled}
data-testid="miew-modal-button"
>
Apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export enum SupportedFormat {
SEQUENCE = 'sequence',
IDT = 'idt',
HELM = 'helm',
RDF = 'rdf',
}

export interface WithStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ function convertMimeTypeToOutputFormat(
format = SupportedFormat.HELM;
break;
}
case ChemicalMimeType.RDF:
format = SupportedFormat.RDF;
break;
case ChemicalMimeType.UNKNOWN:
default: {
throw new Error('Unsupported chemical mime type');
Expand Down

0 comments on commit 6b76730

Please sign in to comment.