mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
fix feature enable/disable issue
This commit is contained in:
@@ -86,6 +86,28 @@ class Query(BaseModel):
|
|||||||
"""Create SHA256 hash digest of model representation."""
|
"""Create SHA256 hash digest of model representation."""
|
||||||
return hashlib.sha256(repr(self).encode()).hexdigest()
|
return hashlib.sha256(repr(self).encode()).hexdigest()
|
||||||
|
|
||||||
|
@validator("query_type")
|
||||||
|
def validate_query_type(cls, value):
|
||||||
|
"""Ensure query_type is enabled.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
value {str} -- Query Type
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
InputInvalid: Raised if query_type is disabled.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
{str} -- Valid query_type
|
||||||
|
"""
|
||||||
|
query_type_obj = getattr(params.queries, value)
|
||||||
|
if not query_type_obj.enable:
|
||||||
|
raise InputInvalid(
|
||||||
|
params.messages.feature_not_enabled,
|
||||||
|
level="warning",
|
||||||
|
feature=query_type_obj.display_name,
|
||||||
|
)
|
||||||
|
return value
|
||||||
|
|
||||||
@validator("query_location")
|
@validator("query_location")
|
||||||
def validate_query_location(cls, value):
|
def validate_query_location(cls, value):
|
||||||
"""Ensure query_location is defined.
|
"""Ensure query_location is defined.
|
||||||
|
@@ -28,9 +28,9 @@ class Messages(HyperglassModel):
|
|||||||
description="Displayed when a query target is implicitly denied by a matched VRF's ACL. `{target}` may be used to display the denied query target.",
|
description="Displayed when a query target is implicitly denied by a matched VRF's ACL. `{target}` may be used to display the denied query target.",
|
||||||
)
|
)
|
||||||
feature_not_enabled: StrictStr = Field(
|
feature_not_enabled: StrictStr = Field(
|
||||||
"{feature} is not enabled for {device_name}.",
|
"{feature} is not enabled.",
|
||||||
title="Feature Not Enabled",
|
title="Feature Not Enabled",
|
||||||
description="Displayed when a query type is submitted that is not supported or disabled. The hyperglass UI performs validation of supported query types prior to submitting any requests, so this is primarily relevant to the hyperglass API. `{feature}` and `{device_name}` may be used to display the disabled feature and the selected device/location.",
|
description="Displayed when a query type is submitted that is not supported or disabled. The hyperglass UI performs validation of supported query types prior to submitting any requests, so this is primarily relevant to the hyperglass API. `{feature}` may be used to display the disabled feature.",
|
||||||
)
|
)
|
||||||
invalid_input: StrictStr = Field(
|
invalid_input: StrictStr = Field(
|
||||||
"{target} is not a valid {query_type} target.",
|
"{target} is not a valid {query_type} target.",
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import ChakraSelect from "~/components/ChakraSelect";
|
import ChakraSelect from "~/components/ChakraSelect";
|
||||||
|
|
||||||
const buildQueries = queryTypes => {
|
|
||||||
const queries = [];
|
|
||||||
queryTypes.map(q => {
|
|
||||||
queries.push({ value: q.name, label: q.display_name });
|
|
||||||
});
|
|
||||||
return queries;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ({ queryTypes, onChange }) => {
|
export default ({ queryTypes, onChange }) => {
|
||||||
const queries = buildQueries(queryTypes);
|
const queries = queryTypes
|
||||||
|
.filter(q => q.enable === true)
|
||||||
|
.map(q => {
|
||||||
|
return { value: q.name, label: q.display_name };
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<ChakraSelect
|
<ChakraSelect
|
||||||
size="lg"
|
size="lg"
|
||||||
|
Reference in New Issue
Block a user