Skip to content

feat: revamped runs section in workspaces #2015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 14, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ private void updateJobStepsWithStatus(int jobId, JobStatus jobStatus) {
}

private void updateJobStatusOnVcs(Job job, JobStatus jobStatus) {
if (job.getVia().equals(JobVia.UI.name()) || job.getVia().equals(JobVia.CLI.name())) {
if (job.getVia().equals(JobVia.UI.name()) || job.getVia().equals(JobVia.CLI.name()) || job.getVia().equals(JobVia.Schedule.name())) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.terrakube.api.repository.TemplateRepository;
import org.terrakube.api.rs.job.Job;
import org.terrakube.api.rs.job.JobStatus;
import org.terrakube.api.rs.job.JobVia;
import org.terrakube.api.rs.template.Template;
import org.terrakube.api.rs.workspace.schedule.Schedule;
import org.quartz.JobExecutionContext;
Expand Down Expand Up @@ -59,6 +60,7 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution
job.setStatus(JobStatus.pending);
job.setCreatedBy("serviceAccount");
job.setUpdatedBy("serviceAccount");
job.setVia(JobVia.Schedule.name());
Date triggerDate = new Date(System.currentTimeMillis());
job.setCreatedDate(triggerDate);
job.setUpdatedDate(triggerDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution
stepRepository.save(step);
}
}
if (job.getVia().equals(JobVia.CLI.name()) || job.getVia().equals(JobVia.UI.name()) ) {
if (job.getVia().equals(JobVia.CLI.name()) || job.getVia().equals(JobVia.UI.name()) || job.getVia().equals(JobVia.Schedule.name()) ) {
log.info("No information to update for job", job.getId());
return;
} else {
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/terrakube/api/rs/job/JobVia.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public enum JobVia {
CLI,
Github,
Gitlab,
Bitbucket
Bitbucket,
Schedule
}
23 changes: 13 additions & 10 deletions ui/src/domain/Modules/List.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ClockCircleOutlined, CloudOutlined, CloudUploadOutlined, DownloadOutlined } from "@ant-design/icons";
import { Breadcrumb, Button, Card, Input, Layout, List, Space, Tag, Typography, theme, Row, Col } from "antd";
import { Button, Card, Input, Layout, List, Space, Tag, Typography, Row, Col } from "antd";
import { DateTime } from "luxon";
import { useEffect, useState } from "react";
import { IconContext } from "react-icons";
Expand Down Expand Up @@ -35,10 +35,6 @@ export const ModuleList = ({ setOrganizationName, organizationName }: Props) =>
const [loading, setLoading] = useState(false);
const navigate = useNavigate();

const {
token: { colorBgContainer },
} = theme.useToken();

const onSearch = (value: string) => {
applyFilters(value);
};
Expand Down Expand Up @@ -101,13 +97,20 @@ export const ModuleList = ({ setOrganizationName, organizationName }: Props) =>
]}
fluid
actions={
<Button type="primary" htmlType="button" icon={<CloudUploadOutlined />} onClick={handlePublish}>
Publish module
</Button>
<Space>
<Button type="primary" htmlType="button" icon={<CloudUploadOutlined />} onClick={handlePublish}>
Publish module
</Button>
</Space>
}
>
<div className="site-layout-content">
<Search placeholder="Filter modules" onSearch={onSearch} allowClear style={{ marginBottom: "16px" }} />
<div style={{ width: "100%", marginTop: "24px" }}>
<Search
placeholder="Filter modules"
onSearch={onSearch}
allowClear
style={{ width: "100%", marginBottom: "16px" }}
/>
<List
split={false}
dataSource={filteredModules}
Expand Down
59 changes: 2 additions & 57 deletions ui/src/domain/Workspaces/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import { WorkspaceGeneral } from "./Settings/General";
import { WorkspaceWebhook } from "./Settings/Webhook.jsx";
import { getIaCIconById, getIaCNameById, renderVCSLogo } from "./Workspaces";
import "./Workspaces.css";
import RunList from "@/modules/workspaces/components/RunList";
const { Paragraph } = Typography;

const include = {
Expand Down Expand Up @@ -731,63 +732,7 @@ export const WorkspaceDetails = ({ setOrganizationName, selectedTab }: Props) =>
{jobVisible ? (
<DetailsJob jobId={jobId!} />
) : (
<div>
<h3>Run List</h3>
<List
itemLayout="horizontal"
dataSource={jobs.sort((a, b) => parseInt(a.id) - parseInt(b.id)).reverse()}
renderItem={(item) => (
<List.Item
extra={
<div className="textLeft">
<Tag
icon={
item.status == "completed" ? (
<CheckCircleOutlined />
) : item.status == "noChanges" ? (
<CheckCircleOutlined />
) : item.status == "running" ? (
<SyncOutlined spin />
) : item.status === "waitingApproval" ? (
<ExclamationCircleOutlined />
) : item.status === "cancelled" ? (
<StopOutlined />
) : item.status === "failed" ? (
<StopOutlined />
) : (
<ClockCircleOutlined />
)
}
color={item.statusColor}
>
{item.status}
</Tag>{" "}
<br />
<span className="metadata">{item.latestChange}</span>
</div>
}
>
<List.Item.Meta
style={{ margin: "0px", padding: "0px" }}
avatar={<Avatar shape="square" icon={<UserOutlined />} />}
title={<a onClick={() => handleClick(item.id)}>{item.title}</a>}
description={
<span>
{" "}
#job-{item.id} |
{item.commitId !== "000000000" ? (
<> commitId {item.commitId?.substring(0, 6)} </>
) : (
""
)}
| <b>{item.createdBy}</b> triggered via {item.via || "UI"}
</span>
}
/>
</List.Item>
)}
/>
</div>
<RunList jobs={jobs} onRunClick={handleClick} />
)}
</TabPane>
<TabPane tab="States" key="3" disabled={!manageState}>
Expand Down
10 changes: 8 additions & 2 deletions ui/src/domain/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ export enum JobStatus {
Failed = "failed",
Unknown = "unknown",
}

export enum JobVia {
Ui = "UI",
Cli = "CLI",
Github = "Github",
Gitlab = "Gitlab",
Bitbucket = "Bitbucket",
Schedule = "Schedule"
}

export type JobAttributes = {
Expand All @@ -100,10 +102,14 @@ export type JobStep = {
};
export type FlatJob = {
id: string;
latestChange: string;
title: string;
status: JobStatus;
statusColor: string;
} & JobAttributes;
latestChange: string;
commitId?: string;
createdBy: string;
via?: JobVia;
};
// VCS

export enum VcsType {
Expand Down
Loading