Skip to content

Commit

Permalink
Alerting Tab and minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimi-Ma authored and Dimi-Ma committed May 2, 2023
1 parent 849900c commit c220571
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const AlertingView = () => {
}
`}</style>
<div className="this">
<TabMenu className="menu" model={items} activeItem={activeTab} onTabChange={(e) => setActiveTab(e.value)} />
<TabMenu className="menu" model={items} activeitem={activeTab} onTabChange={(e) => setActiveTab(e.value)} />

{activeTab === items[0] && (
<AlertingRulesView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, {useState, useEffect, useRef} from 'react';
import { useSelector, useDispatch } from 'react-redux';
import classNames from 'classnames';
import _, { uniq } from 'lodash';
Expand All @@ -16,7 +16,7 @@ const AlertingRulesTree = ({ rules, templates, unsavedRules, onSelectionChanged,
const dispatch = useDispatch();

// state variables
const [contextMenu, setContextMenu] = useState(null);
const contextMenuRef = useRef(null);
const [treeIndex, setTreeIndex] = useState({});
const [treeData, setTreeData] = useState(null);

Expand Down Expand Up @@ -69,6 +69,11 @@ const AlertingRulesTree = ({ rules, templates, unsavedRules, onSelectionChanged,
onSelectionChanged(newSelection);
};

const showContextMenu = (event) => {
event.originalEvent.persist()
contextMenuRef.current.show(event.originalEvent)
}

return (
<>
<style jsx>{`
Expand Down Expand Up @@ -102,10 +107,10 @@ const AlertingRulesTree = ({ rules, templates, unsavedRules, onSelectionChanged,
`}</style>

<div className="this">
<ContextMenu className="context-menu" model={contextMenuItems} ref={(el) => setContextMenu(el)} />
<ContextMenu className="p-contextmenu" model={contextMenuItems} ref={contextMenuRef} />

<Tree
onContextMenu={(event) => contextMenu.show(event.originalEvent)}
onContextMenu={showContextMenu}
filter={true}
filterBy="label"
value={treeData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FileTree extends React.Component {
event.originalEvent.stopPropagation();
return;
}

event.originalEvent.persist();
this.setState({ contextMenuModel: this.getContextMenuModel(newSelection) });
this.contextMenuRef.current.show(event.originalEvent || event);
};
Expand Down

0 comments on commit c220571

Please sign in to comment.