remove proto storage logic

This commit is contained in:
Arthur Tu
2021-06-10 11:23:41 -05:00
committed by yuqiuw
parent 36ace74575
commit 408055ec08
6 changed files with 2 additions and 54 deletions
-8
View File
@@ -4,7 +4,6 @@ import {Notifier} from './components/notifier';
import Error from './components/error';
import {initRouter} from './router';
import log from './utils/log';
import {setContext, Context} from './utils/localStorageHelpers';
import Button from './components/button';
import LogoSvg from './art/skoonerSvg';
import HamburgerSvg from './art/hamburgerSvg';
@@ -29,7 +28,6 @@ class App extends Component<{}, State> {
this.setState({content, contentDate: Date.now(), hasError: false});
window.scrollTo(0, 0);
});
this.setContext();
}
componentDidCatch(err: Error, info: any) { // eslint-disable-line class-methods-use-this
@@ -37,12 +35,6 @@ class App extends Component<{}, State> {
this.setState({hasError: true});
}
setContext() {
api.context().then((context: Context) => {
setContext(context);
});
}
render() {
const {content, contentDate, hasError, menuToggled} = this.state || {};
-5
View File
@@ -46,7 +46,6 @@ const apis = {
exec,
metrics: metricsFactory(),
oidc: oidcFactory(),
context,
clusterRole,
namespace: namespaceService,
@@ -188,8 +187,4 @@ function logs(namespace: string, name: string, container: string, tailLines: num
}
}
function context() {
return request('/context');
}
export default apis;
+2 -2
View File
@@ -2,7 +2,7 @@ import _ from 'lodash';
import {getToken, logout} from './auth';
import log from '../utils/log';
import {ApiItem} from '../utils/types';
import {isProtoEligible, isProtoEnabled, protoParser} from '../utils/protoHelpers';
import {isProtoEligible, protoParser} from '../utils/protoHelpers';
type StreamCallback<T> = (data: T) => void;
type ErrorCallback = (err: Error) => void;
@@ -62,7 +62,7 @@ async function requestInner(path: string, params?: any, autoLogoutOnAuthError =
}
export async function request(path: string, params?: any, autoLogoutOnAuthError = true) {
if (isProtoEligible(path) && isProtoEnabled()) {
if (isProtoEligible(path)) {
return requestProto(path, params, autoLogoutOnAuthError);
}
return requestJson(path, params, autoLogoutOnAuthError);
-26
View File
@@ -1,26 +0,0 @@
const CONTEXT = 'context';
export type Context = {
protoEnabled?: boolean;
promethusEnabled?: boolean;
}
export function getContextItem(item: string) {
return getItem(CONTEXT)[item];
}
export function setContext(context: Context) {
setItem(CONTEXT, {
protoEnabled: true,
promethusEnabled: false,
...context,
});
}
export function setItem(item: string, object: Object) {
localStorage.setItem(item, JSON.stringify(object));
}
export function getItem(item: string) {
return JSON.parse(localStorage.getItem(item) || '');
}
-5
View File
@@ -1,5 +1,4 @@
import {k8s} from '../proto/proto';
import {getContextItem} from './localStorageHelpers';
const {Unknown} = k8s.io.apimachinery.pkg.runtime;
const {NodeMetrics} = k8s.io.metrics.pkg.apis.metrics.v1beta1;
@@ -68,10 +67,6 @@ export function protoParser(raw: Uint8Array) {
return {};
}
export function isProtoEnabled(): boolean {
return getContextItem('protoEnabled');
}
export function isProtoEligible(url: string) {
for (const value of Object.values(kindMap)) {
if (value.paths.some(path => url.includes(path))) {
-8
View File
@@ -14,7 +14,6 @@ const OIDC_SECRET = process.env.OIDC_SECRET;
const OIDC_URL = process.env.OIDC_URL;
const OIDC_SCOPES = process.env.OIDC_SCOPES || 'openid email';
const OIDC_METADATA = JSON.parse(process.env.OIDC_METADATA || '{}');
const USE_PROTO = process.env.USE_PROTO !== 'false' || true;
const clientMetadata = Object.assign({client_id: OIDC_CLIENT_ID, client_secret: OIDC_SECRET}, OIDC_METADATA);
console.log('OIDC_URL: ', OIDC_URL || 'None');
@@ -51,7 +50,6 @@ if (NODE_ENV !== 'production') app.use(cors());
app.use('/', preAuth, express.static('public'));
app.get('/oidc', getOidc);
app.post('/oidc', postOidc);
app.get('/context', getContext);
app.use('/*', createProxyMiddleware(proxySettings));
app.use(handleErrors);
@@ -59,12 +57,6 @@ const port = process.env.SERVER_PORT || 4654;
http.createServer(app).listen(port);
console.log(`Server started. Listening on port ${port}`);
function getContext(req, res) {
res.json({
"protoEnabled": USE_PROTO,
})
}
function preAuth(req, res, next) {
const auth = req.header('Authorization');