Skip to content

Commit

Permalink
fix: compatibility for lifecycle filter of Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Sep 5, 2024
1 parent b49b666 commit d9227f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
60 changes: 33 additions & 27 deletions react/src/pages/EndpointListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ const EndpointListPage: React.FC<PropsWithChildren> = ({ children }) => {
const isPendingPaginationAndFilter =
selectedLifecycleStage !== deferredSelectedLifecycleStage ||
paginationState !== deferredPaginationState;
const lifecycleStageFilter =
deferredSelectedLifecycleStage === 'created&destroying'
? `lifecycle_stage == "created" | lifecycle_stage == "destroying"`
: `lifecycle_stage == "${deferredSelectedLifecycleStage}"`;

const [isRefetchPending, startRefetchTransition] = useTransition();
const [servicesFetchKey, updateServicesFetchKey] =
useUpdatableState('initial-fetch');
const [optimisticDeletingId, setOptimisticDeletingId] = useState<
string | null
>();

const [currentUser] = useCurrentUserInfo();

// const [selectedGeneration, setSelectedGeneration] = useState<
Expand Down Expand Up @@ -360,10 +365,9 @@ const EndpointListPage: React.FC<PropsWithChildren> = ({ children }) => {
deferredPaginationState.pageSize,
limit: deferredPaginationState.pageSize,
projectID: curProject.id,
filter:
deferredSelectedLifecycleStage === 'created&destroying'
? `lifecycle_stage == "created" | lifecycle_stage == "destroying"`
: `lifecycle_stage == "${deferredSelectedLifecycleStage}"`,
filter: baiClient.supports('endpoint-lifecycle-stage-filter')
? lifecycleStageFilter
: undefined,
},
{
fetchPolicy: 'network-only',
Expand Down Expand Up @@ -411,29 +415,31 @@ const EndpointListPage: React.FC<PropsWithChildren> = ({ children }) => {
}}
>
<Flex direction="column" align="start">
<Radio.Group
value={selectedLifecycleStage}
onChange={(e) => {
setSelectedLifecycleStage(e.target?.value);
// reset pagination state when filter changes
setPaginationState({
current: 1,
pageSize: paginationState.pageSize,
});
}}
optionType="button"
buttonStyle="solid"
options={[
{
label: 'Active',
value: 'created&destroying',
},
{
label: 'Destroyed',
value: 'destroyed',
},
]}
/>
{baiClient.supports('endpoint-lifecycle-stage-filter') && (
<Radio.Group
value={selectedLifecycleStage}
onChange={(e) => {
setSelectedLifecycleStage(e.target?.value);
// reset pagination state when filter changes
setPaginationState({
current: 1,
pageSize: paginationState.pageSize,
});
}}
optionType="button"
buttonStyle="solid"
options={[
{
label: 'Active',
value: 'created&destroying',
},
{
label: 'Destroyed',
value: 'destroyed',
},
]}
/>
)}
</Flex>
<Flex direction="row" gap={'xs'} wrap="wrap" style={{ flexShrink: 1 }}>
<Flex gap={'xs'}>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ class Client {
if (this.isManagerVersionCompatibleWith('24.03.7')) {
this._features['per-kernel-logs'] = true;
}
// ignore next alpha version
if(this.isManagerVersionCompatibleWith(['24.03.10'])) {
this._features['endpoint-lifecycle-stage-filter'] = true;
}
if (this.isManagerVersionCompatibleWith('24.09')) {
this._features['extend-login-session'] = true;
}
Expand Down

0 comments on commit d9227f7

Please sign in to comment.