Skip to content
Open
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
5 changes: 2 additions & 3 deletions demo/src/InputsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import {
SelectInput,
CheckboxInput,
SwitchInput,
SubmitButton,
ExpandingTextField,
CustomFormProvider,
SelectClearable,
SelectClearable, ValidateButton,
} from '../../src';

const AUTOCOMPLETE_INPUT = 'autocomplete';
Expand Down Expand Up @@ -174,7 +173,7 @@ function InputsTab() {
backgroundColor: 'pink',
}}
>
<SubmitButton onClick={handleSubmit(onSubmit, onError)} />
<ValidateButton onClick={handleSubmit(onSubmit, onError)} />
</Box>
</Box>
</CustomFormProvider>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@ag-grid-community/locale": "^33.3.2",
"@design-system-rte/react": "^1.0.0",
"@hello-pangea/dnd": "^18.0.1",
"@material-symbols/svg-400": "^0.31.9",
"@react-querybuilder/dnd": "^8.11.0",
Expand Down
17 changes: 9 additions & 8 deletions src/components/authentication/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Avatar, Box, Button, Container, Link, Typography } from '@mui/material';
import { Avatar, Box, Container, Link, Typography } from '@mui/material';
import { LockOutlined as LockOutlinedIcon } from '@mui/icons-material';
import { FormattedMessage } from 'react-intl';
import { Button } from '@design-system-rte/react';
import { FormattedMessage, useIntl } from 'react-intl';
import type { MuiStyles } from '../../utils/styles';
import {useIntlRef} from "../../hooks";

