- Make status page url disabled and read from env
- Use ColorPicker for color selection
This commit is contained in:
1 parent
df4a7f6720
commit
df86c926c7
3 files changed
+29
-21
No files matched your search
@@ -17,6 +17,7 @@ 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/CreateStatusContext";
|
import { StatusFormContext } from "../../../Pages/Status/CreateStatusContext";
|
||||||
|
import ColorPicker from "../../Inputs/ColorPicker";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General settings panel is ued to compose part of the public static page
|
* General settings panel is ued to compose part of the public static page
|
||||||
@@ -53,6 +54,13 @@ const GeneralSettingsPanel = () => {
|
|||||||
setProgress({ value: 0, isLoading: false });
|
setProgress({ value: 0, isLoading: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleColorChange = (newValue) => {
|
||||||
|
setForm((prev) => ({
|
||||||
|
...prev,
|
||||||
|
color: newValue,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const { value, id, name } = event.target;
|
const { value, id, name } = event.target;
|
||||||
@@ -114,9 +122,7 @@ const GeneralSettingsPanel = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabPanel
|
<TabPanel value="General settings">
|
||||||
value="General settings"
|
|
||||||
>
|
|
||||||
<Stack
|
<Stack
|
||||||
component="form"
|
component="form"
|
||||||
className="status-general-settings-form"
|
className="status-general-settings-form"
|
||||||
@@ -170,13 +176,13 @@ const GeneralSettingsPanel = () => {
|
|||||||
type="url"
|
type="url"
|
||||||
label="Your status page address"
|
label="Your status page address"
|
||||||
disabled
|
disabled
|
||||||
value={SUBDOAMIN_PREFIX+ STATUS_PAGE}
|
value={form.url ?? STATUS_PAGE}
|
||||||
// startAdornment={
|
startAdornment={
|
||||||
// <HttpAdornment
|
<HttpAdornment
|
||||||
// prefix={SUBDOAMIN_PREFIX}
|
prefix={SUBDOAMIN_PREFIX}
|
||||||
// https={false}
|
https={false}
|
||||||
// />
|
/>
|
||||||
// }
|
}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
helperText={errors["url"]}
|
helperText={errors["url"]}
|
||||||
@@ -227,8 +233,8 @@ const GeneralSettingsPanel = () => {
|
|||||||
onClick={removeLogo}
|
onClick={removeLogo}
|
||||||
sx={{
|
sx={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
maxWidth:"200px",
|
maxWidth: "200px",
|
||||||
alignSelf: "center"
|
alignSelf: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Remove Logo
|
Remove Logo
|
||||||
@@ -236,14 +242,14 @@ const GeneralSettingsPanel = () => {
|
|||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
<TextInput
|
<ColorPicker
|
||||||
id="color"
|
id="color"
|
||||||
label="Color"
|
label="Color"
|
||||||
value={form.color}
|
value={form.color}
|
||||||
error={errors["color"]}
|
error={errors["color"]}
|
||||||
onChange={handleChange}
|
onChange={handleColorChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
/>
|
></ColorPicker>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -31,12 +31,13 @@ import { networkService } from "../../../main";
|
|||||||
];
|
];
|
||||||
const tabList = ["General settings", "Contents"];
|
const tabList = ["General settings", "Contents"];
|
||||||
const hasInitForm = initForm && Object.keys(initForm).length > 0;
|
const hasInitForm = initForm && Object.keys(initForm).length > 0;
|
||||||
|
const STATUS_PAGE = import.meta.env.VITE_STATU_PAGE_URL?? "status-page";
|
||||||
const [form, setForm] = useState(
|
const [form, setForm] = useState(
|
||||||
hasInitForm
|
hasInitForm
|
||||||
? initForm
|
? initForm
|
||||||
: {
|
: {
|
||||||
companyName: "",
|
companyName: "",
|
||||||
url: "",
|
url: STATUS_PAGE,
|
||||||
timezone: "America/Toronto",
|
timezone: "America/Toronto",
|
||||||
color: "#4169E1",
|
color: "#4169E1",
|
||||||
//which fields matching below?
|
//which fields matching below?
|
||||||
@@ -77,7 +78,7 @@ import { networkService } from "../../../main";
|
|||||||
theme: mode,
|
theme: mode,
|
||||||
logo: { type: form.logo?.type ?? "", size: form.logo?.size ?? "" },
|
logo: { type: form.logo?.type ?? "", size: form.logo?.size ?? "" },
|
||||||
};
|
};
|
||||||
//delete localData.logo
|
delete localData.logo
|
||||||
if (
|
if (
|
||||||
hasValidationErrors(localData, publicPageGeneralSettingsValidation, setErrors)
|
hasValidationErrors(localData, publicPageGeneralSettingsValidation, setErrors)
|
||||||
) {
|
) {
|
||||||
@@ -85,8 +86,9 @@ import { networkService } from "../../../main";
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//form.logo = { ...logo, size: formatBytes(logo?.size) };
|
//localData.logo = form.logo
|
||||||
let config = { authToken: authToken, url: "status-page", data: localData };
|
localData.url = STATUS_PAGE
|
||||||
|
let config = { authToken: authToken, url: STATUS_PAGE, data: localData };
|
||||||
try {
|
try {
|
||||||
const res = await networkService.createStatusPage(config);
|
const res = await networkService.createStatusPage(config);
|
||||||
if (!res.status === 200) {
|
if (!res.status === 200) {
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ const Status = () => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const {authToken} = useSelector((state) => state.auth);
|
const {authToken} = useSelector((state) => state.auth);
|
||||||
const {apiBaseUrl} = useSelector((state) => state.settings);
|
|
||||||
const [initForm, setInitForm] = useState({});
|
const [initForm, setInitForm] = useState({});
|
||||||
|
const STATUS_PAGE = import.meta.env.VITE_STATU_PAGE_URL?? "status-page";
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getStatusPage = async () => {
|
const getStatusPage = async () => {
|
||||||
let config = { authToken: authToken, url: "status-page" };
|
let config = { authToken: authToken, url: STATUS_PAGE };
|
||||||
try {
|
try {
|
||||||
let res = await networkService.getStatusPageByUrl(config);
|
let res = await networkService.getStatusPageByUrl(config);
|
||||||
if(res && res.data)
|
if(res && res.data)
|
||||||
|
|||||||
Reference in new issue
Block a user