- Update getStatusPageByUrl to match BE
- Change layout to use the one that has vertical line - Update name to CreateStatusContext instead of TabContext to make it clearer - Handle errors to land on the respective page tab
This commit is contained in:
1 parent
219bcd4361
commit
c9b804a9ab
5 files changed
+34
-17
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useCallback, useContext } from "react";
|
import { useState, useCallback, useContext } from "react";
|
||||||
import { Button, Box, Stack, Typography } from "@mui/material";
|
import { Button, Box, Stack, Typography } from "@mui/material";
|
||||||
import { ConfigBox } from "../../../Pages/Settings/styled";
|
import { ConfigBox } from "../../../Pages/Uptime/styled";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import TabPanel from "@mui/lab/TabPanel";
|
import TabPanel from "@mui/lab/TabPanel";
|
||||||
import { publicPageGeneralSettingsValidation } from "../../../Validation/validation";
|
import { publicPageGeneralSettingsValidation } from "../../../Validation/validation";
|
||||||
@@ -8,7 +8,7 @@ import { buildErrors } from "../../../Validation/error";
|
|||||||
import Card from "./Card";
|
import Card from "./Card";
|
||||||
import update from "immutability-helper";
|
import update from "immutability-helper";
|
||||||
import Checkbox from "../../Inputs/Checkbox";
|
import Checkbox from "../../Inputs/Checkbox";
|
||||||
import { StatusFormContext } from "../../../Pages/Status/TabContext";
|
import { StatusFormContext } from "../../../Pages/Status/CreateStatusContext";
|
||||||
|
|
||||||
const ContentPanel = () => {
|
const ContentPanel = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -100,11 +100,12 @@ const ContentPanel = () => {
|
|||||||
<Box
|
<Box
|
||||||
className="status-contents-server-list"
|
className="status-contents-server-list"
|
||||||
sx={{
|
sx={{
|
||||||
height: "fit-content",
|
margin: theme.spacing(20),
|
||||||
|
//padding: theme.spacing(20),
|
||||||
border: "solid",
|
border: "solid",
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
borderColor: theme.palette.border.light,
|
borderColor: theme.palette.border.light,
|
||||||
borderWidth: "2px",
|
borderWidth: "1px",
|
||||||
transition: "0.2s",
|
transition: "0.2s",
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
borderColor: theme.palette.primary.main,
|
borderColor: theme.palette.primary.main,
|
||||||
@@ -161,7 +162,7 @@ const ContentPanel = () => {
|
|||||||
<Typography component="p">Show more details on the status page</Typography>
|
<Typography component="p">Show more details on the status page</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack sx={{margin: theme.spacing(20)}}
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id="show-barcode"
|
id="show-barcode"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useRef, useContext } from "react";
|
import { useState, useRef, useContext } from "react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import { ConfigBox } from "../../../Pages/Settings/styled";
|
import { ConfigBox } from "../../../Pages/Uptime/styled";
|
||||||
import Checkbox from "../../Inputs/Checkbox";
|
import Checkbox from "../../Inputs/Checkbox";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import TabPanel from "@mui/lab/TabPanel";
|
import TabPanel from "@mui/lab/TabPanel";
|
||||||
@@ -17,7 +17,7 @@ import { formatBytes } from "../../../Utils/fileUtils";
|
|||||||
import ProgressUpload from "../../ProgressBars";
|
import ProgressUpload from "../../ProgressBars";
|
||||||
import ImageIcon from "@mui/icons-material/Image";
|
import ImageIcon from "@mui/icons-material/Image";
|
||||||
import { HttpAdornment } from "../../Inputs/TextInput/Adornments";
|
import { HttpAdornment } from "../../Inputs/TextInput/Adornments";
|
||||||
import { StatusFormContext } from "../../../Pages/Status/TabContext";
|
import { StatusFormContext } from "../../../Pages/Status/CreateStatusContext";
|
||||||
|
|
||||||
const GeneralSettingsPanel = () => {
|
const GeneralSettingsPanel = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { capitalizeFirstLetter } from "../../../Utils/stringUtils";
|
|||||||
import ContentPanel from "../../../Components/TabPanels/Status/ContentPanel";
|
import ContentPanel from "../../../Components/TabPanels/Status/ContentPanel";
|
||||||
import { publicPageGeneralSettingsValidation } from "../../../Validation/validation";
|
import { publicPageGeneralSettingsValidation } from "../../../Validation/validation";
|
||||||
import { hasValidationErrors } from "../../../Validation/error";
|
import { hasValidationErrors } from "../../../Validation/error";
|
||||||
import { StatusFormProvider } from "../TabContext";
|
import { StatusFormProvider } from "../CreateStatusContext";
|
||||||
/**
|
/**
|
||||||
* CreateStatus page renders a page with tabs for general settings and contents.
|
* CreateStatus page renders a page with tabs for general settings and contents.
|
||||||
* @param {string} [props.open] - Specifies the initially open tab: 'general settings' or 'content'.
|
* @param {string} [props.open] - Specifies the initially open tab: 'general settings' or 'content'.
|
||||||
@@ -19,6 +19,8 @@ const CreateStatus = ({ open = "general-settings", initForm }) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
let tabList = ["General Settings", "Contents"];
|
let tabList = ["General Settings", "Contents"];
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
const error_tab_maping = [["companyName","url","timezone","color","publish","logo"],["monitors",
|
||||||
|
"showUptimePercentage", "showBarcode"]]
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
companyName: "",
|
companyName: "",
|
||||||
url: "",
|
url: "",
|
||||||
@@ -39,6 +41,7 @@ const CreateStatus = ({ open = "general-settings", initForm }) => {
|
|||||||
const [tabIdx, setTabIdx] = useState(tabList.indexOf(tab));
|
const [tabIdx, setTabIdx] = useState(tabList.indexOf(tab));
|
||||||
|
|
||||||
const handleTabChange = (event, newTab) => {
|
const handleTabChange = (event, newTab) => {
|
||||||
|
|
||||||
setTabIdx(tabList.indexOf(newTab));
|
setTabIdx(tabList.indexOf(newTab));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,9 +60,24 @@ const CreateStatus = ({ open = "general-settings", initForm }) => {
|
|||||||
form.logo = { ...logo, size: formatBytes(logo?.size) };
|
form.logo = { ...logo, size: formatBytes(logo?.size) };
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
let newIdx = -1;
|
||||||
|
Object.keys(errors).map(id=>{
|
||||||
|
console.log("errors id")
|
||||||
|
console.log(id)
|
||||||
|
error_tab_maping.map((val, idx) => {
|
||||||
|
let anyMatch = val.some(vl=> vl==id )
|
||||||
|
if(anyMatch){
|
||||||
|
newIdx = idx;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
console.log("newIdx")
|
||||||
|
console.log(newIdx)
|
||||||
|
if(newIdx!==-1)
|
||||||
|
setTabIdx(newIdx)
|
||||||
setTabIdx(tabList.indexOf(tab));
|
setTabIdx(tabList.indexOf(tab));
|
||||||
}, [tab]);
|
}, [tab,errors]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { createContext, useState, React } from "react";
|
import { createContext, React } from "react";
|
||||||
|
|
||||||
const StatusFormContext = createContext({
|
const StatusFormContext = createContext({
|
||||||
form: {},
|
form: {},
|
||||||
@@ -847,13 +847,11 @@ class NetworkService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStatusPageByUrl(config){
|
async getStatusPageByUrl(config) {
|
||||||
const params = new URLSearchParams();
|
const { url, authToken } = config;
|
||||||
params.append("url", encodeURIComponent(config.url));
|
return this.axiosInstance.get(`/status-page/${url}`, {
|
||||||
|
|
||||||
return this.axiosInstance.get(`/status-page?${params.toString()}`, {
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${config.authToken}`,
|
Authorization: `Bearer ${authToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user