📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added i18n, confirmation modal and other improvements
Blue Mouse21b12c1865f3
diff --git a/public/locales/en.json b/public/locales/en.jsonindex 71421b893..4d36e4be5 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -341,7 +341,14 @@"2faRecoveryNote": "Important: If you cannot use your authenticator app, because you've deleted the app or lost your device, you'll need a way to access your account and disable 2FA.\n\nYou can use this recovery code to disable 2FA. Write it down and store it in a safe, secure place.","2faRecoverySaved": "I have saved this recovery code","2faEnabled": "Two-factor authenticated is enabled on your account.",- "2faDisableHint": "To disable two-factor authentication, please enter your 6-digit code or one of your recovery codes below."+ "2faDisableHint": "To disable two-factor authentication, please enter your 6-digit code or one of your recovery codes below.",+ "apiKey": "API Key",+ "noApiKey": "You haven't created any API keys yet.",+ "apiKeyWarning": "Treat your API Key like a password and keep it secret. Never hardcode it into your programs, or share it with anyone.",+ "addApiKeyBtn": "Generate API Key",+ "deleteApiKeyBtn": "Delete API Key",+ "apiKeyDelete": "Delete your API Key?",+ "apiKeyDeleteConf": "Are you sure you want to delete your API key?\nAll API access via this key will be disabled."},"dashboard": {"newProject": "New project",diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsxindex 1f8adeaf1..20095eb4a 100644--- a/src/pages/UserSettings/UserSettings.container.jsx+++ b/src/pages/UserSettings/UserSettings.container.jsx@@ -143,7 +143,6 @@ const UserSettingsContainer = () => {const onApiKeyGenerate = async () => {try {const res = await generateApiKey()- console.log(res)dispatch(authActions.setApiKey(res.apiKey))} catch (e) {dispatch(errorsActions.updateProfileFailed(e))@@ -152,8 +151,7 @@ const UserSettingsContainer = () => {const onApiKeyDelete = async () => {try {- const res = await deleteApiKey()- console.log(res)+ await deleteApiKey()dispatch(authActions.setApiKey(null))} catch (e) {dispatch(errorsActions.updateProfileFailed(e))diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsxindex a2ea6fc4e..7a2f3b20a 100644--- a/src/pages/UserSettings/UserSettings.jsx+++ b/src/pages/UserSettings/UserSettings.jsx@@ -372,6 +372,7 @@ const UserSettings = ({const [errors, setErrors] = useState({})const [beenSubmitted, setBeenSubmitted] = useState(false)const [showModal, setShowModal] = useState(false)+ const [showAPIDeleteModal, setShowAPIDeleteModal] = useState(false)const [showExportModal, setShowExportModal] = useState(false)const [error, setError] = useState(null)const translatedFrequencies = _map(reportFrequencies, (key) => t(`profileSettings.${key}`)) // useMemo(_map(reportFrequencies, (key) => t(`profileSettings.${key}`)), [t])@@ -537,32 +538,41 @@ const UserSettings = ({</Button><hr className='mt-5' /><h3 className='flex items-center mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>- Api-key+ {t('profileSettings.apiKey')}<div className='ml-5'><Beta /></div></h3>- <div className='grid grid-cols-1 gap-y-6 gap-x-4 lg:grid-cols-2 mt-4'>- <div>- <Input- name='apiKey'- id='apiKey'- type='text'- label='Generated Api-key'- value={user.apiKey || ''}- className='mt-4'- onChange={handleInput}- disabled- />- </div>- </div>{user.apiKey ? (- <Button className='mt-4' onClick={onApiKeyDelete} danger large>- Delete api-key+ <>+ <p className='max-w-prose text-base text-gray-900 dark:text-gray-50'>+ {t('profileSettings.apiKeyWarning')}+ </p>+ <div className='grid grid-cols-1 gap-y-6 gap-x-4 lg:grid-cols-2'>+ <Input+ name='apiKey'+ id='apiKey'+ type='text'+ label={t('profileSettings.apiKey')}+ value={user.apiKey}+ className='mt-4'+ onChange={handleInput}+ disabled+ />+ </div>+ </>+ ) : (+ <p className='max-w-prose text-base text-gray-900 dark:text-gray-50'>+ {t('profileSettings.noApiKey')}+ </p>+ )}+ {user.apiKey ? (+ <Button className='mt-4' onClick={() => setShowAPIDeleteModal(true)} danger large>+ {t('profileSettings.deleteApiKeyBtn')}</Button>) : (<Button className='mt-4' onClick={onApiKeyGenerate} primary large>- Generate api-key+ {t('profileSettings.addApiKeyBtn')}</Button>)}<hr className='mt-5' />@@ -676,6 +686,17 @@ const UserSettings = ({message={t('profileSettings.deactivateConfirmation')}isOpened={showModal}/>+ <Modal+ onClose={() => setShowAPIDeleteModal(false)}+ onSubmit={() => { setShowAPIDeleteModal(false); onApiKeyDelete() }}+ submitText={t('profileSettings.deleteApiKeyBtn')}+ closeText={t('common.close')}+ title={t('profileSettings.apiKeyDelete')}+ submitType='danger'+ type='error'+ message={t('profileSettings.apiKeyDeleteConf')}+ isOpened={showAPIDeleteModal}+ /><ModalonClose={() => { setError('') }}closeText={t('common.gotIt')}diff --git a/src/redux/actions/auth/index.js b/src/redux/actions/auth/index.jsindex 53d830913..36e47df23 100644--- a/src/redux/actions/auth/index.js+++ b/src/redux/actions/auth/index.js@@ -144,5 +144,4 @@ export const authActions = {payload: { apiKey },}},-}