Skip to content

Commit

Permalink
Fix metadata editor toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
gordlin committed Dec 9, 2024
1 parent cb26d3e commit 4eedb7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/components/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,12 @@ export default class MetadataEditorV extends Vue {
*/
loadVersion(version: string): Promise<void> {
return new Promise((resolve, reject) => {
if (this.uuid === undefined || this.uuid === '') {
Message.error(this.$t('editor.warning.mustEnterUuid'));
this.loadStatus = 'waiting';
reject();
return;
}
// Create a new AbortController for each fetch attempt
// as they get 'used up' after each successful abort() call
this.controller = new AbortController();
Expand All @@ -925,10 +931,9 @@ export default class MetadataEditorV extends Vue {
if (res.status === 404) {
// Version not found.
if (version === 'latest') {
Message.error(this.$t('editor.warning.uuidNotFound', this.uuid));
Message.error(this.$t('editor.warning.uuidNotFound', { uuid: this.uuid }));
} else {
Message.error(this.$t('editor.editMetadata.message.error.noRequestedVersion'));
this.loadStatus = 'loaded';
}
this.error = true;
this.loadStatus = 'waiting';
Expand Down Expand Up @@ -994,19 +999,21 @@ export default class MetadataEditorV extends Vue {
// Note: This part probably doesn't need an manual abort() trigger to kill on load cancel,
// as the history should be much smaller and quicker to fetch than the config
if (this.uuid === undefined) Message.error(this.$t('editor.warning.mustEnterUuid'));
if (this.uuid === undefined || this.uuid === '') {
return;
}
this.loadStatus = 'loading';
const user = useUserStore().userProfile.userName || 'Guest';
fetch(this.apiUrl + `/history/${this.uuid}`, { headers: { user } }).then((res: Response) => {
if (res.status === 404) {
// Product not found.
Message.error(`The requested UUID '${this.uuid ?? ''}' does not exist.`);
this.loadStatus = 'waiting';
} else {
res.json().then((json) => {
this.storylineHistory = json;
this.loadStatus = 'loaded';
});
}
this.loadStatus = 'loaded';
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/lang/lang.csv
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ editor.uuid.new,New UUID,1,New UUID,0
editor.warning.mustEnterUuid,You must first enter a UUID.,1,Vous devez d'abord saisir un UUID.,0
editor.warning.retrievalFailed,"Failed to load product, no response from server.",1,"Échec du chargement du produit, aucune réponse du serveur.",0
editor.warning.uuid,UUID already exists. Saving this will overwrite existing product.,1,L’IDUU existe déjà. Enregistrer ce produit écrasera le produit existant.,1
editor.warning.uuidNotFound,The requested UUID '{uuid}' does not exist.,1,L'UUID '{uuid}' ​​demandé n'existe pas,0
editor.warning.uuidNotFound,The requested UUID '{uuid}' does not exist.,1,L'UUID '{uuid}' demandé n'existe pas,0
editor.metadata.uuidInstructions,"Please enter the UUID of an existing storylines product, then click the 'Load' button.",1,"Veuillez saisir l'UUID d'un produit de scénario existant, puis cliquez sur le bouton « Charger ».",0
editor.metadata.newUuidInstructions,"Enter a unique ID for your new storyline. One has been auto-generated for you, but you can also enter your own.",1,"Entrez un identifiant unique pour votre nouveau scénario. Un a été généré automatiquement pour vous, mais vous pouvez également saisir le vôtre.",0
editor.warning.rename,UUID already in use. Please choose a different ID.,1,UUID déjà utilisé. Veuillez choisir un autre identifiant.,0
Expand Down

0 comments on commit 4eedb7e

Please sign in to comment.