const styles = {
paper: (theme) => ({
Expand Down Expand Up @@ -36,6 +38,8 @@ export interface LoginProps {
}

export function Login({ onLoginClick, disabled }: LoginProps) {
const intl = useIntl();

return (
<Container component="main" maxWidth="xs">
<Box sx={styles.paper}>
Expand All @@ -49,13 +53,10 @@ export function Login({ onLoginClick, disabled }: LoginProps) {
<Button
data-testid="LoginButton"
disabled={disabled}
fullWidth
variant="contained"
sx={styles.submit}
variant="primary"
onClick={onLoginClick}
>
<FormattedMessage id="login/connection" defaultMessage="connection" />
</Button>
label={intl.formatMessage({ id: 'login/connection' })}
/>
</Box>
<Box mt={2}>
<Typography variant="body2" color="textSecondary" align="center">
Expand Down
19 changes: 10 additions & 9 deletions src/components/authentication/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Avatar, Box, Button, Container, Link, Typography } from '@mui/material';
import { Avatar, Box, Container, Link, Typography } from '@mui/material';
import { LogoutOutlined as LogoutOutlinedIcon } from '@mui/icons-material';
import { FormattedMessage } from 'react-intl';
import { Button } from '@design-system-rte/react';
import { FormattedMessage, useIntl } from 'react-intl';
import type { MuiStyles } from '../../utils/styles';

const styles = {
Expand All @@ -21,10 +22,6 @@ const styles = {
margin: theme.spacing(1),
backgroundColor: theme.palette.error.main,
}),
submit: (theme) => ({
margin: theme.spacing(3, 0, 2),
borderRadius: '30px',
}),
} as const satisfies MuiStyles;

export interface LogoutProps {
Expand All @@ -46,6 +43,7 @@ function Copyright() {
}

export function Logout({ onLogoutClick, disabled }: LogoutProps) {
const intl = useIntl();
return (
<Container component="main" maxWidth="xs">
<Box sx={styles.paper}>
Expand All @@ -56,9 +54,12 @@ export function Logout({ onLogoutClick, disabled }: LogoutProps) {
<FormattedMessage id="login/logout" defaultMessage="logout" /> ?
</Typography>

<Button disabled={disabled} fullWidth variant="contained" sx={styles.submit} onClick={onLogoutClick}>
<FormattedMessage id="login/logout" defaultMessage="logout" />
</Button>
<Button
label={intl.formatMessage({ id: 'login/logout' })}
disabled={disabled}
variant="primary"
onClick={onLogoutClick}
/>
</Box>
<Box mt={2}>
<Copyright />
Expand Down
48 changes: 22 additions & 26 deletions src/components/dialogs/customMuiDialog/CustomMuiDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

import { type MouseEvent, type ReactNode, useCallback, useState } from 'react';
import { FieldErrors, FieldValues, SubmitHandler, UseFormReturn } from 'react-hook-form';
import { FormattedMessage } from 'react-intl';
import { Dialog, DialogActions, DialogContent, DialogProps, DialogTitle, LinearProgress } from '@mui/material';
import { FormattedMessage, useIntl } from 'react-intl';
import { DialogActions, DialogContent, DialogProps, DialogTitle, LinearProgress } from '@mui/material';
import { type ObjectSchema } from 'yup';
import { SubmitButton } from '../../inputs/reactHookForm/utils/SubmitButton';
import { CancelButton } from '../../inputs/reactHookForm/utils/CancelButton';
import { CustomFormProvider } from '../../inputs/reactHookForm/provider/CustomFormProvider';
import { PopupConfirmationDialog } from '../popupConfirmationDialog/PopupConfirmationDialog';
import { GsLang } from '../../../utils';
import type { MuiStyles } from '../../../utils/styles';
import { ValidateButton } from '../../inputs';
import { Modal } from '@design-system-rte/react';

export type CustomMuiDialogProps<T extends FieldValues = FieldValues> = DialogProps & {
open: boolean;
Expand Down Expand Up @@ -148,6 +149,7 @@ export function CustomMuiDialog<T extends FieldValues = FieldValues>({
},
[onValidationError]
);
const intl = useIntl();

return (
<CustomFormProvider<T>
Expand All @@ -156,33 +158,27 @@ export function CustomMuiDialog<T extends FieldValues = FieldValues>({
removeOptional={removeOptional}
language={language}
>
<Dialog
sx={unscrollableFullHeight ? unscrollableDialogStyles.fullHeightDialog : styles.dialogPaper}
open={open}
onClose={handleClose}
fullWidth
{...dialogProps}
>
{isDataFetching && <LinearProgress />}
<DialogTitle data-testid="DialogTitle">
<FormattedMessage id={titleId} />
</DialogTitle>
<DialogContent sx={unscrollableFullHeight ? unscrollableDialogStyles.unscrollableContainer : null}>
{children}
</DialogContent>
<DialogActions>
<CancelButton onClick={handleCancel} data-testid="CancelButton" />
<SubmitButton
variant="outlined"
disabled={disabledSave}
<Modal
id="DialogTitle"
data-testid="DialogTitle"
title={intl.formatMessage({ id: titleId })}
isOpen={open}
onClose={onClose}
primaryButton={
<ValidateButton
disabled={!formMethods.formState.isDirty || disabledSave}
onClick={handleSubmit(handleValidate, handleValidationError)}
data-testid="ValidateButton"
/>
</DialogActions>
</Dialog>
}
secondaryButton={<CancelButton onClick={handleCancel} />}
size="l"
closeOnOverlayClick={false}
>
{children}
</Modal>
{confirmationMessageKey && (
<PopupConfirmationDialog
message={confirmationMessageKey}
descriptionKey={confirmationMessageKey}
openConfirmationPopup={openConfirmationPopup}
setOpenConfirmationPopup={setOpenConfirmationPopup}
handlePopupConfirmation={handlePopupConfirmation}
Expand Down
77 changes: 52 additions & 25 deletions src/components/dialogs/elementSaveDialog/ElementSaveDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { FormattedMessage, useIntl } from 'react-intl';
import { useIntl } from 'react-intl';
import type { UUID } from 'node:crypto';
import { useCallback, useEffect, useState } from 'react';
import { Grid, Box, Button, CircularProgress, Typography } from '@mui/material';
import { Box, CircularProgress, Grid, Typography } from '@mui/material';
import { Button, Grid as GridDS } from '@design-system-rte/react';
import { SubmitHandler, useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import yup from '../../../utils/yupConfig';
Expand All @@ -19,6 +20,7 @@ import { CustomMuiDialog } from '../customMuiDialog/CustomMuiDialog';
import { ElementAttributes, ElementType, FieldConstants, MAX_CHAR_DESCRIPTION } from '../../../utils';
import { useSnackMessage } from '../../../hooks';
import { DirectoryInitConfig, initializeDirectory } from './utils';
import GridItem from '../../grid/grid-item';

// Define operation types
enum OperationType {
Expand All @@ -35,6 +37,7 @@ export interface IElementCommonFields {
interface FormData extends IElementCommonFields {
[FieldConstants.OPERATION_TYPE]: OperationType;
}

export interface IElementCreationDialog extends IElementCommonFields {
[FieldConstants.FOLDER_NAME]: string;
[FieldConstants.FOLDER_ID]: UUID;
Expand Down Expand Up @@ -190,7 +193,10 @@ export function ElementSaveDialog({

// Handle cancellation
const onCancel = useCallback(() => {
reset({ ...emptyFormData, [FieldConstants.OPERATION_TYPE]: initialOperation });
reset({
...emptyFormData,
[FieldConstants.OPERATION_TYPE]: initialOperation,
});
setExpanded([]);
onClose();
}, [onClose, reset, initialOperation]);
Expand Down Expand Up @@ -252,7 +258,9 @@ export function ElementSaveDialog({
const parentFolderId = parents[parents.length - 1].id;

setSelectedItem({ id, name, description, parentFolderId, fullPath });
setValue(FieldConstants.DESCRIPTION, description ?? '', { shouldDirty: true });
setValue(FieldConstants.DESCRIPTION, description ?? '', {
shouldDirty: true,
});
setValue(FieldConstants.NAME, name, { shouldDirty: true });
}
setDirectorySelectorOpen(false);
Expand Down Expand Up @@ -291,30 +299,45 @@ export function ElementSaveDialog({
const renderChooser = () => {
if (isCreateMode) {
return (
<Grid container item>
<Grid container alignItems="center" alignContent="flex-start" spacing={2} pl={2}>
<Grid item>
<Button onClick={handleChangeFolder} variant="contained" size="small">
<FormattedMessage id="showSelectDirectoryDialog" />
</Button>
<Button
onClick={handleChangeFolder}
label={intl.formatMessage({
id: 'showSelectDirectoryDialog',
})}
variant="primary"
size="s"
/>
</Grid>
<Grid item>
<Typography m={1} component="span">
<Box fontWeight="fontWeightBold">
{destinationFolder ? destinationFolder.name : <CircularProgress />}
</Box>
</Typography>
</Grid>
<Typography m={1} component="span">
<Box fontWeight="fontWeightBold">
{destinationFolder ? destinationFolder.name : <CircularProgress />}
</Box>
</Typography>
</Grid>
);
}

return (
<Grid container item>
<Grid container alignItems="center" alignContent="flex-start" spacing={2} pl={2}>
<Grid item>
<Button onClick={handleChangeFolder} variant="contained" size="small">
<FormattedMessage id="showSelectDirectoryItemDialog" />
</Button>
<Button
onClick={handleChangeFolder}
label={intl.formatMessage({
id: 'showSelectDirectoryItemDialog',
})}
variant="primary"
size="s"
/>
</Grid>
<Grid item>
<Typography m={1} component="span">
<Box fontWeight="fontWeightBold">{selectedItem ? selectedItem.fullPath : null}</Box>
</Typography>
</Grid>
<Typography m={1} component="span">
<Box fontWeight="fontWeightBold">{selectedItem ? selectedItem.fullPath : null}</Box>
</Typography>
</Grid>
);
};
Expand All @@ -335,8 +358,14 @@ export function ElementSaveDialog({
<RadioInput
name={FieldConstants.OPERATION_TYPE}
options={[
{ id: OperationType.CREATE, label: createLabelId ?? 'createLabelId' },
{ id: OperationType.UPDATE, label: updateLabelId ?? 'updateLabelId' },
{
id: OperationType.CREATE,
label: createLabelId ?? 'createLabelId',
},
{
id: OperationType.UPDATE,
label: updateLabelId ?? 'updateLabelId',
},
]}
formProps={{
sx: {
Expand Down Expand Up @@ -371,9 +400,7 @@ export function ElementSaveDialog({
onlyLeaves={isCreateMode ? false : undefined}
multiSelect={false}
expanded={isCreateMode ? expanded : []}
validationButtonText={intl.formatMessage({
id: 'validate',
})}
validationButtonText="validate"
title={intl.formatMessage({
id: isCreateMode ? 'showSelectDirectoryDialog' : selectorTitleId,
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
*/

import { useEffect, useState } from 'react';
import { Box, Button, Grid, Typography } from '@mui/material';
import { FormattedMessage, useIntl } from 'react-intl';
import { Box, Grid, Typography } from '@mui/material';
import { useIntl } from 'react-intl';
import { useController } from 'react-hook-form';
import type { UUID } from 'node:crypto';
import { FolderOutlined } from '@mui/icons-material';
import { Button } from '@design-system-rte/react';
import { TreeViewFinderNodeProps } from '../../treeViewFinder';
import { FieldConstants } from '../../../utils/constants/fieldConstants';
import { DirectoryItemSelector } from '../../directoryItemSelector/DirectoryItemSelector';
Expand Down Expand Up @@ -90,9 +91,12 @@ export function ModifyElementSelection(props: ModifyElementSelectionProps) {
</span>
</Box>
</Typography>
<Button onClick={handleSelectFolder} variant="contained" size="small">
<FormattedMessage id={dialogOpeningButtonLabel} />
</Button>
<Button
label={intl.formatMessage({ id: dialogOpeningButtonLabel })}
onClick={handleSelectFolder}
variant="primary"
size="s"
/>
</Grid>
<DirectoryItemSelector
open={open}
Expand Down
Loading