mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-06 21:43:37 +00:00
fix(ui): authenticate pipeline status api call (#21257)
* fix(ui): authenticate pipeline status api call * fix tests
This commit is contained in:
parent
764b1702b4
commit
7a73598a93
@ -24,6 +24,16 @@ jest.mock('../../rest/ingestionPipelineAPI', () => ({
|
|||||||
getAirflowStatus: jest.fn(),
|
getAirflowStatus: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
jest.mock('../../hooks/useApplicationStore', () => {
|
||||||
|
return {
|
||||||
|
useApplicationStore: jest.fn().mockImplementation(() => ({
|
||||||
|
currentUser: {
|
||||||
|
id: '123',
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// Mock component to test the context
|
// Mock component to test the context
|
||||||
const TestComponent = () => {
|
const TestComponent = () => {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { PipelineServiceClientResponse } from '../../generated/entity/services/ingestionPipelines/pipelineServiceClientResponse';
|
import { PipelineServiceClientResponse } from '../../generated/entity/services/ingestionPipelines/pipelineServiceClientResponse';
|
||||||
|
import { useApplicationStore } from '../../hooks/useApplicationStore';
|
||||||
import { getAirflowStatus } from '../../rest/ingestionPipelineAPI';
|
import { getAirflowStatus } from '../../rest/ingestionPipelineAPI';
|
||||||
import { AirflowStatusContextType } from './AirflowStatusProvider.interface';
|
import { AirflowStatusContextType } from './AirflowStatusProvider.interface';
|
||||||
|
|
||||||
@ -40,8 +41,12 @@ const AirflowStatusProvider = ({ children }: Props) => {
|
|||||||
useState<PipelineServiceClientResponse['reason']>();
|
useState<PipelineServiceClientResponse['reason']>();
|
||||||
const [platform, setPlatform] =
|
const [platform, setPlatform] =
|
||||||
useState<PipelineServiceClientResponse['platform']>('unknown');
|
useState<PipelineServiceClientResponse['platform']>('unknown');
|
||||||
|
const { currentUser } = useApplicationStore();
|
||||||
|
|
||||||
const fetchAirflowStatus = useCallback(async () => {
|
const fetchAirflowStatus = useCallback(async () => {
|
||||||
|
if (!currentUser?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await getAirflowStatus();
|
const response = await getAirflowStatus();
|
||||||
@ -54,11 +59,11 @@ const AirflowStatusProvider = ({ children }: Props) => {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [currentUser?.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAirflowStatus();
|
fetchAirflowStatus();
|
||||||
}, []);
|
}, [fetchAirflowStatus]);
|
||||||
|
|
||||||
const value: AirflowStatusContextType = useMemo(
|
const value: AirflowStatusContextType = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user