Skip to content

Commit

Permalink
ACM-10339 Show syntax errors on save in search YAML editor (stolostro…
Browse files Browse the repository at this point in the history
…n#3346)

Signed-off-by: zlayne <[email protected]>
  • Loading branch information
zlayne authored Mar 11, 2024
1 parent 22fae8d commit a264525
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions frontend/src/routes/Home/Search/Details/YAMLPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,21 @@ function updateResource(
setResourceVersion: Dispatch<SetStateAction<string>>
) {
if (cluster === 'local-cluster') {
replaceResource(jsYaml.load(resourceYaml) as IResource)
.promise.then(() => {
loadResource(cluster, kind, apiversion, name, namespace, setResourceYaml, setUpdateError, setResourceVersion)
setUpdateSuccess(true)
})
.catch((err) => {
console.error('Error updating resource: ', err)
setUpdateError(err.message)
})
try {
const parsedYaml = jsYaml.load(resourceYaml) as IResource
replaceResource(parsedYaml)
.promise.then(() => {
loadResource(cluster, kind, apiversion, name, namespace, setResourceYaml, setUpdateError, setResourceVersion)
setUpdateSuccess(true)
})
.catch((err) => {
console.error('Error updating resource: ', err)
setUpdateError(err.message)
})
} catch (err: any) {
console.error('Error updating resource: ', err)
setUpdateError(err?.message)
}
} else {
fireManagedClusterAction('Update', cluster, kind, apiversion, name, namespace, jsYaml.loadAll(resourceYaml)[0])
.then((actionResponse) => {
Expand Down Expand Up @@ -211,6 +217,8 @@ export function EditorActionBar(props: {
variant="primary"
id="update-resource-button"
onClick={() => {
setUpdateError('')
setUpdateSuccess(false)
updateResource(
cluster,
kind,
Expand Down

0 comments on commit a264525

Please sign in to comment.