Skip to content

Commit

Permalink
[frontend] fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumejparis committed Sep 11, 2024
1 parent 3009173 commit c55afe3
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 278 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void createExercisesFromScenarios() {
.filter(scenario -> !alreadyExistIds.contains(scenario.getId()))
// Create simulation with start date provided by cron
.forEach(scenario -> this.scenarioToExerciseService.toExercise(scenario, cronToDate(scenario.getRecurrence()),
null));
false));
}

private void cleanOutdatedRecurringScenario() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ScenarioToExerciseService {
public Exercise toExercise(
@NotBlank final Scenario scenario,
@Nullable final Instant start,
@Nullable final Boolean isRunning) {
final boolean isRunning) {
Exercise exercise = new Exercise();
exercise.setScenario(scenario);
exercise.setName(scenario.getName());
Expand All @@ -58,7 +58,7 @@ public Exercise toExercise(
exercise.setFrom(scenario.getFrom());
exercise.addReplyTos(scenario.getReplyTos());
exercise.setStart(start);
if (isRunning != null && isRunning) {
if (isRunning) {
exercise.setStatus(ExerciseStatus.RUNNING);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void scenarioToExerciseTest() {
VARIABLE_ID = variableSaved.getId();

// -- EXECUTE --
Exercise exercise = this.scenarioToExerciseService.toExercise(scenario, null, null);
Exercise exercise = this.scenarioToExerciseService.toExercise(scenario, null, false);
EXERCISE_ID = exercise.getId();
Exercise exerciseSaved = this.loadService.exercise(EXERCISE_ID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const ScenarioRecurringFormDialog: React.FC<Props> = ({ onSubmit, selectRecurrin
if (['noRepeat'].includes(selectRecurring)) {
if (data.time) {
return new Date(new Date().setUTCHours(0, 0, 0, 0)).getTime() !== new Date(data.startDate).getTime()
|| (new Date().getTime()) < new Date(data.time).getTime();
|| (new Date(minutesInFuture(1).toISOString()).getTime()) < new Date(data.time).getTime();
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const XlsMapperUpdateComponent: FunctionComponent<XlsMapperUpdateComponentProps>
const onSubmit = ((data: ImportMapperUpdateInput) => {
updateMapper(xlsMapper.import_mapper_id, data).then(
(result: { data: RawPaginationImportMapper }) => {
MESSAGING$.notifySuccess('The element has been updated');
onUpdate?.(result.data);
return result;
},
Expand Down
17 changes: 15 additions & 2 deletions openbas-front/src/utils/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,26 @@ export const simplePostCall = (uri: string, data?: unknown, defaultNotifyErrorBe
}
throw error;
});
export const simplePutCall = (uri: string, data?: unknown, defaultNotifyErrorBehavior: boolean = true) => simpleApi.put(buildUri(uri), data)
export const simplePutCall = (uri: string, data?: unknown, defaultNotifyErrorBehavior: boolean = true, defaultSuccessBehavior: boolean = true) => simpleApi.put(buildUri(uri), data)
.then((response) => {
if (defaultSuccessBehavior) {
MESSAGING$.notifySuccess('The element has been updated');
}
return response;
})
.catch((error) => {
if (defaultNotifyErrorBehavior) {
notifyError(error);
}
throw error;
});
export const simpleDelCall = (uri: string, defaultNotifyErrorBehavior: boolean = true) => simpleApi.delete(buildUri(uri))
export const simpleDelCall = (uri: string, defaultNotifyErrorBehavior: boolean = true, defaultSuccessBehavior: boolean = true) => simpleApi.delete(buildUri(uri))
.then((response) => {
if (defaultSuccessBehavior) {
MESSAGING$.notifySuccess('The element has been deleted');
}
return response;
})
.catch((error) => {
if (defaultNotifyErrorBehavior) {
notifyError(error);
Expand Down Expand Up @@ -131,6 +143,7 @@ export const delReferential = (uri: string, type: string, id: string) => (dispat
type: Constants.DATA_DELETE_SUCCESS,
payload: Immutable({ type, id }),
});
MESSAGING$.notifySuccess('The element has been deleted');
})
.catch((error) => {
dispatch({ type: Constants.DATA_FETCH_ERROR, payload: error });
Expand Down

0 comments on commit c55afe3

Please sign in to comment.