Cloud sync for all edits in May->June
This commit is contained in:
@@ -89,49 +89,18 @@ const Priorities = memo((props) => {
|
||||
|
||||
useEffect(() => {
|
||||
prepareNotificationAppList()
|
||||
|
||||
if (notifications === undefined || notifications === null || notifications.length === 0) {
|
||||
getNotifications()
|
||||
}
|
||||
}, []);
|
||||
|
||||
let navigate = useNavigate();
|
||||
const classes = useStyles();
|
||||
|
||||
const getAppIDs = async (appList) => {
|
||||
fetch(globalUrl + "/api/v1/apps", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
}).then((response) => {
|
||||
if (response.status !== 200) {
|
||||
toast("Failed getting app ids: ", response.reason);
|
||||
console.log("Status not 200 for app ids :O!");
|
||||
return;
|
||||
}
|
||||
return response.json();
|
||||
}).then((responseJson) => {
|
||||
if (responseJson !== undefined) {
|
||||
// console.log("App ids: ", responseJson)
|
||||
// console.log("App list: ", appList)
|
||||
const filteredApps = responseJson.filter(app => appList.includes(app.name));
|
||||
const appDetails = filteredApps.map(app => ({ name: app.name, id: app.id }));
|
||||
return appDetails
|
||||
// console.log("App IDs: ", appDetails)
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log("Error getting app ids: " + error);
|
||||
})
|
||||
}
|
||||
|
||||
// getting comms & cases app from app framework
|
||||
var notificationAppList = [];
|
||||
// if (selectedOrganization.security_framework?.cases && selectedOrganization.security_framework?.cases.name.length > 0) {
|
||||
// notificationAppList = notificationAppList.concat(selectedOrganization.security_framework?.cases);
|
||||
// }
|
||||
// if (selectedOrganization.security_framework?.communication && selectedOrganization.security_framework?.communication.name.length > 0) {
|
||||
// notificationAppList = notificationAppList.concat(selectedOrganization.security_framework?.communication);
|
||||
// }
|
||||
|
||||
const mergeAuthData = (result, responseJson) => {
|
||||
// result is only getting: Jira AND discord.
|
||||
|
||||
@@ -146,7 +115,7 @@ const Priorities = memo((props) => {
|
||||
return updatedResult;
|
||||
};
|
||||
|
||||
const prepareNotificationAppList = async () => {
|
||||
const prepareNotificationAppList = () => {
|
||||
// getting App ID,Authentication fields and saved auths for each app
|
||||
var result = []
|
||||
fetch(globalUrl + "/api/v1/apps", {
|
||||
@@ -187,18 +156,17 @@ const Priorities = memo((props) => {
|
||||
return;
|
||||
}
|
||||
return response.json();
|
||||
}).then(async (responseJson) => {
|
||||
}).then((responseJson) => {
|
||||
if (!responseJson.success) {
|
||||
console.log("Could not get app auth")
|
||||
return;
|
||||
}
|
||||
// console.log("responseJson of auth: ", responseJson.data)
|
||||
result = await mergeAuthData(appDetails, responseJson.data)
|
||||
result = mergeAuthData(appDetails, responseJson.data)
|
||||
// console.log("merged auth data: ", result)
|
||||
// console.log("result", result)
|
||||
|
||||
result.map(item => {
|
||||
console.log("Getting app config for: ", item.name);
|
||||
fetch(globalUrl + `/api/v1/apps/${item.id}/config`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
@@ -235,9 +203,9 @@ const Priorities = memo((props) => {
|
||||
setnotificationAppsDetails(newJSON);
|
||||
console.log("notificationAppsDetails: ", newJSON)
|
||||
}
|
||||
}).then(async () => {
|
||||
}).then(() => {
|
||||
// removing this for now,
|
||||
// await checkIfAlreadyGenerated(filteredApps, workflows);
|
||||
// checkIfAlreadyGenerated(filteredApps, workflows);
|
||||
|
||||
}).catch((error) => {
|
||||
console.log("Error getting app config: " + error);
|
||||
@@ -280,143 +248,6 @@ const Priorities = memo((props) => {
|
||||
console.log("Apps: ", notificationAppsDetails);
|
||||
}, [notificationAppsDetails])
|
||||
|
||||
// const generateJiraNotificationWorkflow = async (app, appAuthId, projectId, issuetype) => {
|
||||
// //currently only supports JIRA figure out a way to support more apps
|
||||
|
||||
// var appname = app.name;
|
||||
// var appImage = app.large_image;
|
||||
|
||||
// var workflowName = `[GENERATED] ${appname} notification workflow`
|
||||
// var workflowDescription = "Generated by Shuffle for sending info/error notifications."
|
||||
// var data = {
|
||||
// "name": workflowName,
|
||||
// "description": workflowDescription,
|
||||
// }
|
||||
|
||||
// fetch(globalUrl + "/api/v1/workflows", {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// Accept: "application/json",
|
||||
// },
|
||||
// body: JSON.stringify(data),
|
||||
// credentials: "include",
|
||||
// })
|
||||
// .then((response) => {
|
||||
// if (response.status !== 200) {
|
||||
// toast("Failed setting notification workflow: ", response.reason);
|
||||
// console.log("Status not 200 for workflows :O!");
|
||||
// return;
|
||||
// }
|
||||
// return response.json();
|
||||
// }).then((responseJson) => {
|
||||
// if (responseJson !== undefined) {
|
||||
// console.log("Notification workflow created successfully")
|
||||
// var workflow_id = responseJson.id
|
||||
// if (appname.toLowerCase() === "jira") {
|
||||
// console.log("updating workflow for JIRA")
|
||||
// var workflowBody = {
|
||||
// "name": workflowName,
|
||||
// "Description": workflowDescription,
|
||||
// "id": workflow_id,
|
||||
// "actions": [
|
||||
// {
|
||||
// "app_id": app.id,
|
||||
// "app_name": "jira",
|
||||
// "name": "post_create_issue",
|
||||
// "authentication_id": appAuthId,
|
||||
// "large_image": appImage,
|
||||
// "isStartNode": true,
|
||||
// "label": "create_issue",
|
||||
// "app_version": "1.1.0",
|
||||
// "parameters": [
|
||||
// {
|
||||
// "name": "body",
|
||||
// "value": `{"fields": { "project": {"key": "${projectId}"},"summary": "$exec.title","issuetype": {"name": "${issuetype}"},"description": {"content": [{"content":[{"type":"text","text":"$exec.description"}],"type": "paragraph"}],"type": "doc","version": 1}}}`
|
||||
// },
|
||||
// {
|
||||
// "name": "username_basic",
|
||||
// "value": ""
|
||||
// },
|
||||
// {
|
||||
// "name": "password_basic",
|
||||
// "value": ""
|
||||
// },
|
||||
// {
|
||||
// "name": "url",
|
||||
// "value": ""
|
||||
// },
|
||||
// {
|
||||
// "name": "headers",
|
||||
// "value": "Content-type=application/json \nAccept=application/json"
|
||||
// },
|
||||
// {
|
||||
// "name": "queries",
|
||||
// "value": ""
|
||||
// },
|
||||
// {
|
||||
// "name": "ssl_verify",
|
||||
// "value": "False"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
// fetch(globalUrl + `/api/v1/workflows/${workflow_id}`, {
|
||||
// method: "PUT",
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// Accept: "application/json",
|
||||
// },
|
||||
// body: JSON.stringify(workflowBody),
|
||||
// credentials: "include",
|
||||
// })
|
||||
// .then((response) => {
|
||||
// if (response.status !== 200) {
|
||||
// toast("Failed setting notification workflow: ", response.reason);
|
||||
// console.log("Status not 200 for workflows :O!");
|
||||
// return;
|
||||
// }
|
||||
// return response.json();
|
||||
// }).then((responseJson) => {
|
||||
// if (responseJson !== undefined) {
|
||||
// handleEditOrg(
|
||||
// selectedOrganization.name,
|
||||
// selectedOrganization.description,
|
||||
// selectedOrganization.id,
|
||||
// selectedOrganization.image,
|
||||
// {
|
||||
// documentation_reference: selectedOrganization?.defaults?.documentation_reference,
|
||||
// workflow_upload_repo: selectedOrganization?.defaults?.workflow_upload_repo,
|
||||
// workflow_upload_branch: selectedOrganization?.defaults?.workflow_upload_branch,
|
||||
// workflow_upload_username: selectedOrganization?.defaults?.workflow_upload_username,
|
||||
// workflow_upload_token: selectedOrganization?.defaults?.workflow_upload_token,
|
||||
// newsletter: selectedOrganization?.defaults?.newsletter,
|
||||
// weekly_recommendations: selectedOrganization?.defaults?.weekly_recommendations,
|
||||
// notification_workflow: workflow_id,
|
||||
// },
|
||||
// {
|
||||
// sso_entrypoint: selectedOrganization?.sso_config?.sso_entrypoint,
|
||||
// sso_certificate: selectedOrganization?.sso_config?.sso_certificate,
|
||||
// client_id: selectedOrganization?.sso_config?.client_id,
|
||||
// client_secret: selectedOrganization?.sso_config?.client_secret,
|
||||
// openid_authorization: selectedOrganization?.sso_config?.openid_authorization,
|
||||
// openid_token: selectedOrganization?.sso_config?.openid_token,
|
||||
// SSORequired: selectedOrganization?.sso_config?.SSORequired,
|
||||
// auto_provision: selectedOrganization?.sso_config?.auto_provision,
|
||||
// }
|
||||
// )
|
||||
// console.log("Notification workflow updated successfully")
|
||||
// toast("Notification workflow updated successfully")
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }).catch((error) => {
|
||||
// console.log("Error setting workflows: " + error);
|
||||
// })
|
||||
// }
|
||||
|
||||
const generateCommsNotificationWorkflow = async (app, sender, recepient) => {
|
||||
var appname = app.name
|
||||
var appImage = app.large_image
|
||||
@@ -984,12 +815,13 @@ print('"' + encoded + '"')
|
||||
<FormControl>
|
||||
<DialogTitle>
|
||||
<div style={{ color: "rgba(255,255,255,0.9)" }}>
|
||||
{`Configure ${selectedAppDetails.name} workflow`}
|
||||
{`Configure ${selectedAppDetails?.name?.replaceAll("_", " ")} workflow`}
|
||||
</div>
|
||||
</DialogTitle>
|
||||
<DialogContent style={{ color: "rgba(255,255,255,0.65)", overflowY: 'auto', maxHeight: '450px' }}>
|
||||
<Divider style={{ marginBottom: '1em', backgroundColor: 'rgba(255,255,255,0.12)' }} />
|
||||
{console.log("len Selected app details: ", selectedAppDetails)}
|
||||
|
||||
{(selectedAppDetails.authentication_data || (selectedAppDetails.auth_config && selectedAppDetails.auth_config.required == false) || (selectedAppDetails.authentication && selectedAppDetails.authentication.required == false)) ?
|
||||
<>
|
||||
<Box mb={2}>
|
||||
@@ -1152,13 +984,15 @@ print('"' + encoded + '"')
|
||||
|
||||
const renderChips = useCallback(() => {
|
||||
const appList = Object.values(notificationAppsDetails);
|
||||
|
||||
return (
|
||||
<Stack spacing={2}>
|
||||
<Stack direction="row" spacing={1}>
|
||||
|
||||
{appList.map((app) => (
|
||||
<Chip
|
||||
key={app.id}
|
||||
label={app.name}
|
||||
label={app?.name.replaceAll("_", " ")}
|
||||
variant={generatedWorkflow.app_name === app.name ? "filled" : "outlined"}
|
||||
disabled={generatedWorkflow.app_name === app.name ? true : false}
|
||||
onClick={() => {
|
||||
@@ -1176,6 +1010,7 @@ print('"' + encoded + '"')
|
||||
avatar={<img src={app.large_image} alt={app.name} style={{ width: 24, height: 24, borderRadius: '50%' }} />}
|
||||
/>
|
||||
))}
|
||||
|
||||
</Stack>
|
||||
|
||||
<Box sx={{
|
||||
@@ -1198,7 +1033,7 @@ print('"' + encoded + '"')
|
||||
>
|
||||
Set up app authentication
|
||||
</Link>
|
||||
to unlock additional workflow options.
|
||||
to show additional workflow options.
|
||||
</Typography>
|
||||
</Box>
|
||||
</Stack>
|
||||
@@ -1283,10 +1118,38 @@ print('"' + encoded + '"')
|
||||
})
|
||||
}
|
||||
|
||||
const getNotifications = () => {
|
||||
fetch(`${globalUrl}/api/v1/notifications`, {
|
||||
credentials: "include",
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.status !== 200) {
|
||||
console.log("Error in response");
|
||||
}
|
||||
|
||||
return response.json();
|
||||
})
|
||||
.then(function (responseJson) {
|
||||
if (responseJson?.success !== false && responseJson?.notifications !== undefined && responseJson?.notifications !== null) {
|
||||
setNotifications(responseJson.notifications || [])
|
||||
} else {
|
||||
toast("Failed loading notifications. Please try again later.");
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("error in notification loading: ", error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
const clearNotifications = () => {
|
||||
// Don't really care about the logout
|
||||
|
||||
toast("Clearing notifications")
|
||||
toast.info("Marking all notifications as read. This may take a while.")
|
||||
fetch(`${globalUrl}/api/v1/notifications/clear`, {
|
||||
credentials: "include",
|
||||
method: "GET",
|
||||
|
||||
Reference in New Issue
Block a user