
Add links instead of navigate + onClick in: * Lists - ex. product list (except Plugins, see below) * SortableTables - ex. product variants * Sidebar * Buttons that open new page - ex. "Create product" * Backlinks * Menus - ex. "Account Settings" * Links that actually used onClick - ex. warehouse shipping zone, reset password
16 lines
637 B
TypeScript
16 lines
637 B
TypeScript
import { OverridableComponent } from "@material-ui/core/OverridableComponent";
|
|
import { Button as MacawButton, ButtonTypeMap } from "@saleor/macaw-ui";
|
|
import { isExternalURL } from "@saleor/utils/urls";
|
|
import React from "react";
|
|
import { Link } from "react-router-dom";
|
|
|
|
const _Button: React.FC<any> = React.forwardRef(({ href, ...props }, ref) => {
|
|
if (href && !isExternalURL(href)) {
|
|
return <MacawButton {...props} to={href} component={Link} ref={ref} />;
|
|
}
|
|
|
|
return <MacawButton href={href} {...props} ref={ref} />;
|
|
});
|
|
_Button.displayName = "Button";
|
|
|
|
export const Button = _Button as OverridableComponent<ButtonTypeMap>;
|