feat: dismiss login alert

This commit is contained in:
Maël Gangloff 2025-12-10 14:49:40 +01:00
parent dcf66b8301
commit 34f01a0019
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
2 changed files with 16 additions and 12 deletions

View File

@ -75,8 +75,9 @@ export default function App(): React.ReactElement {
const [sidebarCollapsed, setSidebarCollapsed] = useState(false) const [sidebarCollapsed, setSidebarCollapsed] = useState(false)
const [isAuthenticated, setIsAuthenticated] = useState<boolean | undefined>(undefined) const [isAuthenticated, setIsAuthenticated] = useState<boolean | undefined>(undefined)
const [configuration, setConfiguration] = useState<InstanceConfig | undefined>(undefined) const [configuration, setConfiguration] = useState<InstanceConfig | undefined>(undefined)
const [darkMode, setDarkMode] = useState(false) const [darkMode, setDarkMode] = useState(false)
const [dismissLoginAlert, setDismissLoginAlert] = useState(() => localStorage.getItem('dismiss-login-alert') === 'true')
const windowQuery = window.matchMedia('(prefers-color-scheme:dark)') const windowQuery = window.matchMedia('(prefers-color-scheme:dark)')
const [messageApi, contextHolder] = message.useMessage() const [messageApi, contextHolder] = message.useMessage()
@ -101,6 +102,8 @@ export default function App(): React.ReactElement {
} }
}, [windowQuery, darkModeChange]) }, [windowQuery, darkModeChange])
useEffect(() => localStorage.setItem('dismiss-login-alert', dismissLoginAlert.toString()), [dismissLoginAlert])
useEffect(() => { useEffect(() => {
setDarkMode(windowQuery.matches) setDarkMode(windowQuery.matches)
getConfiguration().then(configuration => { getConfiguration().then(configuration => {
@ -126,11 +129,12 @@ export default function App(): React.ReactElement {
> >
<ConfigurationContext.Provider value={configContextValue}> <ConfigurationContext.Provider value={configContextValue}>
<AuthenticatedContext.Provider value={authContextValue}> <AuthenticatedContext.Provider value={authContextValue}>
{(configuration?.registerEnabled || configuration?.ssoLogin) && isAuthenticated === false && !['/login', '/home'].includes(location.pathname) && {!dismissLoginAlert && (configuration?.registerEnabled || configuration?.ssoLogin) && isAuthenticated === false && !['/login'].includes(location.pathname) &&
<Alert <Alert
type="warning" type="warning"
message={t`Please log in to access all features, monitor domains, and manage your Connectors.`} message={t`Please log in to access all features, monitor domains, and manage your Connectors.`}
action={<Link to='/login'><Button>{t`Log in`}</Button></Link>} action={<Link to='/login'><Button>{t`Log in`}</Button></Link>}
onClose={() => setDismissLoginAlert(true)}
banner closable/> banner closable/>
} }
<Layout hasSider style={{minHeight: '100vh'}}> <Layout hasSider style={{minHeight: '100vh'}}>

View File

@ -3,48 +3,48 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n" "Plural-Forms: nplurals=2; plural=(n!=1);\n"
#: assets/App.tsx:118 #: assets/App.tsx:121
msgid "Unable to contact the server, please reload the page." msgid "Unable to contact the server, please reload the page."
msgstr "" msgstr ""
#: assets/App.tsx:132 #: assets/App.tsx:135
msgid "" msgid ""
"Please log in to access all features, monitor domains, and manage your " "Please log in to access all features, monitor domains, and manage your "
"Connectors." "Connectors."
msgstr "" msgstr ""
#: assets/App.tsx:133 #: assets/App.tsx:136
#: assets/components/Sider.tsx:158 #: assets/components/Sider.tsx:158
#: assets/pages/LoginPage.tsx:36 #: assets/pages/LoginPage.tsx:36
#: assets/pages/LoginPage.tsx:50 #: assets/pages/LoginPage.tsx:50
msgid "Log in" msgid "Log in"
msgstr "" msgstr ""
#: assets/App.tsx:187 #: assets/App.tsx:191
msgid "TOS" msgid "TOS"
msgstr "" msgstr ""
#: assets/App.tsx:189 #: assets/App.tsx:193
msgid "Privacy Policy" msgid "Privacy Policy"
msgstr "" msgstr ""
#: assets/App.tsx:190 #: assets/App.tsx:194
msgid "FAQ" msgid "FAQ"
msgstr "" msgstr ""
#: assets/App.tsx:194 #: assets/App.tsx:198
msgid "Documentation" msgid "Documentation"
msgstr "" msgstr ""
#: assets/App.tsx:199 #: assets/App.tsx:203
msgid "Source code" msgid "Source code"
msgstr "" msgstr ""
#: assets/App.tsx:204 #: assets/App.tsx:208
msgid "Submit an issue" msgid "Submit an issue"
msgstr "" msgstr ""
#: assets/App.tsx:208 #: assets/App.tsx:212
#, javascript-format #, javascript-format
msgid "" msgid ""
"${ ProjectLink } is an open source project distributed under the ${ " "${ ProjectLink } is an open source project distributed under the ${ "