-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Canvas] Fixes Uploaded asset not being saved. (#133166)
* Fixed upload assets and update workpad logic. * Fixed onAssetAdd type. Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
3df948c
commit 6beedb6
Showing
12 changed files
with
125 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { i18n } from '@kbn/i18n'; | ||
import { AssetType, CanvasAsset } from '../../types'; | ||
import { CanvasNotifyService } from '../services/notify'; | ||
import { getId } from './get_id'; | ||
|
||
const strings = { | ||
getSaveFailureTitle: () => | ||
i18n.translate('xpack.canvas.error.esPersist.saveFailureTitle', { | ||
defaultMessage: "Couldn't save your changes to Elasticsearch", | ||
}), | ||
getTooLargeErrorMessage: () => | ||
i18n.translate('xpack.canvas.error.esPersist.tooLargeErrorMessage', { | ||
defaultMessage: | ||
'The server gave a response that the workpad data was too large. This usually means uploaded image assets that are too large for Kibana or a proxy. Try removing some assets in the asset manager.', | ||
}), | ||
getUpdateFailureTitle: () => | ||
i18n.translate('xpack.canvas.error.esPersist.updateFailureTitle', { | ||
defaultMessage: "Couldn't update workpad", | ||
}), | ||
}; | ||
|
||
export const createAsset = (type: AssetType['type'], content: AssetType['value']): CanvasAsset => ({ | ||
id: getId('asset'), | ||
type, | ||
value: content, | ||
'@created': new Date().toISOString(), | ||
}); | ||
|
||
export const notifyError = (err: any, notifyErrorFn: CanvasNotifyService['error']) => { | ||
const statusCode = err.response && err.response.status; | ||
switch (statusCode) { | ||
case 400: | ||
return notifyErrorFn(err.response, { | ||
title: strings.getSaveFailureTitle(), | ||
}); | ||
case 413: | ||
return notifyErrorFn(strings.getTooLargeErrorMessage(), { | ||
title: strings.getSaveFailureTitle(), | ||
}); | ||
default: | ||
return notifyErrorFn(err, { | ||
title: strings.getUpdateFailureTitle(), | ||
}); | ||
} | ||
}; |
Oops, something went wrong.