Skip to content

Commit

Permalink
feature: hide user resource policy based on manager version (#2453)
Browse files Browse the repository at this point in the history
### TL;DR

This PR updates the resource policy page.

### What changed?

In versions 23.09.10 and earlier, it is not suitable to create and modify user resource policies. So this PR will hide user resource policy if manager version < 23.09.10.

---

<!--
Please precisely, concisely, and concretely describe what this PR changes, the rationale behind codes,
and how it affects the users and other developers.
-->

**Checklist:** (if applicable)

- [ ] Mention to the original issue
- [ ] Documentation
- [ ] Minium required manager version
- [ ] Specific setting for review (eg., KB link, endpoint or how to setup)
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
  • Loading branch information
agatha197 authored Jun 3, 2024
1 parent ef7e39d commit a0b65f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions react/src/pages/ResourcePolicyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import FlexActivityIndicator from '../components/FlexActivityIndicator';
import KeypairResourcePolicyList from '../components/KeypairResourcePolicyList';
import ProjectResourcePolicyList from '../components/ProjectResourcePolicyList';
import UserResourcePolicyList from '../components/UserResourcePolicyList';
import { useWebUINavigate } from '../hooks';
import { useSuspendedBackendaiClient, useWebUINavigate } from '../hooks';
import { Card } from 'antd';
import React, { Suspense } from 'react';
import { useTranslation } from 'react-i18next';
Expand All @@ -13,8 +13,12 @@ const tabParam = withDefault(StringParam, 'keypair');
interface ResourcePolicyPageProps {}
const ResourcePolicyPage: React.FC<ResourcePolicyPageProps> = () => {
const { t } = useTranslation();
const webUINavigate = useWebUINavigate();
const [curTabKey] = useQueryParam('tab', tabParam);
const webUINavigate = useWebUINavigate();
const baiClient = useSuspendedBackendaiClient();
const supportConfigureUserResourcePolicy = baiClient?.supports(
'configure-user-resource-policy',
);

return (
<Card
Expand All @@ -37,7 +41,7 @@ const ResourcePolicyPage: React.FC<ResourcePolicyPageProps> = () => {
key: 'keypair',
label: t('resourcePolicy.Keypair'),
},
{
supportConfigureUserResourcePolicy && {
key: 'user',
label: t('resourcePolicy.User'),
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ class Client {
}
if (this.isManagerVersionCompatibleWith('23.09.10')) {
this._features['max-session-count-per-model-session'] = true;
// In versions 23.09.10 and earlier, it is not suitable to create and modify user resource policies.
this._features['configure-user-resource-policy'] = true;
}
if (this.isManagerVersionCompatibleWith('24.03.0')) {
this._features['vfolder-trash-bin'] = true;
Expand Down

0 comments on commit a0b65f5

Please sign in to comment.