Sebas prompt for api key (#171)
* chore: prompt users when they dont have api key set up * bump extension version
This commit is contained in:
committed by
GitHub
parent
e57bdbbfc4
commit
ffd2a48b29
@@ -1,11 +1,17 @@
|
|||||||
import React from 'react';
|
import React, { MouseEventHandler, CSSProperties } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { SuccessOrFailType } from '../config/config';
|
import { SuccessOrFailType } from '../config/config';
|
||||||
interface AlertProps {
|
interface AlertProps {
|
||||||
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
||||||
|
style?: CSSProperties;
|
||||||
text: string;
|
text: string;
|
||||||
type: SuccessOrFailType;
|
type: SuccessOrFailType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Alert({ type, text }: AlertProps): JSX.Element {
|
export default function Alert({ onClick, style, type, text }: AlertProps): JSX.Element {
|
||||||
return <div className={classNames('alert', `alert-${type}`)}>{text}</div>;
|
return (
|
||||||
|
<div className={classNames('alert', `alert-${type}`)} onClick={onClick} style={style}>
|
||||||
|
{text}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import React, { useEffect } from 'react';
|
|||||||
import { useSelector, useDispatch } from 'react-redux';
|
import { useSelector, useDispatch } from 'react-redux';
|
||||||
import { ApiKeyReducer, ReduxSelector } from '../types/store';
|
import { ApiKeyReducer, ReduxSelector } from '../types/store';
|
||||||
import { fetchUserData } from '../utils/user';
|
import { fetchUserData } from '../utils/user';
|
||||||
|
import apiKeyInvalid from '../utils/apiKey';
|
||||||
|
import config from '../config/config';
|
||||||
|
import Alert from './Alert';
|
||||||
import NavBar from './NavBar';
|
import NavBar from './NavBar';
|
||||||
import MainList from './MainList';
|
import MainList from './MainList';
|
||||||
|
|
||||||
@@ -18,9 +21,19 @@ export default function WakaTime(): JSX.Element {
|
|||||||
void fetchUserData(apiKeyFromRedux, dispatch);
|
void fetchUserData(apiKeyFromRedux, dispatch);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const isApiKeyValid = apiKeyInvalid(apiKeyFromRedux) === '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<NavBar />
|
<NavBar />
|
||||||
|
{!isApiKeyValid && (
|
||||||
|
<Alert
|
||||||
|
type={config.alert.failure.type}
|
||||||
|
text={'Please update your api key'}
|
||||||
|
onClick={() => browser.runtime.openOptionsPage()}
|
||||||
|
style={{ cursor: 'pointer' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
|
|||||||
@@ -26,5 +26,5 @@
|
|||||||
"page": "options.html"
|
"page": "options.html"
|
||||||
},
|
},
|
||||||
"permissions": ["alarms", "tabs", "storage", "idle"],
|
"permissions": ["alarms", "tabs", "storage", "idle"],
|
||||||
"version": "3.0.0"
|
"version": "3.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,5 +39,5 @@
|
|||||||
"storage",
|
"storage",
|
||||||
"idle"
|
"idle"
|
||||||
],
|
],
|
||||||
"version": "3.0.0"
|
"version": "3.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user