some minor nits

This commit is contained in:
Hari Krishna
2024-04-29 10:55:09 +00:00
parent 1c97e67855
commit 9837e15502
2 changed files with 136 additions and 93 deletions
+54 -13
View File
@@ -756,7 +756,7 @@ If you're interested, please let me know a time that works for you, or set up a
.then((responseJson) => { .then((responseJson) => {
setWebHooks(responseJson.webhooks || []); // Handling the case where the result is null or undefined setWebHooks(responseJson.webhooks || []); // Handling the case where the result is null or undefined
setAllSchedules(responseJson.schedules || []); setAllSchedules(responseJson.schedules || []);
setPipelines(responseJson.pipelines || []); // setPipelines(responseJson.pipelines || []);
}) })
.catch((error) => { .catch((error) => {
toast(error.toString()); toast(error.toString());
@@ -935,13 +935,54 @@ If you're interested, please let me know a time that works for you, or set up a
}; };
const changePipelineState = (pipeline, state) => { const changePipelineState = (pipeline, state) => {
if (state.trim() === ''){ if (state.trim() === "") {
toast("state is not defined") toast("state is not defined");
return return;
} }
const data = {
name: pipeline.name,
type: state,
environment: pipeline.environment,
workflow_id: pipeline.workflow_id,
trigger_id: pipeline.trigger_id,
};
if (state === "start") toast("starting the pipeline");
else toast("stopping the pipeline");
const url = `${globalUrl}/api/v1/triggers/pipeline`;
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(data),
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for stream results :O!");
toast("Failed to update the pipeline state");
} }
return response.json();
})
.then((responseJson) => {
if (!responseJson.success) {
toast("Failed to update the pipeline: " + responseJson.reason);
} else {
if (state === "start") toast("Successfully created pipeline");
else toast("Sucessfully stopped the pipeline");
}
})
.catch((error) => {
//toast(error.toString());
console.log("Get schedule error: ", error.toString());
});
};
if ( if (
userdata.support === true && userdata.support === true &&
selectedOrganization.id !== "" && selectedOrganization.id !== "" &&
@@ -4618,7 +4659,7 @@ If you're interested, please let me know a time that works for you, or set up a
<ListItemText primary="Actions" /> <ListItemText primary="Actions" />
<ListItemText primary="Delegation" /> <ListItemText primary="Delegation" />
</ListItem> </ListItem>
{ allSchedules.map((schedule, index) => { {allSchedules.map((schedule, index) => {
var bgColor = "#27292d"; var bgColor = "#27292d";
if (index % 2 === 0) { if (index % 2 === 0) {
bgColor = "#1f2023"; bgColor = "#1f2023";
@@ -4667,9 +4708,7 @@ If you're interested, please let me know a time that works for you, or set up a
<Button <Button
style={{}} style={{}}
variant={ variant={
schedule.status === "running" schedule.status === "running" ? "contained" : "outlined"
? "contained"
: "outlined"
} }
disabled={schedule.status === "uninitialized"} disabled={schedule.status === "uninitialized"}
onClick={() => { onClick={() => {
@@ -4833,7 +4872,7 @@ If you're interested, please let me know a time that works for you, or set up a
</List> </List>
)} )}
<div style={{ marginTop: 20, marginBottom: 20 }}> {/* <div style={{ marginTop: 20, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>Tenzir Pipelines</h2> <h2 style={{ display: "inline" }}>Tenzir Pipelines</h2>
<span style={{ marginLeft: 25 }}> <span style={{ marginLeft: 25 }}>
Controls a pipeline to run things.{" "} Controls a pipeline to run things.{" "}
@@ -4855,7 +4894,9 @@ If you're interested, please let me know a time that works for you, or set up a
backgroundColor: theme.palette.inputColor, backgroundColor: theme.palette.inputColor,
}} }}
/> />
{pipelines === undefined || pipelines === null || pipelines.length === 0 ? ( {pipelines === undefined ||
pipelines === null ||
pipelines.length === 0 ? (
<div <div
style={{ style={{
textAlign: "center", textAlign: "center",
@@ -4927,15 +4968,15 @@ If you're interested, please let me know a time that works for you, or set up a
}} }}
> >
{pipeline.status === "running" {pipeline.status === "running"
? "Stop webhook" ? "Stop pipeline"
: "Start Webhook"} : "Start pipeline"}
</Button> </Button>
</ListItemText> </ListItemText>
</ListItem> </ListItem>
); );
})} })}
</List> </List>
)} )}*/}
</div> </div>
) : null; ) : null;
+14 -12
View File
@@ -13141,29 +13141,31 @@ const AngularWorkflow = (defaultprops) => {
return response.json(); return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
if (!responseJson.success) {
if (responseJson.reason !== undefined) {
toast("Failed to stop webhook: " + responseJson.reason);
}
} else {
toast("Successfully stopped webhook");
}
if (workflow.triggers[triggerindex] !== undefined) { if (workflow.triggers[triggerindex] !== undefined) {
workflow.triggers[triggerindex].status = "stopped"; workflow.triggers[triggerindex].status = "stopped";
} }
if (responseJson.success) {
// Set the status
saveWorkflow(workflow);
} else {
if (responseJson.reason !== undefined) {
toast("Failed stopping webhook: " + responseJson.reason);
}
}
trigger.status = "stopped"; trigger.status = "stopped";
setWorkflow(workflow);
setSelectedTrigger(trigger); setSelectedTrigger(trigger);
setWorkflow(workflow);
saveWorkflow(workflow);
}) })
.catch((error) => { .catch((error) => {
//toast(error.toString()); //toast(error.toString());
toast("Delete webhook error. Contact support or check logs if this persists.") toast(
"Delete webhook error. Contact support or check logs if this persists.",
);
}); });
}; };
// POST to /api/v1/workflows // POST to /api/v1/workflows
const createWorkflow = (workflow, trigger_index) => { const createWorkflow = (workflow, trigger_index) => {
fetch(globalUrl + "/api/v1/workflows", { fetch(globalUrl + "/api/v1/workflows", {