Create id inline error
This commit is contained in:
Родитель
29b4b5dd80
Коммит
66aa0bc6bd
|
@ -94,8 +94,8 @@ class ConfigurationsActions extends AbstractActions implements IConfigurationsAc
|
|||
},
|
||||
(error: any, json: any) => {
|
||||
|
||||
if (error || (json && json.errors)) {
|
||||
return this.failure(error || json.errors);
|
||||
if (error || (json && (json.error || json.errors))) {
|
||||
return this.failure(error || json);
|
||||
}
|
||||
|
||||
return dispatcher(json);
|
||||
|
@ -173,7 +173,7 @@ class ConfigurationsActions extends AbstractActions implements IConfigurationsAc
|
|||
}
|
||||
|
||||
failure(error: any) {
|
||||
return { error };
|
||||
return error;
|
||||
}
|
||||
|
||||
deleteDashboard(id: string) {
|
||||
|
|
|
@ -260,11 +260,11 @@ export default class Home extends React.Component<any, IHomeState> {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Create dashboard form validation
|
||||
let error = false;
|
||||
let errorText = null;
|
||||
const isBadId = errors && errors.error && errors.error.message && errors.error.type && errors.error.type === 'id';
|
||||
if (isBadId) {
|
||||
errorText = errors.error.message;
|
||||
if (errors && errors.error && errors.type && errors.type === 'id') {
|
||||
errorText = errors.error;
|
||||
error = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ class ConfigurationsStore extends AbstractStoreModel<IConfigurationsStoreState>
|
|||
loadTemplate(result: { template: IDashboardConfig }) {
|
||||
let { template } = result;
|
||||
this.template = template;
|
||||
this.errors = null;
|
||||
|
||||
if (this.template) {
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ router.put('/dashboards/:id?', (req, res) => {
|
|||
let { script } = req.body || {};
|
||||
|
||||
if (!id || !script) {
|
||||
return res.json({ errors: {message: 'No id or script were supplied for the new dashboard', type: 'id'}} );
|
||||
return res.json({ error: 'No id or script were supplied for the new dashboard', type: 'id'} );
|
||||
}
|
||||
|
||||
const { privateDashboard } = paths();
|
||||
|
@ -283,7 +283,7 @@ router.put('/dashboards/:id?', (req, res) => {
|
|||
let dashboardExists = fs.existsSync(dashboardPath);
|
||||
|
||||
if (dashboardFile || dashboardExists) {
|
||||
return res.json({ errors: {message: 'Dashboard id or filename already exists', type: 'id'}} );
|
||||
return res.json({ error: 'Dashboard id or filename already exists', type: 'id'} );
|
||||
}
|
||||
|
||||
fs.writeFile(dashboardPath, script, err => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче