Skip to content

Commit

Permalink
Pulling in new react conversion changes (#123)
Browse files Browse the repository at this point in the history
* pulling in new react conversion changes

* fix incorrect import

* fix typescript errors
  • Loading branch information
sperry94 committed Jan 29, 2020
1 parent 024a2a8 commit 6937c58
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 25 deletions.
29 changes: 23 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,18 @@
"@kbn/test-subj-selector": "0.2.1",
"@kbn/ui-framework": "1.0.0",
"@logrhythm/icons": "^1.19.0",
"@logrhythm/nm-web-shared": "1.11.0",
"@logrhythm/nm-web-shared": "1.12.1",
"@logrhythm/webui": "^5.9.15",
"@material-ui/core": "^4.4.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/lab": "^4.0.0-alpha.26",
"@material-ui/styles": "^4.4.1",
"@types/json-stable-stringify": "^1.0.32",
"@types/lodash.clonedeep": "^4.5.4",
"@types/react-grid-layout": "^0.16.7",
"@types/react-router": "^5.1.2",
"@types/recompose": "^0.30.5",
"@types/styled-jsx": "^2.2.8",
"@types/tether": "^1.4.4",
"JSONStream": "1.3.5",
"abortcontroller-polyfill": "^1.3.0",
Expand All @@ -145,11 +151,13 @@
"angular-sanitize": "^1.7.8",
"angular-sortable-view": "^0.0.17",
"autoprefixer": "9.6.1",
"axios": "^0.19.0",
"babel-loader": "^8.0.6",
"bluebird": "3.5.5",
"boom": "^7.2.0",
"bootstrap": "4.0.0-alpha.5",
"brace": "0.11.1",
"bytes": "^3.1.0",
"cache-loader": "^4.1.0",
"chalk": "^2.4.2",
"check-disk-space": "^2.1.0",
Expand All @@ -161,14 +169,17 @@
"custom-event-polyfill": "^0.3.0",
"d3": "3.5.17",
"d3-cloud": "1.2.5",
"date-fns": "^2.1.0",
"del": "^4.1.1",
"dragula": "3.7.0",
"elasticsearch": "^16.5.0",
"elasticsearch-browser": "^16.5.0",
"encode-uri-query": "1.0.1",
"execa": "^1.0.0",
"expiry-js": "0.1.7",
"file-loader": "4.2.0",
"font-awesome": "4.7.0",
"formik": "^1.5.8",
"getos": "^3.1.0",
"glob": "^7.1.2",
"glob-all": "^3.1.0",
Expand All @@ -183,6 +194,7 @@
"hoek": "^5.0.4",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.2",
"immutability-helper": "^3.0.1",
"inert": "^5.1.0",
"inline-style": "^2.0.0",
"joi": "^13.5.2",
Expand All @@ -203,13 +215,16 @@
"lr-style": "^6.10.3",
"lru-cache": "4.1.5",
"markdown-it": "^10.0.0",
"material-table": "^1.52.0",
"mini-css-extract-plugin": "0.8.0",
"minimatch": "^3.0.4",
"moment": "^2.20.1",
"moment-timezone": "^0.5.14",
"mustache": "2.3.2",
"ngreact": "0.5.1",
"no-ui-slider": "1.2.0",
"node-fetch": "1.7.3",
"notistack": "0.9.4",
"opn": "^5.5.0",
"oppsy": "^2.0.0",
"pegjs": "0.10.0",
Expand All @@ -219,10 +234,10 @@
"pug": "^2.0.3",
"querystring-browser": "1.0.4",
"raw-loader": "3.1.0",
"react": "^16.8.0",
"react": "^16.8.6",
"react-addons-shallow-compare": "15.6.2",
"react-color": "^2.13.8",
"react-dom": "^16.8.0",
"react-dom": "^16.8.6",
"react-grid-layout": "^0.16.2",
"react-hooks-testing-library": "^0.5.0",
"react-input-range": "^1.3.0",
Expand Down Expand Up @@ -273,7 +288,8 @@
"webpack": "4.41.0",
"webpack-merge": "4.2.2",
"whatwg-fetch": "^3.0.0",
"yauzl": "2.10.0"
"yauzl": "2.10.0",
"yup": "^0.27.0"
},
"devDependencies": {
"@babel/parser": "^7.5.5",
Expand Down Expand Up @@ -341,9 +357,10 @@
"@types/pngjs": "^3.3.2",
"@types/podium": "^1.0.0",
"@types/prop-types": "^15.5.3",
"@types/puppeteer-core": "^1.9.0",
"@types/reach__router": "^1.2.6",
"@types/react": "^16.8.0",
"@types/react-dom": "^16.8.0",
"@types/react": "^16.8.19",
"@types/react-dom": "^16.8.4",
"@types/react-jss": "^8.6.3",
"@types/react-redux": "^6.0.6",
"@types/react-router-dom": "^4.3.1",
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/ui/public/styles/netmon.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import '~@logrhythm/icons/icons.css';

@import '~@logrhythm/webui/styles.css';

html {
font-size: 14px;
}
Expand Down
92 changes: 92 additions & 0 deletions src/netmon/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useEffect, useState } from 'react';
import { SnackbarProvider } from 'notistack';
import { makeStyles } from '@material-ui/core/styles';
import { AuthContext, AuthContextValue } from '@logrhythm/nm-web-shared/contexts/auth_context';
import {
BlockingProcessContext,
BlockingProcessContextState,
} from '@logrhythm/nm-web-shared/contexts/blocking_process_context';
import BlockingProcessModal from '@logrhythm/nm-web-shared/components/blocking_process/blocking_process_modal';
import { Navbar } from '@logrhythm/nm-web-shared/components/navigation/navbar/navbar';
import Auth from '@logrhythm/nm-web-shared/services/auth';
import NotificationHandler from './notification_handler';

