simplify star prompt translations and state
This commit is contained in:
1 parent
c185979479
commit
0f2832b728
4 files changed
+14
-15
No files matched your search
@@ -4,7 +4,7 @@ import CloseIcon from '@mui/icons-material/Close';
|
|||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import { useSelector, useDispatch } from 'react-redux';
|
import { useSelector, useDispatch } from 'react-redux';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { setStarPromptClosed } from '../../Features/UI/uiSlice';
|
import { setStarPromptOpen } from '../../Features/UI/uiSlice';
|
||||||
|
|
||||||
const StarPrompt = ({
|
const StarPrompt = ({
|
||||||
repoUrl = 'https://github.com/bluewave-labs/checkmate'
|
repoUrl = 'https://github.com/bluewave-labs/checkmate'
|
||||||
@@ -12,18 +12,18 @@ const StarPrompt = ({
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const isClosed = useSelector((state) => state.ui?.starPrompt?.closed ?? false);
|
const isOpen = useSelector((state) => state.ui?.starPromptOpen ?? true);
|
||||||
const mode = useSelector((state) => state.ui.mode);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
dispatch(setStarPromptClosed(true));
|
dispatch(setStarPromptOpen(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleStarClick = () => {
|
const handleStarClick = () => {
|
||||||
window.open(repoUrl, '_blank');
|
window.open(repoUrl, '_blank');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isClosed) return null;
|
if (!isOpen) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
@@ -46,7 +46,7 @@ const StarPrompt = ({
|
|||||||
mt: theme.spacing(3)
|
mt: theme.spacing(3)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('starPrompt.title')}
|
{t('starPromptTitle')}
|
||||||
</Typography>
|
</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
@@ -75,7 +75,7 @@ const StarPrompt = ({
|
|||||||
px: theme.spacing(4)
|
px: theme.spacing(4)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('starPrompt.description')}
|
{t('starPromptDescription')}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ const initialState = {
|
|||||||
timezone: "America/Toronto",
|
timezone: "America/Toronto",
|
||||||
distributedUptimeEnabled: false,
|
distributedUptimeEnabled: false,
|
||||||
language: "gb",
|
language: "gb",
|
||||||
starPrompt: {
|
starPromptOpen: true,
|
||||||
closed: false
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const uiSlice = createSlice({
|
const uiSlice = createSlice({
|
||||||
@@ -58,11 +56,8 @@ const uiSlice = createSlice({
|
|||||||
setLanguage(state, action) {
|
setLanguage(state, action) {
|
||||||
state.language = action.payload;
|
state.language = action.payload;
|
||||||
},
|
},
|
||||||
setStarPromptClosed(state, action) {
|
setStarPromptOpen: (state, action) => {
|
||||||
if (!state.starPrompt) {
|
state.starPromptOpen = action.payload;
|
||||||
state.starPrompt = {};
|
|
||||||
}
|
|
||||||
state.starPrompt.closed = action.payload;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -76,5 +71,5 @@ export const {
|
|||||||
setTimezone,
|
setTimezone,
|
||||||
setDistributedUptimeEnabled,
|
setDistributedUptimeEnabled,
|
||||||
setLanguage,
|
setLanguage,
|
||||||
setStarPromptClosed,
|
setStarPromptOpen,
|
||||||
} = uiSlice.actions;
|
} = uiSlice.actions;
|
||||||
@@ -108,6 +108,8 @@
|
|||||||
"settingsFailedToAddDemoMonitors": "Failed to add demo monitors",
|
"settingsFailedToAddDemoMonitors": "Failed to add demo monitors",
|
||||||
"settingsMonitorsDeleted": "Successfully deleted all monitors",
|
"settingsMonitorsDeleted": "Successfully deleted all monitors",
|
||||||
"settingsFailedToDeleteMonitors": "Failed to delete all monitors",
|
"settingsFailedToDeleteMonitors": "Failed to delete all monitors",
|
||||||
|
"starPromptTitle": "Star Checkmate",
|
||||||
|
"starPromptDescription": "See the latest releases and help grow the community on GitHub",
|
||||||
"starPrompt": {
|
"starPrompt": {
|
||||||
"title": "Star Checkmate",
|
"title": "Star Checkmate",
|
||||||
"description": "See the latest releases and help grow the community on GitHub"
|
"description": "See the latest releases and help grow the community on GitHub"
|
||||||
|
|||||||
@@ -102,6 +102,8 @@
|
|||||||
"settingsFailedToAddDemoMonitors": "Demo monitörler eklenemedi",
|
"settingsFailedToAddDemoMonitors": "Demo monitörler eklenemedi",
|
||||||
"settingsMonitorsDeleted": "Tüm monitörler başarıyla silindi",
|
"settingsMonitorsDeleted": "Tüm monitörler başarıyla silindi",
|
||||||
"settingsFailedToDeleteMonitors": "Monitörler silinemedi",
|
"settingsFailedToDeleteMonitors": "Monitörler silinemedi",
|
||||||
|
"starPromptTitle": "Checkmate yıldızla değerlendirin",
|
||||||
|
"starPromptDescription": "En son sürümleri görün ve GitHub'daki topluluğun büyümesine yardımcı olun",
|
||||||
"starPrompt": {
|
"starPrompt": {
|
||||||
"title": "Checkmate yıldızla değerlendirin",
|
"title": "Checkmate yıldızla değerlendirin",
|
||||||
"description": "En son sürümleri görün ve GitHub'daki topluluğun büyümesine yardımcı olun"
|
"description": "En son sürümleri görün ve GitHub'daki topluluğun büyümesine yardımcı olun"
|
||||||
|
|||||||
Reference in new issue
Block a user