Skip to content

Commit

Permalink
Merge branch 'dev' into feature/SOF-7326-1
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Apr 14, 2024
2 parents cbee134 + 13c087d commit c67bf42
Show file tree
Hide file tree
Showing 17 changed files with 553 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default PythonTransformation;
declare class PythonTransformation extends React.Component<any, any, any> {
constructor(props: any);
state: {
pyodide: null;
};
onLoad: (pyodideInstance: any) => void;
render(): React.JSX.Element;
}
declare namespace PythonTransformation {
namespace propTypes {
const show: PropTypes.Validator<boolean>;
const onHide: PropTypes.Validator<(...args: any[]) => any>;
}
}
import React from "react";
import PropTypes from "prop-types";
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import PyodideLoader from "@exabyte-io/cove.js/dist/other/pyodide";
import Dialog from "@mui/material/Dialog";
import PropTypes from "prop-types";
import React from "react";
class PythonTransformation extends React.Component {
constructor(props) {
super(props);
this.onLoad = (pyodideInstance) => {
this.setState({ pyodide: pyodideInstance });
};
this.state = {
pyodide: null,
};
}
render() {
const { show, onHide } = this.props;
return (React.createElement(React.Fragment, null,
React.createElement(PyodideLoader, { onLoad: this.onLoad, triggerLoad: show }),
React.createElement(Dialog, { open: show, onClose: onHide, fullWidth: true, maxWidth: "lg", PaperProps: { sx: { width: "60vw", height: "60vh", padding: "20px" } } },
React.createElement("div", null, this.state.pyodide ? "Pyodide is loaded" : "Pyodide is not loaded"))));
}
}
PythonTransformation.propTypes = {
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired,
};
export default PythonTransformation;
20 changes: 20 additions & 0 deletions dist/components/include/SAlertContentTmpl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default SAlertContentTmpl;
declare function SAlertContentTmpl({ id, classNames, condition, styles, message, handleClose, }: {
id: any;
classNames: any;
condition: any;
styles: any;
message: any;
handleClose: any;
}): import("react/jsx-runtime").JSX.Element;
declare namespace SAlertContentTmpl {
namespace propTypes {
const id: PropTypes.Validator<string>;
const classNames: PropTypes.Validator<string>;
const condition: PropTypes.Validator<string>;
const styles: PropTypes.Validator<object>;
const message: PropTypes.Validator<NonNullable<NonNullable<string | object | null | undefined>>>;
const handleClose: PropTypes.Validator<(...args: any[]) => any>;
}
}
import PropTypes from "prop-types";
18 changes: 18 additions & 0 deletions dist/components/include/SAlertContentTmpl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/* eslint-disable jsx-a11y/label-has-associated-control, jsx-a11y/control-has-associated-label */
import PropTypes from "prop-types";
import React from "react";
const SAlertContentTmpl = function SAlertContentTmpl({ id, classNames, condition, styles, message, handleClose, }) {
return (_jsxs("div", { id: id, style: styles, className: `alert alert-${condition} ${classNames} growl-animated animated`, children: [_jsx("button", { type: "button", "data-growl": "dismiss", className: "close s-alert-close", onClick: handleClose }), _jsx("span", { children: message })] }));
};
SAlertContentTmpl.propTypes = {
id: PropTypes.string.isRequired,
classNames: PropTypes.string.isRequired,
condition: PropTypes.string.isRequired,
// eslint-disable-next-line react/forbid-prop-types
styles: PropTypes.object.isRequired,
// eslint-disable-next-line react/forbid-prop-types
message: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
handleClose: PropTypes.func.isRequired,
};
export default SAlertContentTmpl;
20 changes: 20 additions & 0 deletions dist/components/include/StandataImportModal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MaterialSchema } from "@exabyte-io/code.js/dist/types";
import { Made } from "@exabyte-io/made.js";
import React from "react";
interface StandataImportModalProps {
show: boolean;
onClose: () => void;
onSubmit: (materials: Made.Material[]) => void;
defaultMaterialConfigs: MaterialSchema[];
}
interface StandataImportModalState {
selectedMaterialConfigs: MaterialSchema[];
}
declare class StandataImportModal extends React.Component<StandataImportModalProps, StandataImportModalState> {
constructor(props: StandataImportModalProps);
handleMaterialSelect: (materialConfigs: MaterialSchema[] | []) => void;
handleRemoveMaterial: (index: number) => void;
addMaterials: () => void;
render(): import("react/jsx-runtime").JSX.Element;
}
export default StandataImportModal;
84 changes: 84 additions & 0 deletions dist/components/include/StandataImportModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import Dialog from "@exabyte-io/cove.js/dist/mui/components/dialog/Dialog";
import IconByName from "@exabyte-io/cove.js/dist/mui/components/icon/IconByName";
import { Made } from "@exabyte-io/made.js";
import CheckBoxOutlineBlank from "@mui/icons-material/CheckBoxOutlineBlank";
import Autocomplete from "@mui/material/Autocomplete";
import Checkbox from "@mui/material/Checkbox";
import Grid from "@mui/material/Grid";
import IconButton from "@mui/material/IconButton";
import TextField from "@mui/material/TextField";
import { DataGrid } from "@mui/x-data-grid";
import React from "react";
class StandataImportModal extends React.Component {
constructor(props) {
super(props);
this.handleMaterialSelect = (materialConfigs) => {
this.setState({
selectedMaterialConfigs: [...materialConfigs],
});
};
this.handleRemoveMaterial = (index) => {
this.setState((prevState) => ({
selectedMaterialConfigs: prevState.selectedMaterialConfigs.filter((_, i) => i !== index),
}));
};
this.addMaterials = () => {
const { selectedMaterialConfigs } = this.state;
const materials = selectedMaterialConfigs.map((config) => new Made.Material(config));
const { onSubmit } = this.props;
onSubmit(materials);
this.setState({ selectedMaterialConfigs: [] });
};
this.state = {
selectedMaterialConfigs: [],
};
}
render() {
const { show, onClose, defaultMaterialConfigs } = this.props;
const { selectedMaterialConfigs } = this.state;
const selectedMaterials = selectedMaterialConfigs.map((config) => new Made.Material(config));
const columns = [
{ field: "name", headerName: "Name", flex: 1, headerAlign: "center", align: "center" },
{
field: "lattice",
headerName: "Lattice",
flex: 1,
headerAlign: "center",
align: "center",
},
{
field: "formula",
headerName: "Formula",
flex: 1,
headerAlign: "center",
align: "center",
},
{
field: "actions",
headerName: "Actions",
headerAlign: "center",
align: "center",
flex: 1,
sortable: false,
filterable: false,
disableColumnMenu: true,
renderCell: (params) => (_jsx(IconButton, { id: `${params.row.name.replace(/\s+/g, "-")}-remove-button`, color: "inherit", onClick: () => this.handleRemoveMaterial(params.row.id), children: _jsx(IconByName, { name: "actions.remove", fontSize: "small" }) })),
},
];
return (_jsx(Dialog, { open: show, id: "standataImportModalDialog", title: "Import from Standata", onClose: onClose, onSubmit: this.addMaterials, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsx(Grid, { item: true, xs: 12, children: _jsx(Autocomplete, { multiple: true, id: "materials-autocomplete", "data-tid": "materials-selector", disableCloseOnSelect: true, options: defaultMaterialConfigs || [], value: selectedMaterialConfigs || null, getOptionLabel: (material) => material.name || "Not available", onChange: (event, newValues) => this.handleMaterialSelect(newValues), renderOption: (props, option, { selected }) => (
// eslint-disable-next-line react/jsx-props-no-spreading
_jsxs("li", { ...props, "data-tid": "select-material", children: [_jsx(Checkbox, { icon: _jsx(CheckBoxOutlineBlank, { fontSize: "small" }), checkedIcon: _jsx(IconByName, { name: "shapes.check", fontSize: "small" }), checked: selected }), option.name] })), renderInput: (params) => (_jsx(TextField
// eslint-disable-next-line react/jsx-props-no-spreading
, { ...params, label: "Selected Materials", placeholder: "Select materials" })) }) }), _jsx(Grid, { item: true, xs: 12, style: { minHeight: 300 }, children: _jsx(DataGrid, { "data-name": "data-grid", hideFooter: true, rows: selectedMaterials.map((material, index) => {
var _a;
return ({
name: material.name,
lattice: ((_a = material.lattice) === null || _a === void 0 ? void 0 : _a.type) || "TRI",
formula: material.formula || "Not available",
id: index,
});
}), columns: columns }) })] }) }));
}
}
export default StandataImportModal;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { jsx as _jsx } from "react/jsx-runtime";
import JupyterLiteSession from "@exabyte-io/cove.js/dist/other/jupyterlite/JupyterLiteSession";
import { Action } from "@mat3ra/esse/dist/js/types";
import { Made } from "@mat3ra/made";
import { enqueueSnackbar } from "notistack";
import React from "react";
Expand Down Expand Up @@ -52,11 +53,11 @@ class BaseJupyterLiteSessionComponent extends React.Component {
// eslint-disable-next-line react/sort-comp
this.messageHandlerConfigs = [
{
action: "set-data",
action: Action.setData,
handlers: [this.handleSetMaterials],
},
{
action: "get-data",
action: Action.getData,
handlers: [this.getMaterialsForMessage],
},
];
Expand Down
2 changes: 2 additions & 0 deletions dist/components/include/material-ui/theme.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const DarkMaterialUITheme: import("@mui/material").Theme;
export const LightMaterialUITheme: import("@mui/material").Theme;
34 changes: 34 additions & 0 deletions dist/components/include/material-ui/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createTheme } from "@mui/material";
// adopted from: https://material-ui.com/customization/themes/#theme-configuration-variables
const DarkThemeConfig = {
palette: {
// Switching the dark mode on is a single property value change.
mode: "dark",
},
typography: {
// Tell Material-UI what's the font-size on the html element is.
htmlFontSize: 12,
},
overrides: {
MuiFormControl: {
root: {
margin: 10,
minWidth: 120,
},
},
MuiOutlinedInput: {
root: {
"& .MuiOutlinedInput-notchedOutline": {
border: "none",
},
},
},
},
};
export const DarkMaterialUITheme = createTheme(DarkThemeConfig);
export const LightMaterialUITheme = createTheme({
typography: DarkThemeConfig.typography,
palette: {
mode: "light",
},
});
8 changes: 4 additions & 4 deletions dist/material.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,21 @@ export class Material extends Material_base {
}, {
id?: number | undefined;
}] | undefined;
bondType?: "double" | "single" | "triple" | "quadruple" | "aromatic" | "tautomeric" | "dative" | "other" | undefined;
bondType?: "double" | "other" | "single" | "triple" | "quadruple" | "aromatic" | "tautomeric" | "dative" | undefined;
}[] | undefined;
};
lattice: {
name?: "lattice" | undefined;
vectors?: {
alat?: number | undefined;
units?: "m" | "alat" | "bohr" | "angstrom" | "crystal" | "km" | "pm" | "nm" | "a.u." | "fractional" | "cartesian" | undefined;
units?: "m" | "angstrom" | "crystal" | "km" | "pm" | "nm" | "a.u." | "bohr" | "fractional" | "cartesian" | "alat" | undefined;
a: [number, number, number];
b: [number, number, number];
c: [number, number, number];
} | undefined;
type: "CUB" | "BCC" | "FCC" | "TET" | "MCL" | "ORC" | "ORCC" | "ORCF" | "ORCI" | "HEX" | "BCT" | "TRI" | "MCLC" | "RHL";
units?: {
length?: "bohr" | "angstrom" | undefined;
length?: "angstrom" | "bohr" | undefined;
angle?: "degree" | "radian" | undefined;
} | undefined;
a: number;
Expand Down Expand Up @@ -333,7 +333,7 @@ export class Material extends Material_base {
consistencyChecks?: {
key: string;
name: "default" | "atomsTooClose" | "atomsOverlap";
severity: "info" | "warning" | "error";
severity: "error" | "warning" | "info";
message: string;
}[] | undefined;
schemaVersion?: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _material_designer_page = require("../widgets/material_designer_page");
function _default() {
this.Then(/^I see UploadDialog$/, () => {
_material_designer_page.materialDesignerPage.designerWidget.defaultImportModalDialog.isVisible();
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _material_designer_page = require("../widgets/material_designer_page");
function _default() {
this.Then(/^the UploadDialog should be closed$/, () => {
_material_designer_page.materialDesignerPage.designerWidget.defaultImportModalDialog.waitForDisappear();
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _material_designer_page = require("../widgets/material_designer_page");
function _default() {
this.When(/^I open UploadDialog/, () => {
_material_designer_page.materialDesignerPage.designerWidget.headerMenu.selectMenuItemByNameAndItemNumber("Input/Output", 1);
});
}
35 changes: 35 additions & 0 deletions dist/tests-legacy/cucumber/support/widgets/alert/s_alert_widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SAlertWidget = void 0;
var _logger = require("../../logger");
var _selectors = require("../../selectors");
var _utils = require("../../utils");
var _alert_widget = require("./alert_widget");
class SAlertWidget extends _alert_widget.AlertWidget {
getAlertSelectorByType(type) {
return this.getWrappedSelector(_selectors.SELECTORS.sAlertWidget.alertByType(type), "");
}
isVisibleByType(type) {
return exabrowser.isVisible(this.getAlertSelectorByType(type));
}
isVisibleSuccess() {
return this.isVisibleByType("success");
}
close() {
exabrowser.scrollAndClick(this.getWrappedSelector(_selectors.SELECTORS.sAlertWidget.closeButton));
}
closeAllSuccess() {
(0, _utils.retry)(() => {
if (this.isVisible()) {
_logger.logger.debug("sAlertSuccess closed");
this.close();
// eslint-disable-next-line no-throw-literal
throw "Something is wrong: there should be no sAlertSuccess shown!";
}
});
}
}
exports.SAlertWidget = SAlertWidget;
Loading

0 comments on commit c67bf42

Please sign in to comment.