-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from flotiq/feature/24748-build-app-on-co-save
build the application on the object form submission
- Loading branch information
Showing
5 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export const handleAfterSubmitPlugin = ( | ||
{ success, contentObject }, | ||
toast, | ||
getPluginSettings, | ||
) => { | ||
const ctdName = contentObject?.internal?.contentType; | ||
const settings = getPluginSettings(); | ||
|
||
if (!success || !ctdName || !settings) return; | ||
|
||
const settingsForCtd = JSON.parse(settings)?.builds?.filter( | ||
(plugin) => | ||
plugin.content_types.length === 0 || | ||
plugin.content_types.find((ctd) => ctd === ctdName), | ||
); | ||
|
||
if (!settingsForCtd.length) return null; | ||
|
||
settingsForCtd.map((item) => | ||
fetch(item.build_webhook_url, { | ||
method: `POST`, | ||
body: '{}', | ||
headers: { | ||
'content-type': 'application/json;charset=UTF-8', | ||
}, | ||
}) | ||
.then(async ({ ok, status }) => { | ||
if (!ok) | ||
throw Error( | ||
`Failed to fetch Netlify build URL: ${item.build_instance_url}. Status: ${status}`, | ||
); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
if (error.message) { | ||
toast.error(error.message); | ||
} else { | ||
toast.error( | ||
`Failed to fetch Netlify build URL: ${item.build_instance_url}`, | ||
); | ||
} | ||
}), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.