From 4b34682e99522038136cb0ac05ece27e69b46b3f Mon Sep 17 00:00:00 2001 From: tschumpr Date: Mon, 29 Jan 2024 08:33:13 +0100 Subject: [PATCH 1/4] Move alert to components folder --- src/client/src/App.js | 4 +- .../src/commons/feedback/feedbackComponent.js | 2 +- .../files/table/editorBoreholeFilesTable.js | 2 +- .../src/commons/form/borehole/boreholeForm.js | 2 +- .../hydrogeology/fieldMeasurementInput.js | 2 +- .../groundwaterLevelMeasurementInput.js | 2 +- .../borehole/hydrogeology/hydrotestInput.js | 2 +- .../hydrogeology/hydrotestResultTable.js | 2 +- .../hydrogeology/waterIngressInput.js | 2 +- .../borehole/segments/indentifierSegment.js | 2 +- .../profileAttributes/profileAttributes.js | 2 +- .../components/profileInfo/profileInfo.js | 2 +- .../components/instrument/Instrument.js | 2 +- .../profileLayersError/profileLayersError.js | 2 +- .../profileLayersList/profileLayersList.js | 2 +- .../components/profileLayers/profileLayers.js | 2 +- .../src/commons/form/workflow/workflowForm.js | 2 +- .../commons/menu/editor/menuEditorSearch.js | 2 +- src/client/src/commons/prompt/prompt.js | 50 ------------------- .../src/commons/table/boreholeEditorTable.js | 2 +- .../alert/alertBanner.js | 0 .../alert/alertContext.js | 0 .../src/pages/settings/admin/adminSettings.js | 2 +- .../editorSettingList/mapSettings.js | 2 +- .../settings/editor/identifierSettings.js | 2 +- .../src/pages/settings/explorerSettings.js | 2 +- src/client/src/pages/settings/loginScreen.js | 2 +- 27 files changed, 25 insertions(+), 75 deletions(-) delete mode 100644 src/client/src/commons/prompt/prompt.js rename src/client/src/{commons => components}/alert/alertBanner.js (100%) rename src/client/src/{commons => components}/alert/alertContext.js (100%) diff --git a/src/client/src/App.js b/src/client/src/App.js index 786ee8bb5..1b0c7def3 100644 --- a/src/client/src/App.js +++ b/src/client/src/App.js @@ -14,8 +14,8 @@ import EditorComponent from "./pages/editor/editorComponent"; import SettingCmp from "./pages/settings/settingCmp"; import DataLoader from "./pages/settings/dataLoader"; import AcceptTerms from "./pages/term/accept"; -import { AlertProvider } from "./commons/alert/alertContext"; -import { AlertBanner } from "./commons/alert/alertBanner"; +import { AlertProvider } from "./components/alert/alertContext"; +import { AlertBanner } from "./components/alert/alertBanner"; const queryClient = new QueryClient(); diff --git a/src/client/src/commons/feedback/feedbackComponent.js b/src/client/src/commons/feedback/feedbackComponent.js index 79d97ed34..eee4cb52e 100644 --- a/src/client/src/commons/feedback/feedbackComponent.js +++ b/src/client/src/commons/feedback/feedbackComponent.js @@ -4,7 +4,7 @@ import { connect } from "react-redux"; import { withTranslation } from "react-i18next"; import { Form, Button } from "semantic-ui-react"; -import { AlertContext } from "../alert/alertContext"; +import { AlertContext } from "../../components/alert/alertContext"; import { createFeedback } from "../../api-lib/index"; class Feedback extends React.Component { diff --git a/src/client/src/commons/files/table/editorBoreholeFilesTable.js b/src/client/src/commons/files/table/editorBoreholeFilesTable.js index 2f68e11ff..8d33fc882 100644 --- a/src/client/src/commons/files/table/editorBoreholeFilesTable.js +++ b/src/client/src/commons/files/table/editorBoreholeFilesTable.js @@ -11,7 +11,7 @@ import { import FilesTableComponent from "./filesTableComponent"; import TranslationText from "../../form/translationText"; import { Button } from "semantic-ui-react"; -import { AlertContext } from "../../alert/alertContext"; +import { AlertContext } from "../../../components/alert/alertContext"; import { withTranslation } from "react-i18next"; class EditorBoreholeFilesTable extends Component { diff --git a/src/client/src/commons/form/borehole/boreholeForm.js b/src/client/src/commons/form/borehole/boreholeForm.js index 8a11c3010..d1a59f520 100644 --- a/src/client/src/commons/form/borehole/boreholeForm.js +++ b/src/client/src/commons/form/borehole/boreholeForm.js @@ -24,7 +24,7 @@ import LocationSegment from "./segments/locationSegment"; import WaterIngress from "./hydrogeology/waterIngress"; import GroundwaterLevelMeasurement from "./hydrogeology/groundwaterLevelMeasurement"; import Hydrotest from "./hydrogeology/hydrotest"; -import { AlertContext } from "../../alert/alertContext"; +import { AlertContext } from "../../../components/alert/alertContext"; import FieldMeasurement from "./hydrogeology/fieldMeasurement"; import ChronostratigraphyPanel from "./stratigraphy/chronostratigraphyPanel"; import LithostratigraphyPanel from "./stratigraphy/lithostratigraphyPanel"; diff --git a/src/client/src/commons/form/borehole/hydrogeology/fieldMeasurementInput.js b/src/client/src/commons/form/borehole/hydrogeology/fieldMeasurementInput.js index 3249661e6..6db656db6 100644 --- a/src/client/src/commons/form/borehole/hydrogeology/fieldMeasurementInput.js +++ b/src/client/src/commons/form/borehole/hydrogeology/fieldMeasurementInput.js @@ -13,7 +13,7 @@ import { import { useDomains } from "../../../../api/fetchApiV2"; import CheckIcon from "@mui/icons-material/Check"; import { useTranslation } from "react-i18next"; -import { AlertContext } from "../../../alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import ObservationInput from "./observationInput"; import { ObservationType } from "./observationType"; import { hydrogeologySchemaConstants } from "./hydrogeologySchemaConstants"; diff --git a/src/client/src/commons/form/borehole/hydrogeology/groundwaterLevelMeasurementInput.js b/src/client/src/commons/form/borehole/hydrogeology/groundwaterLevelMeasurementInput.js index 5b041387b..3b57b7fd8 100644 --- a/src/client/src/commons/form/borehole/hydrogeology/groundwaterLevelMeasurementInput.js +++ b/src/client/src/commons/form/borehole/hydrogeology/groundwaterLevelMeasurementInput.js @@ -12,7 +12,7 @@ import { import { useDomains } from "../../../../api/fetchApiV2"; import CheckIcon from "@mui/icons-material/Check"; import { useTranslation } from "react-i18next"; -import { AlertContext } from "../../../alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import ObservationInput from "./observationInput"; import { ObservationType } from "./observationType"; import { hydrogeologySchemaConstants } from "./hydrogeologySchemaConstants"; diff --git a/src/client/src/commons/form/borehole/hydrogeology/hydrotestInput.js b/src/client/src/commons/form/borehole/hydrogeology/hydrotestInput.js index a83b917df..8eeb32f10 100644 --- a/src/client/src/commons/form/borehole/hydrogeology/hydrotestInput.js +++ b/src/client/src/commons/form/borehole/hydrogeology/hydrotestInput.js @@ -19,7 +19,7 @@ import AddCircleIcon from "@mui/icons-material/AddCircle"; import CancelIcon from "@mui/icons-material/Cancel"; import { useTranslation } from "react-i18next"; import { useHydrotestDomains, useDomains } from "../../../../api/fetchApiV2"; -import { AlertContext } from "../../../alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import { ObservationType } from "./observationType"; import { hydrogeologySchemaConstants } from "./hydrogeologySchemaConstants"; diff --git a/src/client/src/commons/form/borehole/hydrogeology/hydrotestResultTable.js b/src/client/src/commons/form/borehole/hydrogeology/hydrotestResultTable.js index d24d75be7..9d2bf0f68 100644 --- a/src/client/src/commons/form/borehole/hydrogeology/hydrotestResultTable.js +++ b/src/client/src/commons/form/borehole/hydrogeology/hydrotestResultTable.js @@ -18,7 +18,7 @@ import DeleteIcon from "@mui/icons-material/Delete"; import CheckIcon from "@mui/icons-material/Check"; import { useDomains } from "../../../../api/fetchApiV2"; import { TestResultParameterUnits } from "./parameterUnits"; -import { AlertContext } from "../../../alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import { hydrogeologySchemaConstants } from "./hydrogeologySchemaConstants"; const HydrotestResultTable = ({ diff --git a/src/client/src/commons/form/borehole/hydrogeology/waterIngressInput.js b/src/client/src/commons/form/borehole/hydrogeology/waterIngressInput.js index 77d95c8fa..18eafc43c 100644 --- a/src/client/src/commons/form/borehole/hydrogeology/waterIngressInput.js +++ b/src/client/src/commons/form/borehole/hydrogeology/waterIngressInput.js @@ -12,7 +12,7 @@ import { import { useDomains } from "../../../../api/fetchApiV2"; import CheckIcon from "@mui/icons-material/Check"; import { useTranslation } from "react-i18next"; -import { AlertContext } from "../../../alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import ObservationInput from "./observationInput"; import { ObservationType } from "./observationType"; import { hydrogeologySchemaConstants } from "./hydrogeologySchemaConstants"; diff --git a/src/client/src/commons/form/borehole/segments/indentifierSegment.js b/src/client/src/commons/form/borehole/segments/indentifierSegment.js index d8a1d88ed..a5af2f665 100644 --- a/src/client/src/commons/form/borehole/segments/indentifierSegment.js +++ b/src/client/src/commons/form/borehole/segments/indentifierSegment.js @@ -4,7 +4,7 @@ import _ from "lodash"; import DomainDropdown from "../../domain/dropdown/domainDropdown"; import DomainText from "../../domain/domainText"; import TranslationText from "../../translationText"; -import { AlertContext } from "../../../alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import { Form, Icon, Input, Segment } from "semantic-ui-react"; import { removeIdentifier, addIdentifier } from "../../../../api-lib"; import { useTranslation } from "react-i18next"; diff --git a/src/client/src/commons/form/profile/components/profileAttributes/profileAttributes.js b/src/client/src/commons/form/profile/components/profileAttributes/profileAttributes.js index 9dce30709..39be4b1d2 100644 --- a/src/client/src/commons/form/profile/components/profileAttributes/profileAttributes.js +++ b/src/client/src/commons/form/profile/components/profileAttributes/profileAttributes.js @@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next"; import ProfileAttributeList from "./components/profileAttributeList/profileAttributeList"; import { useSelector } from "react-redux"; import { useQueryClient } from "react-query"; -import { AlertContext } from "../../../../alert/alertContext"; +import { AlertContext } from "../../../../../components/alert/alertContext"; import { fetchLayerById, layerQueryKey, diff --git a/src/client/src/commons/form/profile/components/profileInfo/profileInfo.js b/src/client/src/commons/form/profile/components/profileInfo/profileInfo.js index 3750af10a..d98f58922 100644 --- a/src/client/src/commons/form/profile/components/profileInfo/profileInfo.js +++ b/src/client/src/commons/form/profile/components/profileInfo/profileInfo.js @@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next"; import { getData, sendProfile } from "./api"; import _ from "lodash"; import useCasingList from "../../hooks/useCasingList"; -import { AlertContext } from "../../../../alert/alertContext"; +import { AlertContext } from "../../../../../components/alert/alertContext"; const ProfileInfo = props => { const { diff --git a/src/client/src/commons/form/profile/components/profileInstrument/components/instrument/Instrument.js b/src/client/src/commons/form/profile/components/profileInstrument/components/instrument/Instrument.js index 9f862d15b..21dfdfcc3 100644 --- a/src/client/src/commons/form/profile/components/profileInstrument/components/instrument/Instrument.js +++ b/src/client/src/commons/form/profile/components/profileInstrument/components/instrument/Instrument.js @@ -13,7 +13,7 @@ import { } from "../../../../../../../api/fetchApiV2"; import { NumericFormat } from "react-number-format"; import { parseIfString } from "../../../../../formUtils"; -import { AlertContext } from "../../../../../../alert/alertContext"; +import { AlertContext } from "../../../../../../../components/alert/alertContext"; import { produce } from "immer"; const Instrument = props => { diff --git a/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersError/profileLayersError.js b/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersError/profileLayersError.js index a416d426a..0600ec5f6 100644 --- a/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersError/profileLayersError.js +++ b/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersError/profileLayersError.js @@ -8,7 +8,7 @@ import { addBedrock, } from "../../../../../../../api/fetchApiV2"; import ErrorTypes from "./errorTypes"; -import { AlertContext } from "../../../../../../alert/alertContext"; +import { AlertContext } from "../../../../../../../components/alert/alertContext"; const ProfileLayersError = props => { const { diff --git a/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersList/profileLayersList.js b/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersList/profileLayersList.js index 047149e06..43c472608 100644 --- a/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersList/profileLayersList.js +++ b/src/client/src/commons/form/profile/components/profileLayers/components/profileLayersList/profileLayersList.js @@ -15,7 +15,7 @@ import { NumericFormat } from "react-number-format"; import { withTranslation } from "react-i18next"; import * as Styled from "./styles"; import { deleteLayer } from "../../../../../../../api-lib"; -import { AlertContext } from "../../../../../../alert/alertContext"; +import { AlertContext } from "../../../../../../../components/alert/alertContext"; import { useLithostratigraphies } from "../../../../../../../api/fetchApiV2"; const ProfileLayersList = props => { diff --git a/src/client/src/commons/form/profile/components/profileLayers/profileLayers.js b/src/client/src/commons/form/profile/components/profileLayers/profileLayers.js index 05a980b9c..731b3c8aa 100644 --- a/src/client/src/commons/form/profile/components/profileLayers/profileLayers.js +++ b/src/client/src/commons/form/profile/components/profileLayers/profileLayers.js @@ -40,7 +40,7 @@ import { import AddCircleIcon from "@mui/icons-material/AddCircle"; import { withTranslation } from "react-i18next"; import { useMutation, useQueryClient } from "react-query"; -import { AlertContext } from "../../../../alert/alertContext"; +import { AlertContext } from "../../../../../components/alert/alertContext"; import { profileKind } from "../../constance"; const ProfileLayers = props => { diff --git a/src/client/src/commons/form/workflow/workflowForm.js b/src/client/src/commons/form/workflow/workflowForm.js index 9baf5b699..85b171b53 100644 --- a/src/client/src/commons/form/workflow/workflowForm.js +++ b/src/client/src/commons/form/workflow/workflowForm.js @@ -24,7 +24,7 @@ import { rejectWorkflow, resetWorkflow, } from "../../../api-lib/index"; -import { AlertContext } from "../../alert/alertContext"; +import { AlertContext } from "../../../components/alert/alertContext"; import CommentArea from "./commentArea"; import DateText from "../dateText"; import TranslationText from "../../form/translationText"; diff --git a/src/client/src/commons/menu/editor/menuEditorSearch.js b/src/client/src/commons/menu/editor/menuEditorSearch.js index 3f5895ea1..5f96ae3e7 100644 --- a/src/client/src/commons/menu/editor/menuEditorSearch.js +++ b/src/client/src/commons/menu/editor/menuEditorSearch.js @@ -11,7 +11,7 @@ import { Box, Stack, MenuItem, Select, FormControl } from "@mui/material/"; import { Button, Header, Icon, Menu, Modal, Segment } from "semantic-ui-react"; import { createBorehole } from "../../../api-lib/index"; -import { AlertContext } from "../../alert/alertContext"; +import { AlertContext } from "../../../components/alert/alertContext"; import SearchEditorComponent from "../../search/editor/searchEditorComponent"; import { downloadCodelistCsv, importBoreholes } from "../../../api/fetchApiV2"; import Downloadlink from "../../files/downloadlink"; diff --git a/src/client/src/commons/prompt/prompt.js b/src/client/src/commons/prompt/prompt.js deleted file mode 100644 index 4b058ed28..000000000 --- a/src/client/src/commons/prompt/prompt.js +++ /dev/null @@ -1,50 +0,0 @@ -import React from "react"; -import { useTranslation } from "react-i18next"; -import { - Button, - Dialog, - DialogActions, - DialogContent, - DialogContentText, - DialogTitle, -} from "@mui/material"; -import { styled } from "@mui/system"; - -export const PromptButton = styled(Button)({ - fontFamily: "Lato", - textTransform: "none", - color: "rgba(0, 0, 0, 0.8)", - "&:hover": { - backgroundColor: "rgba(0, 0, 0, 0.05)", - }, -}); - -const Prompt = props => { - const { open, setOpen, titleLabel, messageLabel, actions } = props; - const { t } = useTranslation(); - return ( - - {t(titleLabel)} - - {t(messageLabel)} - - - {actions?.map((action, index) => ( - { - if (action.action != null) { - action.action(); - } - setOpen(false); - }} - data-cy={"prompt-button-" + action.label}> - {t(action.label)} - - ))} - - - ); -}; - -export default Prompt; diff --git a/src/client/src/commons/table/boreholeEditorTable.js b/src/client/src/commons/table/boreholeEditorTable.js index 5193387e5..7d18b6660 100644 --- a/src/client/src/commons/table/boreholeEditorTable.js +++ b/src/client/src/commons/table/boreholeEditorTable.js @@ -27,7 +27,7 @@ import { getdBoreholeIds, deleteBoreholes, } from "../../api-lib/index"; -import { AlertContext } from "../alert/alertContext"; +import { AlertContext } from "../../components/alert/alertContext"; class BoreholeEditorTable extends TTable { static contextType = AlertContext; diff --git a/src/client/src/commons/alert/alertBanner.js b/src/client/src/components/alert/alertBanner.js similarity index 100% rename from src/client/src/commons/alert/alertBanner.js rename to src/client/src/components/alert/alertBanner.js diff --git a/src/client/src/commons/alert/alertContext.js b/src/client/src/components/alert/alertContext.js similarity index 100% rename from src/client/src/commons/alert/alertContext.js rename to src/client/src/components/alert/alertContext.js diff --git a/src/client/src/pages/settings/admin/adminSettings.js b/src/client/src/pages/settings/admin/adminSettings.js index 6efb5ad5a..11292e70b 100644 --- a/src/client/src/pages/settings/admin/adminSettings.js +++ b/src/client/src/pages/settings/admin/adminSettings.js @@ -2,7 +2,7 @@ import React from "react"; import { connect } from "react-redux"; import PropTypes from "prop-types"; import { withTranslation } from "react-i18next"; -import { AlertContext } from "../../../commons/alert/alertContext"; +import { AlertContext } from "../../../components/alert/alertContext"; import { fetchUsers } from "../../../api/fetchApiV2"; import { diff --git a/src/client/src/pages/settings/components/editorSettingList/mapSettings.js b/src/client/src/pages/settings/components/editorSettingList/mapSettings.js index 1d64ccf62..ef3542483 100644 --- a/src/client/src/pages/settings/components/editorSettingList/mapSettings.js +++ b/src/client/src/pages/settings/components/editorSettingList/mapSettings.js @@ -13,7 +13,7 @@ import { Segment, } from "semantic-ui-react"; import { getWms } from "../../../../api-lib/index"; -import { AlertContext } from "../../../../commons/alert/alertContext"; +import { AlertContext } from "../../../../components/alert/alertContext"; import TranslationText from "../../../../commons/form/translationText"; import WMTSCapabilities from "ol/format/WMTSCapabilities"; import WMSCapabilities from "ol/format/WMSCapabilities"; diff --git a/src/client/src/pages/settings/editor/identifierSettings.js b/src/client/src/pages/settings/editor/identifierSettings.js index 3ffec6a0b..43ee6ac99 100644 --- a/src/client/src/pages/settings/editor/identifierSettings.js +++ b/src/client/src/pages/settings/editor/identifierSettings.js @@ -2,7 +2,7 @@ import React from "react"; import { connect } from "react-redux"; import PropTypes from "prop-types"; import { withTranslation } from "react-i18next"; -import { AlertContext } from "../../../commons/alert/alertContext"; +import { AlertContext } from "../../../components/alert/alertContext"; import { Button, Icon, Form, Modal, Header } from "semantic-ui-react"; diff --git a/src/client/src/pages/settings/explorerSettings.js b/src/client/src/pages/settings/explorerSettings.js index ad7d13612..c1cabe588 100644 --- a/src/client/src/pages/settings/explorerSettings.js +++ b/src/client/src/pages/settings/explorerSettings.js @@ -17,7 +17,7 @@ import { fillingEditorData } from "./data/fillingEditorData"; import { lithologyFieldEditorData } from "./data/lithologyFieldEditorData"; import EditorSettingList from "./components/editorSettingList/editorSettingList"; import MapSettings from "./components/editorSettingList/mapSettings"; -import { AlertContext } from "../../commons/alert/alertContext"; +import { AlertContext } from "../../components/alert/alertContext"; const projections = { "EPSG:21781": diff --git a/src/client/src/pages/settings/loginScreen.js b/src/client/src/pages/settings/loginScreen.js index 35f5a2c44..d3e1e2417 100644 --- a/src/client/src/pages/settings/loginScreen.js +++ b/src/client/src/pages/settings/loginScreen.js @@ -3,7 +3,7 @@ import { connect } from "react-redux"; import PropTypes from "prop-types"; import { withTranslation } from "react-i18next"; import { Button, Form, Modal, TextArea } from "semantic-ui-react"; -import { AlertContext } from "../../commons/alert/alertContext"; +import { AlertContext } from "../../components/alert/alertContext"; import LoginPreview from "../../commons/form/loginPreview"; import TranslationKeys from "../../commons/translationKeys"; From 8bddf600ed9feb3dff5048d6e3dcf70164c6c13e Mon Sep 17 00:00:00 2001 From: tschumpr Date: Mon, 29 Jan 2024 08:33:24 +0100 Subject: [PATCH 2/4] Move prompt to components folder --- .../form/borehole/completion/completion.js | 2 +- .../completion/completionHeaderInput.js | 2 +- src/client/src/components/prompt/prompt.js | 50 +++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/client/src/components/prompt/prompt.js diff --git a/src/client/src/commons/form/borehole/completion/completion.js b/src/client/src/commons/form/borehole/completion/completion.js index 93d520519..e1d15d0be 100644 --- a/src/client/src/commons/form/borehole/completion/completion.js +++ b/src/client/src/commons/form/borehole/completion/completion.js @@ -17,7 +17,7 @@ import { import CompletionContent from "./completionContent"; import CompletionHeaderInput from "./completionHeaderInput"; import CompletionHeaderDisplay from "./completionHeaderDisplay"; -import Prompt from "../../../prompt/prompt"; +import Prompt from "../../../../components/prompt/prompt"; const Completion = props => { const { isEditable, boreholeId } = props; diff --git a/src/client/src/commons/form/borehole/completion/completionHeaderInput.js b/src/client/src/commons/form/borehole/completion/completionHeaderInput.js index 616d6b059..5fb839b23 100644 --- a/src/client/src/commons/form/borehole/completion/completionHeaderInput.js +++ b/src/client/src/commons/form/borehole/completion/completionHeaderInput.js @@ -11,7 +11,7 @@ import { FormSelect, FormCheckbox, } from "../../../../components/form/form"; -import Prompt from "../../../prompt/prompt"; +import Prompt from "../../../../components/prompt/prompt"; const CompletionHeaderInput = props => { const { diff --git a/src/client/src/components/prompt/prompt.js b/src/client/src/components/prompt/prompt.js new file mode 100644 index 000000000..4b058ed28 --- /dev/null +++ b/src/client/src/components/prompt/prompt.js @@ -0,0 +1,50 @@ +import React from "react"; +import { useTranslation } from "react-i18next"; +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, +} from "@mui/material"; +import { styled } from "@mui/system"; + +export const PromptButton = styled(Button)({ + fontFamily: "Lato", + textTransform: "none", + color: "rgba(0, 0, 0, 0.8)", + "&:hover": { + backgroundColor: "rgba(0, 0, 0, 0.05)", + }, +}); + +const Prompt = props => { + const { open, setOpen, titleLabel, messageLabel, actions } = props; + const { t } = useTranslation(); + return ( + + {t(titleLabel)} + + {t(messageLabel)} + + + {actions?.map((action, index) => ( + { + if (action.action != null) { + action.action(); + } + setOpen(false); + }} + data-cy={"prompt-button-" + action.label}> + {t(action.label)} + + ))} + + + ); +}; + +export default Prompt; From b2aee992f4ab6c304dc8bd89b40a0fd4618d2b91 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Mon, 29 Jan 2024 08:38:43 +0100 Subject: [PATCH 3/4] Increase font size for better readability --- src/client/src/components/prompt/prompt.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/src/components/prompt/prompt.js b/src/client/src/components/prompt/prompt.js index 4b058ed28..0c847af7c 100644 --- a/src/client/src/components/prompt/prompt.js +++ b/src/client/src/components/prompt/prompt.js @@ -12,6 +12,7 @@ import { styled } from "@mui/system"; export const PromptButton = styled(Button)({ fontFamily: "Lato", + fontSize: "16px", textTransform: "none", color: "rgba(0, 0, 0, 0.8)", "&:hover": { From 908a1243785263e2e17e00d3432263ea305d3971 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Mon, 29 Jan 2024 08:43:48 +0100 Subject: [PATCH 4/4] Move prompt handler to helper --- src/client/cypress/e2e/editor/completion-v2.cy.js | 7 +------ src/client/cypress/e2e/helpers/testHelpers.js | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/client/cypress/e2e/editor/completion-v2.cy.js b/src/client/cypress/e2e/editor/completion-v2.cy.js index dddd460fc..61250561a 100644 --- a/src/client/cypress/e2e/editor/completion-v2.cy.js +++ b/src/client/cypress/e2e/editor/completion-v2.cy.js @@ -2,6 +2,7 @@ import { createBorehole, startBoreholeEditing, loginAsAdmin, + handlePrompt, } from "../helpers/testHelpers"; import { setInput, @@ -58,12 +59,6 @@ const isTabSelected = index => { .should("eq", "true"); }; -const handlePrompt = (title, action) => { - cy.get('[data-cy="prompt"]').should("exist"); - cy.contains(title); - cy.get('[data-cy="prompt-button-' + action + '"]').click(); -}; - describe("completion crud tests", () => { it("add, edit, copy and delete completions", () => { createBorehole({ "extended.original_name": "INTEADAL" }).as("borehole_id"); diff --git a/src/client/cypress/e2e/helpers/testHelpers.js b/src/client/cypress/e2e/helpers/testHelpers.js index fc2d33132..9b05c8288 100644 --- a/src/client/cypress/e2e/helpers/testHelpers.js +++ b/src/client/cypress/e2e/helpers/testHelpers.js @@ -366,3 +366,9 @@ export const createStratigraphy = (boreholeId, kindId) => { }); }); }; + +export const handlePrompt = (title, action) => { + cy.get('[data-cy="prompt"]').should("exist"); + cy.contains(title); + cy.get('[data-cy="prompt-button-' + action + '"]').click(); +};