Changeset View
Changeset View
Standalone View
Standalone View
swh/web/vault/assets/vault-create-tasks.js
Show All 29 Lines | export async function vaultRequest(objectType, swhid) { | ||||
} else { | } else { | ||||
vaultUrl = Urls.api_1_vault_cook_git_bare(swhid); | vaultUrl = Urls.api_1_vault_cook_git_bare(swhid); | ||||
} | } | ||||
// check if object has already been cooked | // check if object has already been cooked | ||||
const response = await fetch(vaultUrl); | const response = await fetch(vaultUrl); | ||||
const data = await response.json(); | const data = await response.json(); | ||||
// object needs to be cooked | // object needs to be cooked | ||||
if (data.exception === 'NotFoundExc' || data.status === 'failed') { | const statusForCooking = ['failed', 'pending', 'new']; | ||||
if (data.exception === 'NotFoundExc' || statusForCooking.includes(data.status)) { | |||||
// if last cooking has failed, remove previous task info from localStorage | // if last cooking has failed, remove previous task info from localStorage | ||||
// in order to force the recooking of the object | // in order to force the recooking of the object | ||||
swh.vault.removeCookingTaskInfo([swhid]); | swh.vault.removeCookingTaskInfo([swhid]); | ||||
const vaultModalId = `#vault-cook-${objectType}-modal`; | const vaultModalId = `#vault-cook-${objectType}-modal`; | ||||
$(vaultModalId).modal('show'); | $(vaultModalId).modal('show'); | ||||
$('body').on('keyup', vaultModalId, vaultModalHandleEnterKey); | $('body').on('keyup', vaultModalId, vaultModalHandleEnterKey); | ||||
// object has been cooked and should be in the vault cache, | // object has been cooked and should be in the vault cache, | ||||
// it will be asked to cook it again if it is not | // it will be asked to cook it again if it is not | ||||
} else if (data.status === 'done') { | } else if (data.status === 'done') { | ||||
const vaultModalId = `#vault-fetch-${objectType}-modal`; | const vaultModalId = `#vault-fetch-${objectType}-modal`; | ||||
$(vaultModalId).modal('show'); | $(vaultModalId).modal('show'); | ||||
$('body').on('keyup', vaultModalId, vaultModalHandleEnterKey); | $('body').on('keyup', vaultModalId, vaultModalHandleEnterKey); | ||||
} else { | } else { | ||||
vlorentz: wait, what happens if `response.ok` is true here? No feedback to the user? | |||||
Done Inline ActionsI updated the diff to handle all possible vault cooking statuses and the danger alert should only be displayed when HTTP response ends up with error so we should be good now. anlambert: I updated the diff to handle all possible vault cooking statuses and the danger alert should… | |||||
Not Done Inline ActionsCould you make it display "something unexpected happened" and send a Sentry report when none of the conditions is satisfied, then? I don't like the idea of not giving any feedback when the backend sends an unexpected response vlorentz: Could you make it display "something unexpected happened" and send a Sentry report when none of… | |||||
Done Inline ActionsI removed the !response.ok condition. We do not have any caught exception here so I do not think it worth it to report to sentry as Web API errors are already reported. anlambert: I removed the `!response.ok` condition. We do not have any caught exception here so I do not… | |||||
const cookingServiceDownAlert = | const cookingServiceDownAlert = | ||||
$(htmlAlert('danger', | $(htmlAlert('danger', | ||||
'Archive cooking service is currently experiencing issues.<br/>' + | 'Something unexpected happened when requesting the archive cooking service.<br/>' + | ||||
'Please try again later.', | 'Please try again later.', | ||||
true)); | true)); | ||||
cookingServiceDownAlert.css(alertStyle); | cookingServiceDownAlert.css(alertStyle); | ||||
$('body').append(cookingServiceDownAlert); | $('body').append(cookingServiceDownAlert); | ||||
} | } | ||||
} | } | ||||
async function addVaultCookingTask(objectType, cookingTask) { | async function addVaultCookingTask(objectType, cookingTask) { | ||||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
wait, what happens if response.ok is true here? No feedback to the user?