Skip to content

Commit

Permalink
Added save error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gebsl committed Oct 29, 2024
1 parent b26ee9f commit cd0b532
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions databud/src/components/DataVisualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
title="Raw Data"
v-if="showRawView"
>
<b-alert
v-if="saveMessage"
show
variant="danger"
>
{{saveMessage}}
</b-alert>
<raw-data
:item="item"
:isSaving="isSaving"
Expand Down Expand Up @@ -63,6 +70,7 @@ import { ActionType } from '@/store/action-type';
interface Data {
isSaving: boolean;
activeTabIndex: number;
saveMessage?: string;
}
export default Vue.extend({
Expand All @@ -76,6 +84,7 @@ export default Vue.extend({
data: (): Data => ({
isSaving: false,
activeTabIndex: 0,
saveMessage: undefined,
}),
components: {
RawData,
Expand All @@ -91,12 +100,14 @@ export default Vue.extend({
},
methods: {
async saveVaultItem(item: VaultPostItem, onComplete?: () => void) {
this.saveMessage = undefined;
this.isSaving = true;
try {
await this.$store.dispatch(ActionType.UPDATE_VAULT_ITEM, item);
} catch {
/* TODO: Error handling */
} catch (e: any) {
console.error(e);
this.saveMessage = e.message ?? 'Could not save item';
}
this.isSaving = false;
Expand Down

0 comments on commit cd0b532

Please sign in to comment.