Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling in new react conversion changes #123

Merged
merged 3 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,17 @@
"@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-router": "^5.1.2",
"@types/recompose": "^0.30.5",
"@types/styled-jsx": "^2.2.8",
"@types/tether": "^1.4.4",
"JSONStream": "1.1.1",
"abortcontroller-polyfill": "^1.1.9",
Expand All @@ -137,11 +143,13 @@
"angular-sanitize": "1.6.5",
"angular-sortable-view": "0.0.15",
"autoprefixer": "^9.1.0",
"axios": "^0.19.0",
"babel-loader": "8.0.5",
"bluebird": "3.5.3",
"boom": "^7.2.0",
"bootstrap": "4.0.0-alpha.5",
"brace": "0.11.1",
"bytes": "^3.1.0",
"cache-loader": "1.2.2",
"chalk": "^2.4.1",
"color": "1.0.3",
Expand All @@ -152,6 +160,7 @@
"custom-event-polyfill": "^0.3.0",
"d3": "3.5.6",
"d3-cloud": "1.2.1",
"date-fns": "^2.1.0",
"del": "^3.0.0",
"dragula": "3.7.0",
"elasticsearch": "^16.1.0",
Expand All @@ -161,6 +170,7 @@
"expiry-js": "0.1.7",
"file-loader": "2.0.0",
"font-awesome": "4.4.0",
"formik": "^1.5.8",
"getos": "^3.1.0",
"glob": "^7.1.2",
"glob-all": "^3.1.0",
Expand All @@ -174,6 +184,7 @@
"hoek": "^5.0.4",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.1",
"immutability-helper": "^3.0.1",
"inert": "^5.1.0",
"joi": "^13.5.2",
"jquery": "^3.4.1",
Expand All @@ -193,6 +204,7 @@
"lr-style": "^6.10.3",
"lru-cache": "4.1.1",
"markdown-it": "^8.4.1",
"material-table": "^1.52.0",
"mini-css-extract-plugin": "0.4.4",
"minimatch": "^3.0.4",
"mkdirp": "0.5.1",
Expand All @@ -202,6 +214,7 @@
"ngreact": "0.5.1",
"no-ui-slider": "1.2.0",
"node-fetch": "1.3.2",
"notistack": "0.9.4",
"opn": "^5.4.0",
"oppsy": "^2.0.0",
"pegjs": "0.9.0",
Expand All @@ -211,10 +224,10 @@
"pug": "^2.0.3",
"querystring-browser": "1.0.4",
"raw-loader": "0.5.1",
"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-input-range": "^1.3.0",
"react-jss": "^10.0.0",
Expand Down Expand Up @@ -262,7 +275,8 @@
"webpack": "4.23.1",
"webpack-merge": "4.1.4",
"whatwg-fetch": "^3.0.0",
"yauzl": "2.7.0"
"yauzl": "2.7.0",
"yup": "^0.27.0"
},
"devDependencies": {
"@babel/parser": "^7.3.4",
Expand Down Expand Up @@ -325,8 +339,8 @@
"@types/podium": "^1.0.0",
"@types/prop-types": "^15.5.3",
"@types/puppeteer-core": "^1.9.0",
"@types/react": "^16.8.0",
"@types/react-dom": "^16.8.0",
"@types/react": "^16.8.19",
"@types/react-dom": "^16.8.4",
"@types/react-redux": "^6.0.6",
"@types/react-router-dom": "^4.3.1",
"@types/react-virtualized": "^9.18.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { RecentlyAccessedHistoryItem } from 'ui/persisted_log';
import { ChromeHeaderNavControlsRegistry } from 'ui/registry/chrome_header_nav_controls';
import { relativeToAbsolute } from 'ui/url/relative_to_absolute';

import { Navbar } from '@logrhythm/nm-web-shared';
import LogRhythmNavbar from '../../../../../../../netmon/components/navbar';

import { ChromeBadge, ChromeBreadcrumb, ChromeNavLink } from '../../../../../../../core/public';

Expand Down Expand Up @@ -269,7 +269,7 @@ class HeaderUI extends Component<Props, State> {

return (
<Fragment>
<Navbar currentPage="analyze" />
<LogRhythmNavbar />

<EuiNavDrawer ref={this.navDrawerRef} data-test-subj="navDrawer">
<EuiNavDrawerGroup listItems={recentLinksArray} />
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