-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2018 from andrewballantyne/dsp-removed-not-disabled
Handle Removed but not Disabled DS Pipelines
- Loading branch information
Showing
5 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
frontend/src/concepts/pipelines/context/PipelinesContextWorkaround.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* This file is immediately deprecated, this is for a small fix for the next release and will | ||
* be fixed by https://github.com/opendatahub-io/odh-dashboard/issues/2010 | ||
*/ | ||
import * as React from 'react'; | ||
import axios from 'axios'; | ||
import { Bullseye, Spinner } from '@patternfly/react-core'; | ||
import { DataScienceClusterKindStatus } from '~/k8sTypes'; | ||
import useFetchState from '~/utilities/useFetchState'; | ||
import { PipelineContextProvider as PipelineContextProviderActual } from './PipelinesContext'; | ||
|
||
/** | ||
* Should only return `null` when on v1 Operator. | ||
*/ | ||
const fetchDscStatus = (): Promise<DataScienceClusterKindStatus | null> => { | ||
const url = '/api/dsc/status'; | ||
return axios | ||
.get(url) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
if (e.response.status === 404) { | ||
// DSC is not available, assume v1 Operator | ||
return null; | ||
} | ||
throw new Error(e.response.data.message); | ||
}); | ||
}; | ||
|
||
const useFetchDscStatus = () => useFetchState(fetchDscStatus, null); | ||
|
||
/** @deprecated - replaced by https://github.com/opendatahub-io/odh-dashboard/issues/2010 */ | ||
export const PipelineContextProviderWorkaround: React.FC< | ||
React.ComponentProps<typeof PipelineContextProviderActual> | ||
> = ({ children, ...props }) => { | ||
const [dscStatus, loaded] = useFetchDscStatus(); | ||
|
||
if (!loaded) { | ||
return ( | ||
<Bullseye> | ||
<Spinner /> | ||
</Bullseye> | ||
); | ||
} | ||
|
||
if (dscStatus && !dscStatus.installedComponents?.['data-science-pipelines-operator']) { | ||
// eslint-disable-next-line no-console | ||
console.log('Not rendering DS Pipelines Context because there is no backing component.'); | ||
return <>{children}</>; | ||
} | ||
|
||
return <PipelineContextProviderActual {...props}>{children}</PipelineContextProviderActual>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters