Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: AntaresSimulatorTeam/AntaREST
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 315469b535e08f7841d7cb398eb7dfd31157d985
Choose a base ref
..
head repository: AntaresSimulatorTeam/AntaREST
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bd973590fb4673c930481b49cbd92cc5d81d3fcd
Choose a head ref
1 change: 0 additions & 1 deletion webapp/cypress/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
* This file is part of the Antares project.
*/

// cypress/types/global.d.ts
import { TAppPages } from "./index";
import { mount } from "cypress/react";

1 change: 1 addition & 0 deletions webapp/eslint.config.js
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ export default [
rules: {
...reactHookPlugin.configs.recommended.rules,
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-restricted-imports": [
"error",
{
11 changes: 8 additions & 3 deletions webapp/src/components/App/Singlestudy/FreezeStudy.tsx
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ function FreezeStudy({ studyId }: FreezeStudyProps) {
setBlockingTasks(
tasks.map((task) => ({
id: task.id,
type: task.type!,
type: task.type,
})),
);

@@ -143,10 +143,15 @@ function FreezeStudy({ studyId }: FreezeStudyProps) {

function forceUpdate(taskId: BlockingTask["id"]) {
getTask({ id: taskId }).then((task) => {
// Normally all blocking tasks have a type
if (!task.type) {
return;
}

const payload = {
id: task.id,
message: task.result?.message || "",
type: task.type!,
type: task.type,
};
if (task.status === TaskStatus.Running) {
if (typeof task.progress === "number") {
@@ -179,7 +184,7 @@ function FreezeStudy({ studyId }: FreezeStudyProps) {
unsubscribeWsChannels();
window.clearInterval(intervalId);
};
}, [studyId]);
}, [blockingTasksRef, studyId]);

return (
<Backdrop open={blockingTasks.length > 0} sx={{ position: "absolute" }}>
27 changes: 12 additions & 15 deletions webapp/src/components/App/Singlestudy/explore/Debug/index.tsx
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ function Debug() {
// Allow to keep expanded items when the tree is reloaded with `reloadTreeData`
const [expandedItems, setExpandedItems] = useState<string[]>([]);
const [searchParams, setSearchParams] = useSearchParams();
const pathInUrl = searchParams.get("path");
const path = searchParams.get("path");

const res = usePromiseWithSnackbarError(
async () => {
@@ -60,17 +60,18 @@ function Debug() {
const firstChildName = Object.keys(res.data ?? {})[0];
const firstChildTreeData = R.path<TreeData>([firstChildName], res.data);

const pathInUrlParts = pathInUrl?.split("/");
const urlPathTreeData = pathInUrlParts ? R.path<TreeData>(pathInUrlParts, res.data) : null;
const pathSegments = path?.split("/");
const filename = pathSegments ? R.last(pathSegments) : null;
const treeData = pathSegments ? R.path<TreeData>(pathSegments, res.data) : null;

let fileInfo: FileInfo | null = null;

if (urlPathTreeData) {
if (path && filename && treeData) {
fileInfo = {
fileType: getFileType(urlPathTreeData),
treeData: urlPathTreeData,
filename: R.last(pathInUrlParts!)!,
filePath: pathInUrl!,
fileType: getFileType(treeData),
treeData,
filename,
filePath: path,
};
} else if (firstChildTreeData) {
fileInfo = {
@@ -81,15 +82,11 @@ function Debug() {
};
}

if (fileInfo) {
setSelectedFile(fileInfo);
} else {
setSelectedFile(null);
}
}, [res.data, pathInUrl]);
setSelectedFile(fileInfo);
}, [res.data, path]);

useUpdateEffect(() => {
if (selectedFile?.filePath !== pathInUrl) {
if (selectedFile?.filePath !== path) {
setSearchParams({ path: selectedFile?.filePath || "" });
}
}, [selectedFile?.filePath]);
2 changes: 1 addition & 1 deletion webapp/src/components/App/Singlestudy/index.tsx
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ function SingleStudy(props: Props) {
) : (
<HomeView study={study} tree={tree} />
)}
<FreezeStudy studyId={studyId!} />
{studyId && <FreezeStudy studyId={studyId} />}
</Box>
{openCommands && studyId && (
<CommandDrawer
5 changes: 4 additions & 1 deletion webapp/src/components/common/buttons/DownloadButton.tsx
Original file line number Diff line number Diff line change
@@ -62,7 +62,10 @@ function DownloadButton<OptionValue extends string>(props: DownloadButtonProps<O

try {
if (formatOptions) {
await onClick?.(format!);
if (!format) {
throw new Error("No format selected");
}
await onClick?.(format);
} else {
await onClick?.();
}
8 changes: 5 additions & 3 deletions webapp/src/services/api/tasks/index.ts
Original file line number Diff line number Diff line change
@@ -13,10 +13,12 @@
*/

import client from "../client";
import type { GetTaskParams, GetTasksParams, TaskDTO } from "./types";
import type { GetTaskParams, GetTasksParams, TaskDTO, TTaskStatus, TTaskType } from "./types";

export async function getTasks(params: GetTasksParams) {
const { data } = await client.post<TaskDTO[]>("/v1/tasks", {
export async function getTasks<TStatus extends TTaskStatus, TType extends TTaskType | undefined>(
params: GetTasksParams<TStatus, TType>,
) {
const { data } = await client.post<Array<TaskDTO<TStatus, TType>>>("/v1/tasks", {
status: params.status,
type: params.type,
name: params.name,
22 changes: 16 additions & 6 deletions webapp/src/services/api/tasks/types.ts
Original file line number Diff line number Diff line change
@@ -20,9 +20,12 @@ export type TTaskStatus = O.UnionOf<typeof TaskStatus>;

export type TTaskType = O.UnionOf<typeof TaskType>;

export interface TaskDTO extends IdentityDTO<string> {
status: TTaskStatus;
type?: TTaskType;
interface BaseTaskDTO<
TStatus extends TTaskStatus = TTaskStatus,
TType extends TTaskType = TTaskType,
> extends IdentityDTO<string> {
status: TStatus;
type?: TType;
owner?: number;
ref_id?: string;
creation_date_utc: string;
@@ -39,9 +42,16 @@ export interface TaskDTO extends IdentityDTO<string> {
}>;
}

export interface GetTasksParams {
status?: TTaskStatus[];
type?: TTaskType[];
export type TaskDTO<
TStatus extends TTaskStatus = TTaskStatus,
TType extends TTaskType | undefined = undefined,
> = TType extends TTaskType
? O.Required<BaseTaskDTO<TStatus, TType>, "type">
: BaseTaskDTO<TStatus>;

export interface GetTasksParams<TStatus extends TTaskStatus, TType extends TTaskType | undefined> {
status?: TStatus[];
type?: TType[];
name?: string;
studyId?: StudyMetadata["id"];
fromCreationDateUtc?: number;