mirror of
https://github.com/nickzuber/meteorite.git
synced 2024-09-11 11:36:03 +03:00
Support local env so i can finally stop pushing my token
This commit is contained in:
parent
856281b70a
commit
ecd8b7ef0b
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
|
||||
# meta
|
||||
git-hash.txt
|
||||
.env
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const {execSync} = require('child_process');
|
||||
const fs = require('fs');
|
||||
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
||||
@ -15,7 +15,16 @@ const paths = require('./paths');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
|
||||
|
||||
const gitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
||||
let gitHash = '';
|
||||
let localEnv = {};
|
||||
|
||||
try {
|
||||
gitHash = readFileSync('./git-hash.txt').toString().trim();
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
localEnv = JSON.parse(fs.readFileSync('./.env').toString());
|
||||
} catch (e) {}
|
||||
|
||||
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||
// In development, we always serve from the root. This makes config easier.
|
||||
@ -331,7 +340,8 @@ module.exports = {
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
'GIT_HASH': JSON.stringify(gitHash)
|
||||
'GIT_HASH': JSON.stringify(gitHash),
|
||||
'OAUTH_TOKEN': JSON.stringify(localEnv.OAUTH_TOKEN)
|
||||
}
|
||||
}),
|
||||
// Generates an `index.html` file with the <script> injected.
|
||||
|
@ -24,7 +24,7 @@
|
||||
"case-sensitive-paths-webpack-plugin": "2.1.2",
|
||||
"chalk": "2.4.1",
|
||||
"css-loader": "1.0.0",
|
||||
"dotenv": "6.0.0",
|
||||
"dotenv": "^6.0.0",
|
||||
"dotenv-expand": "4.2.0",
|
||||
"emotion": "^9.2.12",
|
||||
"eslint": "5.6.0",
|
||||
|
@ -494,6 +494,7 @@ class NotificationsPage extends React.Component {
|
||||
fetchNotifications,
|
||||
markAllAsStaged,
|
||||
clearCache,
|
||||
clearArchivedCache,
|
||||
notificationsPermission,
|
||||
loading: isFetchingNotifications,
|
||||
error: fetchingNotificationsError,
|
||||
@ -572,6 +573,7 @@ class NotificationsPage extends React.Component {
|
||||
onMarkAsRead={this.enhancedOnMarkAsRead}
|
||||
onMarkAllAsStaged={markAllAsStaged}
|
||||
onClearCache={clearCache}
|
||||
onClearArchivedCache={clearArchivedCache}
|
||||
onStageThread={this.enhancedOnStageThread}
|
||||
onRestoreThread={this.restoreThread}
|
||||
onRefreshNotifications={this.props.storageApi.refreshNotifications}
|
||||
|
@ -329,6 +329,7 @@ export default function Scene ({
|
||||
onFetchNotifications,
|
||||
onMarkAllAsStaged,
|
||||
onClearCache,
|
||||
onClearArchivedCache,
|
||||
setNotificationsPermission,
|
||||
onStageThread,
|
||||
onArchiveThread,
|
||||
@ -642,6 +643,15 @@ export default function Scene ({
|
||||
<h2>Mark all as read</h2>
|
||||
<p>Move all your unread notifications to the read tab</p>
|
||||
</optimized.div>
|
||||
<optimized.div onClick={event => {
|
||||
event.stopPropagation();
|
||||
const response = window.confirm('Are you sure you want to delete the archived section?');
|
||||
void (response && onClearArchivedCache());
|
||||
setDropdownOpen(false);
|
||||
}}>
|
||||
<h2>Empty archived</h2>
|
||||
<p>Clear all the notifications in the archived section from your local storage</p>
|
||||
</optimized.div>
|
||||
<optimized.div onClick={event => {
|
||||
event.stopPropagation();
|
||||
const response = window.confirm('Are you sure you want to clear the cache?');
|
||||
|
@ -6,7 +6,7 @@ const {Provider, Consumer} = React.createContext();
|
||||
|
||||
class AuthProvider extends React.Component {
|
||||
state = {
|
||||
token: this.props.cookiesApi.getCookie(OAUTH_TOKEN_COOKIE)
|
||||
token: this.props.cookiesApi.getCookie(OAUTH_TOKEN_COOKIE) || process.env.OAUTH_TOKEN
|
||||
}
|
||||
|
||||
setToken = token => {
|
||||
|
@ -220,6 +220,20 @@ class StorageProvider extends React.Component {
|
||||
this.setItem(id, closed_cached_n);
|
||||
}
|
||||
|
||||
clearArchivedCache = () => {
|
||||
const notifications = Object
|
||||
.keys(window.localStorage)
|
||||
.reduce((acc, key) => {
|
||||
if (key.indexOf(LOCAL_STORAGE_PREFIX) > -1) {
|
||||
const cached_n = JSON.parse(window.localStorage.getItem(key));
|
||||
acc.push(cached_n);
|
||||
}
|
||||
return acc;
|
||||
}, [])
|
||||
.filter(notification => notification.status === Status.Archived)
|
||||
.forEach(notification => this.deleteItem(notification.id));
|
||||
}
|
||||
|
||||
clearCache = () => {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
@ -233,6 +247,7 @@ class StorageProvider extends React.Component {
|
||||
setUserItem: this.setUserItem,
|
||||
removeItem: this.removeItem,
|
||||
clearCache: this.clearCache,
|
||||
clearArchivedCache: this.clearArchivedCache,
|
||||
refreshNotifications: this.refreshNotifications,
|
||||
getStat: this.getStat,
|
||||
getAllRepoStagedCounts: this.getAllRepoStagedCounts,
|
||||
|
Loading…
Reference in New Issue
Block a user