@kaspernj/api-maker 1.0.173 → 1.0.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/base-error.cjs +5 -1
- package/src/commands-pool.cjs +5 -1
- package/src/config.js +5 -1
- package/src/link.jsx +12 -6
package/package.json
CHANGED
package/src/base-error.cjs
CHANGED
|
@@ -6,7 +6,11 @@ class BaseError extends Error {
|
|
|
6
6
|
let messageToUse = message
|
|
7
7
|
|
|
8
8
|
if (typeof args.response == "object" && dig(args, "response", "errors")) {
|
|
9
|
-
|
|
9
|
+
if (message) {
|
|
10
|
+
messageToUse = `${messageToUse}: ${errorMessages(args).join(". ")}`
|
|
11
|
+
} else {
|
|
12
|
+
messageToUse = errorMessages(args).join(". ")
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
super(messageToUse)
|
package/src/commands-pool.cjs
CHANGED
|
@@ -162,7 +162,11 @@ module.exports = class ApiMakerCommandsPool {
|
|
|
162
162
|
})
|
|
163
163
|
error = new ValidationError(validationErrors, {response: commandResponseData})
|
|
164
164
|
} else {
|
|
165
|
-
|
|
165
|
+
let errorMessage
|
|
166
|
+
|
|
167
|
+
if (!commandResponseData.errors) { errorMessage = "Command failed" }
|
|
168
|
+
|
|
169
|
+
error = new CustomError(errorMessage, {response: commandResponseData})
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
commandData.reject(error)
|
package/src/config.js
CHANGED
package/src/link.jsx
CHANGED
|
@@ -5,17 +5,23 @@ export default class Link extends React.PureComponent {
|
|
|
5
5
|
const {to, onClick, ...restProps} = this.props
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
|
-
<a href={to} {...restProps} onClick={
|
|
8
|
+
<a href={to} {...restProps} onClick={this.onLinkClicked} />
|
|
9
9
|
)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
onLinkClicked = (e) => {
|
|
13
|
-
|
|
12
|
+
onLinkClicked = (e, ...restArgs) => {
|
|
13
|
+
const {onClick} = this.props
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
if (onClick) onClick(e, ...restArgs)
|
|
16
16
|
|
|
17
|
-
if (!
|
|
17
|
+
if (!e.defaultPrevented) {
|
|
18
|
+
e.preventDefault()
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
const history = global.apiMakerConfigGlobal?.history
|
|
21
|
+
|
|
22
|
+
if (!history) throw new Error("History hasn't been set in the API maker configuration")
|
|
23
|
+
|
|
24
|
+
history.push(this.props.to)
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
}
|