Skip to content

Commit

Permalink
Merge pull request #332 from nkaretnikov/prefix-size-check-649
Browse files Browse the repository at this point in the history
Expose `status_info` in the UI
  • Loading branch information
Nikita Karetnikov authored Nov 16, 2023
2 parents 34903d4 + 20c18fa commit 5ef8cac
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/common/models/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Build = {
};
packages: BuildPackage[];
status: string;
status_info: string | null;
size: number;
scheduled_on: string;
started_on: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ export const EnvironmentCreate = ({ environmentNotification }: IEnvCreate) => {
description: createLabel(name, "create")
}
});
} catch ({ data }) {
} catch (e) {
setError({
message: data.message,
message: e?.data?.message ?? createLabel(undefined, "error"),
visible: true
});
}
Expand Down
8 changes: 7 additions & 1 deletion src/features/metadata/components/EnvBuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ export const EnvBuilds = ({
>
Status: {""}
<Typography component="span" sx={{ fontSize: "13px" }}>
{currentBuild.status}
{currentBuild.status_info ? (
<>
{currentBuild.status} ({currentBuild.status_info})
</>
) : (
<>{currentBuild.status}</>
)}
{(currentBuild.status === "Building" ||
currentBuild.status === "Queued") && (
<CircularProgress
Expand Down
74 changes: 40 additions & 34 deletions src/utils/helpers/buildMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,50 @@ const dateToTimezone = (date: string) => {
};

export const buildMapper = (data: Build[], currentBuildId: number) => {
return data.map(({ id, status, ended_on, scheduled_on }: Build) => {
let duration = 0;
if (ended_on && scheduled_on) {
const startTime = new Date(scheduled_on);
const endTime = new Date(ended_on);
duration = (endTime.valueOf() - startTime.valueOf()) / 60000;
duration = Math.round(duration);
}
if (id === currentBuildId) {
return {
id,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - Active`,
status: isCompleted(status, duration)
};
}
return data.map(
({ id, status, status_info, ended_on, scheduled_on }: Build) => {
let duration = 0;
if (ended_on && scheduled_on) {
const startTime = new Date(scheduled_on);
const endTime = new Date(ended_on);
duration = (endTime.valueOf() - startTime.valueOf()) / 60000;
duration = Math.round(duration);
}
if (id === currentBuildId) {
return {
id,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - Active`,
status: isCompleted(status, duration),
status_info
};
}

if (isBuilding(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Building`,
status: "Building"
};
}
if (isBuilding(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Building`,
status: "Building",
status_info
};
}

if (isQueued(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Queued`,
status: "Building",
status_info
};
}

if (isQueued(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Queued`,
status: "Building"
name: `${dateToTimezone(ended_on ?? scheduled_on)} - ${
STATUS_OPTIONS[status]
}`,
status: isCompleted(status, duration),
status_info
};
}

return {
id,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - ${
STATUS_OPTIONS[status]
}`,
status: isCompleted(status, duration)
};
});
);
};

0 comments on commit 5ef8cac

Please sign in to comment.