Skip to content

Commit

Permalink
Fix displaying errors
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jul 4, 2018
1 parent fcd38cf commit f202ef1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions settings/src/components/appList/appItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
<div class="actions">
<div class="warning" v-if="app.error">{{ app.error }}</div>
<div class="icon icon-loading-small" v-if="loading(app.id)"></div>
<input v-if="app.update" class="update" type="button" :value="t('settings', 'Update to {update}', {update:app.update})" v-on:click="update(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.canUnInstall" class="uninstall" type="button" :value="t('settings', 'Remove')" v-on:click="remove(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.active" class="enable" type="button" :value="t('settings','Disable')" v-on:click="disable(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="!app.active" class="enable" type="button" :value="enableButtonText" v-on:click="enable(app.id)" v-tooltip.auto="enableButtonTooltip" :disabled="!app.canInstall || installing || loading(app.id)" />
<input v-if="app.update" class="update" type="button" :value="t('settings', 'Update to {update}', {update:app.update})" v-on:click.stop="update(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.canUnInstall" class="uninstall" type="button" :value="t('settings', 'Remove')" v-on:click.stop="remove(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="app.active" class="enable" type="button" :value="t('settings','Disable')" v-on:click.stop="disable(app.id)" :disabled="installing || loading(app.id)" />
<input v-if="!app.active" class="enable" type="button" :value="enableButtonText" v-on:click.stop="enable(app.id)" v-tooltip.auto="enableButtonTooltip" :disabled="!app.canInstall || installing || loading(app.id)" />
</div>
</div>
</template>
Expand Down
16 changes: 12 additions & 4 deletions settings/src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ const mutations = {
},

setError(state, {appId, error}) {
let app = state.apps.find(app => app.id === appId);
app.error = error;
if (!Array.isArray(appId)) {
appId = [appId];
}
appId.forEach((_id) => {
let app = state.apps.find(app => app.id === _id);
app.error = error;
});
},

clearError(state, {appId, error}) {
Expand Down Expand Up @@ -199,10 +204,13 @@ const actions = {
});
})
.catch((error) => {
context.commit('setError', {appId: apps, error: t('settings', 'Error while enabling app')});
context.commit('stopLoading', apps);
context.commit('stopLoading', 'install');
context.commit('APPS_API_FAILURE', { appId, error })
context.commit('setError', {
appId: apps,
error: error.response.data.data.message
});
context.commit('APPS_API_FAILURE', { appId, error});
})
}).catch((error) => context.commit('API_FAILURE', { appId, error }));
},
Expand Down

0 comments on commit f202ef1

Please sign in to comment.