Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
Frontend updates from internal fork (getredash#5209)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldutra authored Oct 15, 2020
1 parent db4e97f commit 9097feb
Show file tree
Hide file tree
Showing 40 changed files with 924 additions and 491 deletions.
7 changes: 7 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ module.exports = {
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
"jsx-a11y/anchor-is-valid": "off",
"no-restricted-imports": [
"error",
{
name: "antd",
message: "Please use antd/lib instead.",
},
],
},
overrides: [
{
Expand Down
18 changes: 15 additions & 3 deletions client/app/components/ApplicationArea/ErrorMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { isObject, get } from "lodash";
import { get, isObject } from "lodash";
import React from "react";
import PropTypes from "prop-types";

import "./ErrorMessage.less";
import DynamicComponent from "@/components/DynamicComponent";
import { ErrorMessageDetails } from "@/components/ApplicationArea/ErrorMessageDetails";

function getErrorMessageByStatus(status, defaultMessage) {
switch (status) {
Expand Down Expand Up @@ -31,21 +33,30 @@ function getErrorMessage(error) {
return message;
}

export default function ErrorMessage({ error }) {
export default function ErrorMessage({ error, message }) {
if (!error) {
return null;
}

console.error(error);

const errorDetailsProps = {
error,
message: message || getErrorMessage(error),
};

return (
<div className="error-message-container" data-test="ErrorMessage">
<div className="error-state bg-white tiled">
<div className="error-state__icon">
<i className="zmdi zmdi-alert-circle-o" />
</div>
<div className="error-state__details">
<h4>{getErrorMessage(error)}</h4>
<DynamicComponent
name="ErrorMessageDetails"
fallback={<ErrorMessageDetails {...errorDetailsProps} />}
{...errorDetailsProps}
/>
</div>
</div>
</div>
Expand All @@ -54,4 +65,5 @@ export default function ErrorMessage({ error }) {

ErrorMessage.propTypes = {
error: PropTypes.object.isRequired,
message: PropTypes.string,
};
11 changes: 11 additions & 0 deletions client/app/components/ApplicationArea/ErrorMessageDetails.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import PropTypes from "prop-types";

export function ErrorMessageDetails(props) {
return <h4>{props.message}</h4>;
}

ErrorMessageDetails.propTypes = {
error: PropTypes.instanceOf(Error).isRequired,
message: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function handleNavigationIntent(event) {
}
element = element.parentNode;
}
if (!element || !element.hasAttribute("href") || element.hasAttribute("download")) {
if (!element || !element.hasAttribute("href") || element.hasAttribute("download") || element.dataset.skipRouter) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions client/app/components/DialogWrapper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export function wrap<ROk = void, P = {}, RCancel = void>(
props?: P
) => {
update: (props: P) => void;
onClose: (handler: (result: ROk) => Promise<void>) => void;
onDismiss: (handler: (result: RCancel) => Promise<void>) => void;
onClose: (handler: (result: ROk) => Promise<void> | void) => void;
onDismiss: (handler: (result: RCancel) => Promise<void> | void) => void;
close: (result: ROk) => void;
dismiss: (result: RCancel) => void;
};
Expand Down
Loading

0 comments on commit 9097feb

Please sign in to comment.