fix: dependent variable panel not updating (#5283)

* fix: dependent variable panel not updating

* fix: build issues
This commit is contained in:
Vikrant Gupta 2024-06-20 17:21:04 +05:30 committed by GitHub
parent 38b1de5ccc
commit 67965c8e4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View File

@ -138,6 +138,7 @@ function DashboardVariableSelection(): JSX.Element | null {
}} }}
onValueUpdate={onValueUpdate} onValueUpdate={onValueUpdate}
variablesToGetUpdated={variablesToGetUpdated} variablesToGetUpdated={variablesToGetUpdated}
setVariablesToGetUpdated={setVariablesToGetUpdated}
/> />
))} ))}
</Row> </Row>

View File

@ -54,6 +54,7 @@ describe('VariableItem', () => {
existingVariables={{}} existingVariables={{}}
onValueUpdate={mockOnValueUpdate} onValueUpdate={mockOnValueUpdate}
variablesToGetUpdated={[]} variablesToGetUpdated={[]}
setVariablesToGetUpdated={(): void => {}}
/> />
</MockQueryClientProvider>, </MockQueryClientProvider>,
); );
@ -69,6 +70,7 @@ describe('VariableItem', () => {
existingVariables={{}} existingVariables={{}}
onValueUpdate={mockOnValueUpdate} onValueUpdate={mockOnValueUpdate}
variablesToGetUpdated={[]} variablesToGetUpdated={[]}
setVariablesToGetUpdated={(): void => {}}
/> />
</MockQueryClientProvider>, </MockQueryClientProvider>,
); );
@ -83,6 +85,7 @@ describe('VariableItem', () => {
existingVariables={{}} existingVariables={{}}
onValueUpdate={mockOnValueUpdate} onValueUpdate={mockOnValueUpdate}
variablesToGetUpdated={[]} variablesToGetUpdated={[]}
setVariablesToGetUpdated={(): void => {}}
/> />
</MockQueryClientProvider>, </MockQueryClientProvider>,
); );
@ -111,6 +114,7 @@ describe('VariableItem', () => {
existingVariables={{}} existingVariables={{}}
onValueUpdate={mockOnValueUpdate} onValueUpdate={mockOnValueUpdate}
variablesToGetUpdated={[]} variablesToGetUpdated={[]}
setVariablesToGetUpdated={(): void => {}}
/> />
</MockQueryClientProvider>, </MockQueryClientProvider>,
); );
@ -134,6 +138,7 @@ describe('VariableItem', () => {
existingVariables={{}} existingVariables={{}}
onValueUpdate={mockOnValueUpdate} onValueUpdate={mockOnValueUpdate}
variablesToGetUpdated={[]} variablesToGetUpdated={[]}
setVariablesToGetUpdated={(): void => {}}
/> />
</MockQueryClientProvider>, </MockQueryClientProvider>,
); );
@ -149,6 +154,7 @@ describe('VariableItem', () => {
existingVariables={{}} existingVariables={{}}
onValueUpdate={mockOnValueUpdate} onValueUpdate={mockOnValueUpdate}
variablesToGetUpdated={[]} variablesToGetUpdated={[]}
setVariablesToGetUpdated={(): void => {}}
/> />
</MockQueryClientProvider>, </MockQueryClientProvider>,
); );

View File

@ -52,6 +52,7 @@ interface VariableItemProps {
allSelected: boolean, allSelected: boolean,
) => void; ) => void;
variablesToGetUpdated: string[]; variablesToGetUpdated: string[];
setVariablesToGetUpdated: React.Dispatch<React.SetStateAction<string[]>>;
} }
const getSelectValue = ( const getSelectValue = (
@ -73,6 +74,7 @@ function VariableItem({
existingVariables, existingVariables,
onValueUpdate, onValueUpdate,
variablesToGetUpdated, variablesToGetUpdated,
setVariablesToGetUpdated,
}: VariableItemProps): JSX.Element { }: VariableItemProps): JSX.Element {
const [optionsData, setOptionsData] = useState<(string | number | boolean)[]>( const [optionsData, setOptionsData] = useState<(string | number | boolean)[]>(
[], [],
@ -171,6 +173,10 @@ function VariableItem({
} }
setOptionsData(newOptionsData); setOptionsData(newOptionsData);
} else {
setVariablesToGetUpdated((prev) =>
prev.filter((name) => name !== variableData.name),
);
} }
} }
} catch (e) { } catch (e) {