Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend updates from internal fork #5209

Merged
merged 8 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😁

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