Skip to content

Commit

Permalink
rendered default axes selected and added error toasts on Save and App…
Browse files Browse the repository at this point in the history
…ly click if invalid value option selected

Signed-off-by: rinku-kumar-psl <[email protected]>
  • Loading branch information
rinku-kumar-psl committed May 13, 2022
1 parent 291d17f commit b8f8671
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 7 deletions.
26 changes: 25 additions & 1 deletion dashboards-observability/common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { IField } from '../../common/types/explorer';
import CSS from 'csstype';

// Client route
Expand Down Expand Up @@ -71,9 +72,32 @@ export const pageStyles: CSS.Properties = {
maxWidth: '1130px',
};


export enum visChartTypes {
Bar = 'bar',
HorizontalBar = 'horizontal_bar',
Line = 'line',
Pie = 'pie',
HeatMap = 'heatmap',
Text = 'text',
Gauge = 'gauge',
Histogram = 'histogram',
TreeMap = 'tree_map'
}

export interface ValueOptionsAxes {
xaxis ?: IField[];
yaxis ?: IField[];
zaxis ?: IField[];
childField?: IField[];
valueField?: IField[];
series?: IField[];
value?: IField[];
}

export const NUMERICAL_FIELDS = ['short', 'integer', 'long', 'float', 'double'];

export const ENABLED_VIS_TYPES = ['bar', 'horizontal_bar', 'line', 'pie', 'heatmap', 'text'];
export const ENABLED_VIS_TYPES = [visChartTypes.Bar, visChartTypes.HorizontalBar, visChartTypes.Line, visChartTypes.Pie, visChartTypes.HeatMap, visChartTypes.Text];

//Live tail constants
export const LIVE_OPTIONS = [
Expand Down
1 change: 1 addition & 0 deletions dashboards-observability/common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface IQueryTab {
export interface IField {
name: string;
type: string;
label?: string;
}

export interface ITabQueryResults {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ exports[`Utils helper functions renders displayVisualization function 1`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -224,12 +226,14 @@ exports[`Utils helper functions renders displayVisualization function 1`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -461,12 +465,14 @@ exports[`Utils helper functions renders displayVisualization function 1`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -853,12 +859,14 @@ exports[`Utils helper functions renders displayVisualization function 2`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -1084,12 +1092,14 @@ exports[`Utils helper functions renders displayVisualization function 2`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -1369,12 +1379,14 @@ exports[`Utils helper functions renders displayVisualization function 2`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -1788,12 +1800,14 @@ exports[`Utils helper functions renders displayVisualization function 3`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -1996,12 +2010,14 @@ exports[`Utils helper functions renders displayVisualization function 3`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -2227,12 +2243,14 @@ exports[`Utils helper functions renders displayVisualization function 3`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "Carrier",
"name": "Carrier",
"type": "keyword",
},
],
"yaxis": Array [
Object {
"label": "avg(FlightDelayMin)",
"name": "avg(FlightDelayMin)",
"type": "double",
},
Expand Down Expand Up @@ -2613,12 +2631,14 @@ exports[`Utils helper functions renders displayVisualization function 4`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "span(timestamp,1h)",
"name": "span(timestamp,1h)",
"type": "timestamp",
},
],
"yaxis": Array [
Object {
"label": "count('ip')",
"name": "count('ip')",
"type": "integer",
},
Expand Down Expand Up @@ -2794,12 +2814,14 @@ exports[`Utils helper functions renders displayVisualization function 4`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "span(timestamp,1h)",
"name": "span(timestamp,1h)",
"type": "timestamp",
},
],
"yaxis": Array [
Object {
"label": "count('ip')",
"name": "count('ip')",
"type": "integer",
},
Expand Down Expand Up @@ -2998,12 +3020,14 @@ exports[`Utils helper functions renders displayVisualization function 4`] = `
"defaultAxes": Object {
"xaxis": Array [
Object {
"label": "span(timestamp,1h)",
"name": "span(timestamp,1h)",
"type": "timestamp",
},
],
"yaxis": Array [
Object {
"label": "count('ip')",
"name": "count('ip')",
"type": "integer",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const Explorer = ({
const [browserTabFocus, setBrowserTabFocus] = useState(true);
const [liveTimestamp, setLiveTimestamp] = useState(DATE_PICKER_FORMAT);
const [triggerAvailability, setTriggerAvailability] = useState(false);
const [isValidDataConfigOptionSelected, setIsValidDataConfigOptionSelected] = useState<Boolean>(false);

const queryRef = useRef();
const appBasedRef = useRef('');
Expand Down Expand Up @@ -727,6 +728,9 @@ export const Explorer = ({
}
};

const changeIsValidConfigOptionState = (isValidConfig: Boolean) =>
setIsValidDataConfigOptionSelected(isValidConfig);

const getExplorerVis = () => {
return (
<ExplorerVisualizations
Expand All @@ -741,6 +745,7 @@ export const Explorer = ({
visualizations={visualizations}
handleOverrideTimestamp={handleOverrideTimestamp}
callback={callbackForConfig}
changeIsValidConfigOptionState={changeIsValidConfigOptionState}
/>
);
};
Expand Down Expand Up @@ -835,6 +840,10 @@ export const Explorer = ({
setToast('Name field cannot be empty.', 'danger');
return;
}
if (!isValidDataConfigOptionSelected) {
setToast('Invalid value options configuration selected.', 'danger');
return;
}
setIsPanelTextFieldInvalid(false);
if (isEqual(selectedContentTabId, TAB_EVENT_ID)) {
const isTabMatchingSavedType = isEqual(currQuery![SAVED_OBJECT_TYPE], SAVED_QUERY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

exports[`Config panel component Renders config panel with visualization data 1`] = `
<ConfigPanel
changeIsValidConfigOptionState={
[MockFunction] {
"calls": Array [
Array [
true,
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
setCurVisId={[MockFunction]}
visualizations={
Object {
Expand Down Expand Up @@ -2541,6 +2556,11 @@ exports[`Config panel component Renders config panel with visualization data 1`]
},
}
}
vizState={
Object {
"valueOptions": Object {},
}
}
/>,
"id": "data-panel",
"name": "Data",
Expand Down Expand Up @@ -2962,6 +2982,11 @@ exports[`Config panel component Renders config panel with visualization data 1`]
},
}
}
vizState={
Object {
"valueOptions": Object {},
}
}
/>,
"id": "data-panel",
"name": "Data",
Expand Down Expand Up @@ -3830,6 +3855,11 @@ exports[`Config panel component Renders config panel with visualization data 1`]
},
}
}
vizState={
Object {
"valueOptions": Object {},
}
}
>
<div
className="visEditorSidebar__config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Config panel component', () => {
const tabId = 'query-panel-1';
const curVisId = 'bar';
const pplService = new PPLService(httpClientMock);
const mockChangeIsValidConfigOptionState = jest.fn();

const wrapper = mount(
<TabContext.Provider
Expand All @@ -39,7 +40,7 @@ describe('Config panel component', () => {
pplService: pplService,
}}
>
<ConfigPanel visualizations={TEST_VISUALIZATIONS_DATA} setCurVisId={setCurVisId} />
<ConfigPanel visualizations={TEST_VISUALIZATIONS_DATA} setCurVisId={setCurVisId} changeIsValidConfigOptionState={mockChangeIsValidConfigOptionState} />
</TabContext.Provider>
);

Expand Down
Loading

0 comments on commit b8f8671

Please sign in to comment.