fix(ui): UI doesn't need to calculate which annotation is hidden by default, backend provides this information

This commit is contained in:
Łukasz Mierzwa
2018-09-01 21:20:22 +01:00
parent c6b3bb5000
commit 2dbbef2f3e
3 changed files with 5 additions and 30 deletions

View File

@@ -50,6 +50,7 @@ const Alert = observer(
key={a.name}
name={a.name}
value={a.value}
visible={a.visible}
afterUpdate={afterUpdate}
/>
))}

View File

@@ -1,7 +1,7 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { observable, action, toJS } from "mobx";
import { observable, action } from "mobx";
import { observer, inject } from "mobx-react";
import Linkify from "react-linkify";
@@ -20,6 +20,7 @@ const RenderNonLinkAnnotation = inject("alertStore")(
alertStore: PropTypes.object.isRequired,
name: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
visible: PropTypes.bool.isRequired,
afterUpdate: PropTypes.func.isRequired
};
@@ -45,7 +46,7 @@ const RenderNonLinkAnnotation = inject("alertStore")(
constructor(props) {
super(props);
this.toggle.visible = this.isVisible();
this.toggle.visible = props.visible;
}
componentDidUpdate() {
@@ -54,34 +55,6 @@ const RenderNonLinkAnnotation = inject("alertStore")(
afterUpdate();
}
// determinate if this annotation should be hidden by default or not
isVisible() {
const { alertStore, name } = this.props;
const annotationsHidden = toJS(
alertStore.settings.values.annotationsHidden
);
const isInHidden =
annotationsHidden !== null && annotationsHidden.indexOf(name) >= 0;
const annotationsVisible = toJS(
alertStore.settings.values.annotationsVisible
);
const isInVisible =
annotationsVisible !== null && annotationsVisible.indexOf(name) >= 0;
if (isInVisible) return true;
if (
toJS(alertStore.settings.values.annotationsDefaultHidden) === true ||
isInHidden === true
) {
return false;
}
return true;
}
render() {
const { name, value } = this.props;

View File

@@ -28,6 +28,7 @@ const GroupFooter = observer(
key={a.name}
name={a.name}
value={a.value}
visible={a.visible}
afterUpdate={afterUpdate}
/>
))}