Skip to content

Commit

Permalink
Merge branch 'main' into feat_optim_users-identity_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sBouzols authored Jan 2, 2025
2 parents e9efc3a + 8fbaf47 commit cea9317
Show file tree
Hide file tree
Showing 13 changed files with 490 additions and 439 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@gridsuite/commons-ui": "0.75.0",
"@gridsuite/commons-ui": "0.76.2",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.15.14",
"@mui/lab": "5.0.0-alpha.169",
Expand Down
14 changes: 10 additions & 4 deletions src/components/dialogs/commons/prefilled-name-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import { ElementType, FieldConstants, UniqueNameInput } from '@gridsuite/commons-ui';
import { useSelector } from 'react-redux';
import { elementExists } from '../../../utils/rest-api';
import { elementExists, getBaseName } from '../../../utils/rest-api';
import { AppState } from '../../../redux/types';

export interface PrefilledNameInputProps {
Expand Down Expand Up @@ -45,9 +45,15 @@ export default function PrefilledNameInput({ label, name, elementType }: Readonl

if (caseName) {
clearErrors(name);
setValue(name, caseName?.substring(0, caseName.indexOf('.')), {
shouldDirty: true,
});
getBaseName(caseName)
.then((response) => {
setValue(name, response, {
shouldDirty: true,
});
})
.catch((error) => {
console.error('Error fetching base name:', error);
});
}
}
}, [caseFile, modifiedByUser, apiCallErrorMessage, caseFileErrorMessage, setValue, clearErrors, name]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function CriteriaBasedEditionDialog({
const [languageLocal] = useParameterState(PARAM_LANGUAGE);
const [isFetching, setIsFetching] = useState(!!contingencyListId);
const { snackError } = useSnackMessage();
const selectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const itemSelectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const dispatch = useDispatch();
const methods = useForm<CriteriaBasedEditionFormData>({
defaultValues: getContingencyListEmptyFormData(name),
Expand Down Expand Up @@ -98,7 +98,7 @@ export default function CriteriaBasedEditionDialog({
const onSubmit = (contingencyList: CriteriaBasedEditionFormData) => {
saveCriteriaBasedContingencyList(contingencyListId, contingencyList)
.then(() => {
if (selectionForCopy.sourceItemUuid === contingencyListId) {
if (itemSelectionForCopy.sourceItemUuid === contingencyListId) {
dispatch(setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY));
broadcastChannel.postMessage({ NO_ITEM_SELECTION_FOR_COPY });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function ExplicitNamingEditionDialog({
}: Readonly<ExplicitNamingEditionDialogProps>) {
const [isFetching, setIsFetching] = useState(!!contingencyListId);
const { snackError } = useSnackMessage();
const selectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const itemSelectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const dispatch = useDispatch();
const methods = useForm({
defaultValues: emptyFormData(name),
Expand Down Expand Up @@ -110,7 +110,7 @@ export default function ExplicitNamingEditionDialog({
const onSubmit = (contingencyList: ExplicitNamingEditionFormData) => {
editContingencyList(contingencyListId, contingencyList)
.then(() => {
if (selectionForCopy.sourceItemUuid === contingencyListId) {
if (itemSelectionForCopy.sourceItemUuid === contingencyListId) {
dispatch(setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY));
broadcastChannel.postMessage({ NO_ITEM_SELECTION_FOR_COPY });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function ScriptEditionDialog({
}: Readonly<ScriptEditionDialogProps>) {
const [isFetching, setIsFetching] = useState(!!contingencyListId);
const { snackError } = useSnackMessage();
const selectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const itemSelectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const dispatch = useDispatch();

const methods = useForm({
Expand Down Expand Up @@ -106,7 +106,7 @@ export default function ScriptEditionDialog({
const onSubmit = (contingencyList: ScriptEditionFormData) => {
editContingencyList(contingencyListId, contingencyList)
.then(() => {
if (selectionForCopy.sourceItemUuid === contingencyListId) {
if (itemSelectionForCopy.sourceItemUuid === contingencyListId) {
dispatch(setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY));
broadcastChannel.postMessage({ NO_ITEM_SELECTION_FOR_COPY });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function CompositeModificationDialog({
const [languageLocal] = useParameterState(PARAM_LANGUAGE);
const [isFetching, setIsFetching] = useState(!!compositeModificationId);
const { snackError } = useSnackMessage();
const selectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const itemSelectionForCopy = useSelector((state: AppState) => state.itemSelectionForCopy);
const [modifications, setModifications] = useState<NetworkModificationMetadata[]>([]);
const dispatch = useDispatch();

Expand Down Expand Up @@ -129,7 +129,7 @@ export default function CompositeModificationDialog({
const onSubmit = (formData: FormData) => {
saveCompositeModification(compositeModificationId, formData[FieldConstants.NAME])
.then(() => {
if (selectionForCopy.sourceItemUuid === compositeModificationId) {
if (itemSelectionForCopy.sourceItemUuid === compositeModificationId) {
dispatch(setItemSelectionForCopy(NO_ITEM_SELECTION_FOR_COPY));
broadcastChannel.postMessage({ NO_ITEM_SELECTION_FOR_COPY });
}
Expand Down
Loading

0 comments on commit cea9317

Please sign in to comment.