-
Notifications
You must be signed in to change notification settings - Fork 2
move PD api endpoints to hooks #1053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ee4e630
move PD api endpoints to hooks
TheGostKasper af803c4
fix snapshots testing
TheGostKasper f2094e0
fix snapshots onSuccess
TheGostKasper cd873ef
update snapshots
TheGostKasper 4698bb7
Merge branch 'main' into pd-move-api-toHook
TheGostKasper 408ea11
Merge branch 'main' into pd-move-api-toHook
TheGostKasper fca520f
add canaries count to details page
TheGostKasper ee77191
Merge branch 'pd-move-api-toHook' of https://github.com/weaveworks/we…
TheGostKasper e0a5107
Merge branch 'main' of https://github.com/weaveworks/weave-gitops-ent…
TheGostKasper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
14 changes: 3 additions & 11 deletions
14
ui-cra/src/components/ProgressiveDelivery/Events/ListEvents.tsx
This file contains hidden or 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
25 changes: 5 additions & 20 deletions
25
ui-cra/src/components/ProgressiveDelivery/ListCanaries/CanariesList.tsx
This file contains hidden or 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 |
---|---|---|
@@ -1,40 +1,25 @@ | ||
import { CanaryTable } from './Table'; | ||
import { | ||
ListCanariesResponse, | ||
ProgressiveDeliveryService, | ||
} from '@weaveworks/progressive-delivery'; | ||
import { useQuery } from 'react-query'; | ||
import { LoadingPage } from '@weaveworks/weave-gitops'; | ||
import { Alert } from '@material-ui/lab'; | ||
import { Canary } from '@weaveworks/progressive-delivery/api/prog/types.pb'; | ||
import { useListCanaries } from '../../../hooks/progressiveDelivery'; | ||
|
||
const CANARIES_POLL_INTERVAL = 60000; | ||
|
||
const ProgressiveDelivery = ({ | ||
onCountChange, | ||
}: { | ||
onCountChange: (count: number) => void; | ||
}) => { | ||
const { error, data, isLoading } = useQuery<ListCanariesResponse, Error>( | ||
'canaries', | ||
() => | ||
ProgressiveDeliveryService.ListCanaries({}).then(res => { | ||
onCountChange(res.canaries?.length || 0); | ||
return res; | ||
}), | ||
{ | ||
refetchInterval: CANARIES_POLL_INTERVAL, | ||
}, | ||
const { error, data, isLoading } = useListCanaries(res => | ||
onCountChange(res.canaries?.length || 0), | ||
); | ||
return ( | ||
<> | ||
{isLoading && <LoadingPage />} | ||
{error && <Alert severity="error">{error.message}</Alert>} | ||
{data?.canaries && ( | ||
<CanaryTable canaries={data.canaries as Canary[]} /> | ||
)} | ||
{data?.canaries && <CanaryTable canaries={data.canaries as Canary[]} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default ProgressiveDelivery; | ||
export default ProgressiveDelivery; |
This file contains hidden or 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 hidden or 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,73 @@ | ||
import { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whop! |
||
GetCanaryResponse, | ||
IsFlaggerAvailableResponse, | ||
ListCanariesResponse, | ||
ProgressiveDeliveryService, | ||
} from '@weaveworks/progressive-delivery'; | ||
import { useQuery } from 'react-query'; | ||
import { | ||
ClustersService, | ||
ListEventsRequest, | ||
ListEventsResponse, | ||
} from '../cluster-services/cluster_services.pb'; | ||
|
||
interface FlaggerStatus { | ||
isFlaggerAvailable: boolean; | ||
} | ||
|
||
export function useIsFlaggerAvailable() { | ||
return useQuery<FlaggerStatus, Error>('flagger', () => | ||
ProgressiveDeliveryService.IsFlaggerAvailable({}).then( | ||
({ clusters }: IsFlaggerAvailableResponse) => { | ||
return clusters === undefined || Object.keys(clusters).length === 0 | ||
? { isFlaggerAvailable: false } | ||
: { | ||
isFlaggerAvailable: Object.values(clusters).some( | ||
(value: boolean) => value === true, | ||
), | ||
}; | ||
}, | ||
), | ||
); | ||
} | ||
const CANARIES_POLL_INTERVAL = 60000; | ||
export function useListCanaries(clb: (res: ListCanariesResponse) => void) { | ||
return useQuery<ListCanariesResponse, Error>( | ||
'canaries', | ||
() => | ||
ProgressiveDeliveryService.ListCanaries({}).then(res => { | ||
clb(res); | ||
return res; | ||
}), | ||
{ | ||
refetchInterval: CANARIES_POLL_INTERVAL, | ||
}, | ||
); | ||
} | ||
|
||
export function useListEvents(listEventsPayload: ListEventsRequest) { | ||
return useQuery<ListEventsResponse, Error>('events', () => | ||
ClustersService.ListEvents(listEventsPayload), | ||
); | ||
} | ||
export interface CanaryParams { | ||
name: string; | ||
namespace: string; | ||
clusterName: string; | ||
} | ||
export function useCanaryDetails({ | ||
name, | ||
namespace, | ||
clusterName, | ||
}: CanaryParams) { | ||
return useQuery<GetCanaryResponse, Error>( | ||
'canaryDetails', | ||
() => | ||
ProgressiveDeliveryService.GetCanary({ | ||
name, | ||
namespace, | ||
clusterName, | ||
}), | ||
{}, | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.