Skip to content

Commit

Permalink
Pull relevant bugfixes from upstream project (#327)
Browse files Browse the repository at this point in the history
Signed-off-by: James Phillips <[email protected]>
  • Loading branch information
jamesdphillips authored Jul 8, 2020
1 parent 7654efe commit a73ce69
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ContextSwitcherList = ({
useEffect(() => {
const onKeyPress = (ev: KeyboardEvent) => {
if (ev.code === "Tab" || ev.code === "ArrowDown") {
setIdx(Math.min(idx + 1, items.length));
setIdx(Math.min(idx + 1, Math.max(items.length - 1, 0)));
ev.preventDefault();
}

Expand All @@ -84,8 +84,8 @@ const ContextSwitcherList = ({
ev.preventDefault();
}

if (ev.code === "Enter") {
onSelect(items[idx]); // TODO
if (ev.code === "Enter" && items.length > 0) {
onSelect(items[Math.min(idx, items.length - 1)]);
ev.preventDefault();
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/component/partial/EventsList/EventsListHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class EventsListHeader extends React.Component {
};

updateSort = newValue => {
this.props.onChangeQuery(params => ({ order: newValue, ...params }));
this.props.onChangeQuery(params => ({ ...params, order: newValue }));
};

renderBulkActions = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ const styles = () => ({
},
});

// eslint-disable-next-line react/prop-types
const JSONValue = ({ object }) => {
const str = JSON.stringify(object);

return (
<React.Fragment>
{str.length > 7 ? str.slice(0, 7) + "..." : "JSON"}{" "}
<OpenInNewIcon fontSize="inherit" />
</React.Fragment>
);
};

class ExpandableKeyValueChip extends React.Component {
static propTypes = {
children: PropTypes.object.isRequired,
Expand All @@ -40,7 +52,13 @@ class ExpandableKeyValueChip extends React.Component {
<React.Fragment key={key}>
<ModalController
renderModal={({ close }) => (
<Dialog open maxWidth="sm" fullWidth TransitionComponent={Slide} onClose={close}>
<Dialog
open
maxWidth="sm"
fullWidth
TransitionComponent={Slide}
onClose={close}
>
<DialogTitle>{key}</DialogTitle>
<DialogContent>
<CodeBlock>
Expand All @@ -52,9 +70,7 @@ class ExpandableKeyValueChip extends React.Component {
</CodeBlock>
</DialogContent>
<DialogActions>
<Button onClick={close}>
Close
</Button>
<Button onClick={close}>Close</Button>
</DialogActions>
</Dialog>
)}
Expand All @@ -74,10 +90,10 @@ class ExpandableKeyValueChip extends React.Component {
variant="body2"
className={classes.iconFix}
>
<OpenInNewIcon fontSize="inherit" />
<JSONValue object={children[key]} />
</Typography>
) : (
children[key]
children[key].toString() || "[empty]"
)
}
onClick={open}
Expand Down

0 comments on commit a73ce69

Please sign in to comment.