-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb5672
commit c22b20f
Showing
7 changed files
with
205 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useState, useEffect, useRef } from 'react'; | ||
import { TextArea } from '@patternfly/react-core'; | ||
|
||
const DotStringEditor = ({ dotString, onDotStringChange }) => { | ||
const [localDotString, setLocalDotString] = useState(dotString); | ||
const timeoutRef = useRef(null); | ||
|
||
useEffect(() => { | ||
setLocalDotString(dotString); | ||
}, [dotString]); | ||
|
||
const handleChange = (value) => { | ||
setLocalDotString(value); | ||
|
||
// Clear the existing timeout if there is one | ||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
|
||
// Set a new timeout to trigger the update after 1 second of inactivity | ||
timeoutRef.current = setTimeout(() => { | ||
onDotStringChange(value); | ||
}, 1000); // 1 second delay | ||
}; | ||
|
||
// Clear the timeout on component unmount | ||
useEffect(() => { | ||
return () => { | ||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="dot-string-editor"> | ||
<h3>Edit DOT String</h3> | ||
<TextArea | ||
value={localDotString} | ||
onChange={handleChange} | ||
aria-label="DOT string editor" | ||
rows={15} | ||
resizeOrientation="vertical" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DotStringEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core'; | ||
|
||
const PickResource = ({ graph, onResourceSelect }) => { | ||
const [isDropdownOpen, setIsDropdownOpen] = useState(false); | ||
const [dropdownItems, setDropdownItems] = useState([]); | ||
const [selectedLabel, setSelectedLabel] = useState('Select a resource'); | ||
|
||
useEffect(() => { | ||
if (graph) { | ||
const items = [ | ||
<DropdownItem key="reset" component="button" onClick={() => handleSelection(null)}> | ||
- | ||
</DropdownItem>, | ||
...graph.nodes().map(node => ( | ||
<DropdownItem key={node} component="button" onClick={() => handleSelection(node)}> | ||
{graph.node(node).label} | ||
</DropdownItem> | ||
)), | ||
]; | ||
setDropdownItems(items); | ||
} | ||
}, [graph]); | ||
|
||
const handleSelection = (nodeId) => { | ||
setSelectedLabel(nodeId ? graph.node(nodeId).label : 'Select a resource'); | ||
onResourceSelect(nodeId); | ||
setIsDropdownOpen(false); | ||
}; | ||
|
||
const onToggle = (isOpen) => { | ||
setIsDropdownOpen(isOpen); | ||
}; | ||
|
||
return ( | ||
<Dropdown | ||
onSelect={() => setIsDropdownOpen(false)} | ||
toggle={<DropdownToggle onToggle={onToggle}>{selectedLabel}</DropdownToggle>} | ||
isOpen={isDropdownOpen} | ||
dropdownItems={dropdownItems} | ||
/> | ||
); | ||
}; | ||
|
||
export default PickResource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { Button } from '@patternfly/react-core'; | ||
|
||
const ResetPolicyTopology = ({ onReset }) => { | ||
return ( | ||
<Button variant="secondary" onClick={onReset} style={{ marginLeft: '10px' }}> | ||
Reset Graph | ||
</Button> | ||
); | ||
}; | ||
|
||
export default ResetPolicyTopology; |