mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-03 01:18:43 +02:00
fix: maintenance banner should show right away when toggled (#5021)
Makes the maintenance banner show right away when toggled. Includes some misc cleaning up. Co-authored-by: Nicolae <nicolae@getunleash.ai>
This commit is contained in:
parent
75fb7a0d93
commit
e663dc0960
@ -1,4 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
@ -10,6 +9,7 @@ import { useMaintenance } from 'hooks/api/getters/useMaintenance/useMaintenance'
|
|||||||
import { useMaintenanceApi } from 'hooks/api/actions/useMaintenanceApi/useMaintenanceApi';
|
import { useMaintenanceApi } from 'hooks/api/actions/useMaintenanceApi/useMaintenanceApi';
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
import useToast from 'hooks/useToast';
|
import useToast from 'hooks/useToast';
|
||||||
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
|
|
||||||
const StyledContainer = styled('div')(({ theme }) => ({
|
const StyledContainer = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -19,12 +19,12 @@ const StyledContainer = styled('div')(({ theme }) => ({
|
|||||||
borderRadius: theme.shape.borderRadiusLarge,
|
borderRadius: theme.shape.borderRadiusLarge,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const CardTitleRow = styled(Box)(({ theme }) => ({
|
const CardTitleRow = styled(Box)({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
}));
|
});
|
||||||
|
|
||||||
const CardDescription = styled(Box)(({ theme }) => ({
|
const CardDescription = styled(Box)(({ theme }) => ({
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
@ -38,6 +38,7 @@ const SwitchLabel = styled(Typography)(({ theme }) => ({
|
|||||||
|
|
||||||
export const MaintenanceToggle = () => {
|
export const MaintenanceToggle = () => {
|
||||||
const { enabled, refetchMaintenance } = useMaintenance();
|
const { enabled, refetchMaintenance } = useMaintenance();
|
||||||
|
const { refetch: refetchUiConfig } = useUiConfig();
|
||||||
const { toggleMaintenance } = useMaintenanceApi();
|
const { toggleMaintenance } = useMaintenanceApi();
|
||||||
const { trackEvent } = usePlausibleTracker();
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const { setToastData } = useToast();
|
const { setToastData } = useToast();
|
||||||
@ -55,6 +56,7 @@ export const MaintenanceToggle = () => {
|
|||||||
});
|
});
|
||||||
await toggleMaintenance({ enabled: !enabled });
|
await toggleMaintenance({ enabled: !enabled });
|
||||||
refetchMaintenance();
|
refetchMaintenance();
|
||||||
|
refetchUiConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user