const useStyles = makeStyles(
{
snackbar: {
maxWidth: '20vw',
'& > div': {
borderRadius: 0,
font: '400 100%/1.4 Ubuntu,Tahoma,sans-serif',
flexWrap: 'nowrap',
},
'& a': {
textDecoration: 'underline !important',
},
},
},
{ name: 'Navbar' }
);

const LogRhythmNavbar = () => {
const classes = useStyles();

const [authState, setAuthState] = useState<AuthContextValue>(undefined);

const [blockingProcessMsg, setBlockingProcessMsg] = useState<string>('');
const blockingProcessContextState: BlockingProcessContextState = {
message: blockingProcessMsg,
block: setBlockingProcessMsg,
unblock: () => setBlockingProcessMsg(''),
};

useEffect(() => {
const unsub = Auth.subscribe(setAuthState);

Auth.getCurrentUser();

return unsub;
}, []);

if (authState === undefined) {
return null;
}

return (
<AuthContext.Provider value={[authState, setAuthState]}>
<BlockingProcessContext.Provider value={blockingProcessContextState}>
<SnackbarProvider
maxSnack={7}
classes={{ root: classes.snackbar }}
autoHideDuration={3000}
hideIconVariant={true}
>
<Navbar />
<NotificationHandler />
<BlockingProcessModal />
</SnackbarProvider>
</BlockingProcessContext.Provider>
</AuthContext.Provider>
);
};

export default LogRhythmNavbar; // eslint-disable-line
41 changes: 41 additions & 0 deletions src/netmon/components/notification_handler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useEffect } from 'react';
import { useNotifications } from '@logrhythm/nm-web-shared/hooks/notification_hooks';
import { useSnackbar } from '@logrhythm/nm-web-shared/hooks/notistack_hooks';

const NotificationHandler = () => {
const notifications = useNotifications();

const { enqueueError } = useSnackbar();

useEffect(
() => {
notifications.forEach(n => {
enqueueError(<div>{n.text}</div>);
});
},
[notifications]
);

return null;
};

export default NotificationHandler; // eslint-disable-line
4 changes: 3 additions & 1 deletion src/netmon/components/save_rule/save_rule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import { convertQuery } from '@logrhythm/nm-web-shared/services/query_mapping';
import {
getTriggerCount,
save as saveQueryRule,
saveQueryRule,
QueryRule,
} from '@logrhythm/nm-web-shared/services/query_rules';
import { SaveRuleForm, SaveRuleFormDataValidation } from './save_rule_form';
Expand All @@ -43,6 +43,7 @@ const validateForm = (value: QueryRule | null): SaveRuleFormDataValidation | nul
id: !!value && !!value.id,
severity: !!value && _.contains(['low', 'medium', 'high'], value.severity),
query: !!value && !!value.query,
enabled: true,
};

return _.every(Object.values(validation), v => v) ? null : validation;
Expand Down Expand Up @@ -88,6 +89,7 @@ const reducer = (state: SaveRuleState, action: SaveRuleAction): SaveRuleState =>
id: '',
severity: '',
query: action.query,
enabled: true,
},
saveSuccess: null,
triggerCount: null,
Expand Down
Loading

0 comments on commit 6937c58

Please sign in to comment.