Merge pull request #2192 from Br0wnHammer/fix/fe/rerender-ui-components
Fix: Re-render of Unrelated UI Components
This commit is contained in:
2 files changed
+5
-5
No files matched your search
@@ -1,14 +1,13 @@
|
|||||||
import { Stack, Button } from "@mui/material";
|
import { Stack, Button } from "@mui/material";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import SkeletonLayout from "./skeleton";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
|
|
||||||
const CreateMonitorHeader = ({
|
const CreateMonitorHeader = ({
|
||||||
isAdmin,
|
isAdmin,
|
||||||
label = "Create new",
|
label = "Create new",
|
||||||
shouldRender = true,
|
isLoading = true,
|
||||||
path,
|
path,
|
||||||
bulkPath,
|
bulkPath,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -17,7 +16,6 @@ const CreateMonitorHeader = ({
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (!isAdmin) return null;
|
if (!isAdmin) return null;
|
||||||
if (!shouldRender) return <SkeletonLayout />;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
@@ -27,6 +25,7 @@ const CreateMonitorHeader = ({
|
|||||||
gap={theme.spacing(6)}
|
gap={theme.spacing(6)}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
|
loading={isLoading}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="accent"
|
color="accent"
|
||||||
onClick={() => navigate(path)}
|
onClick={() => navigate(path)}
|
||||||
@@ -35,6 +34,7 @@ const CreateMonitorHeader = ({
|
|||||||
</Button>
|
</Button>
|
||||||
{bulkPath && (
|
{bulkPath && (
|
||||||
<Button
|
<Button
|
||||||
|
loading={isLoading}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="accent"
|
color="accent"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -52,7 +52,7 @@ export default CreateMonitorHeader;
|
|||||||
|
|
||||||
CreateMonitorHeader.propTypes = {
|
CreateMonitorHeader.propTypes = {
|
||||||
isAdmin: PropTypes.bool.isRequired,
|
isAdmin: PropTypes.bool.isRequired,
|
||||||
shouldRender: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
bulkPath: PropTypes.string,
|
bulkPath: PropTypes.string,
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ const UptimeMonitors = () => {
|
|||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
<CreateMonitorHeader
|
<CreateMonitorHeader
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
shouldRender={!isLoading}
|
isLoading={isLoading}
|
||||||
path="/uptime/create"
|
path="/uptime/create"
|
||||||
bulkPath="/uptime/bulk-import"
|
bulkPath="/uptime/bulk-import"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user