Skip to content

Commit b80f0ae

Browse files
committed
feat(FR-2115): show allowed resource group warning for domain/project/user fair share list (#5562)
Resolves #5540 ([FR-2115](https://lablup.atlassian.net/browse/FR-2115)) - Add **warning icon** in `DomainFairShareTable` and `ProjectFairShareTable` when the selected resource group is not included in a domain/project's allowed scaling groups - Add **warning Alert** in `FairShareWeightSettingModal` (single-edit only) for domain and project fair share entries - Add **warning Alert** in `FairShareList` (user step) and `FairShareWeightSettingModal` for user fair share entries — checks both domain-level and project-level `scaling_groups` (passes if either allows the resource group) - New components: `DomainResourceGroupWarningIcon`, `DomainResourceGroupAlert`, `ProjectResourceGroupWarningIcon`, `ProjectResourceGroupAlert`, `UserResourceGroupAlert` - i18n: added `fairShare.DomainNotAllowedInResourceGroup` key across all 21 supported locales - [ ] Navigate to Fair Share Scheduler → select a resource group - [ ] On the Domain step: verify warning icon appears next to domain names not associated with the selected resource group - [ ] On the Project step: verify warning icon appears next to project names not associated with the selected resource group - [ ] Open weight setting modal (single edit) for a domain/project/user with a mismatched resource group → verify warning Alert appears - [ ] On the User step in FairShareList: verify warning Alert appears above the table when neither the domain nor the project allows the resource group - [ ] Confirm no warning is shown when the resource group is properly allowed [FR-2115]: https://lablup.atlassian.net/browse/FR-2115?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 7097557 commit b80f0ae

30 files changed

Lines changed: 785 additions & 292 deletions

react/src/components/FairShareItems/DomainFairShareTable.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import QuestionIconWithTooltip from '../QuestionIconWithTooltip';
2+
import DomainResourceGroupWarningIcon from './DomainResourceGroupWarningIcon';
23
import { SettingOutlined } from '@ant-design/icons';
34
import { Divider, theme, Typography } from 'antd';
45
import {
@@ -104,6 +105,7 @@ const DomainFairShareTable: React.FC<DomainFairShareTableProps> = ({
104105
createdAt
105106
updatedAt
106107
108+
...DomainResourceGroupWarningIconFragment
107109
...FairShareWeightSettingModal_DomainFragment
108110
...UsageBucketModal_DomainFragment
109111
}
@@ -120,6 +122,7 @@ const DomainFairShareTable: React.FC<DomainFairShareTableProps> = ({
120122
sorter: isEnableSorter('domainName'),
121123
render: (_name, record) => (
122124
<BAIFlex gap="xxs" align="center">
125+
<DomainResourceGroupWarningIcon domainFairShareFrgmt={record} />
123126
<BAILink
124127
icon={<ChevronRight />}
125128
onClick={() =>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { Alert, AlertProps } from 'antd';
2+
import _ from 'lodash';
3+
import { useTranslation } from 'react-i18next';
4+
import { graphql, useFragment, useLazyLoadQuery } from 'react-relay';
5+
import type { DomainResourceGroupAlertFragment$key } from 'src/__generated__/DomainResourceGroupAlertFragment.graphql';
6+
import type { DomainResourceGroupAlertQuery } from 'src/__generated__/DomainResourceGroupAlertQuery.graphql';
7+
8+
interface DomainResourceGroupAlertProps extends AlertProps {
9+
domainFairShareFrgmt: DomainResourceGroupAlertFragment$key;
10+
isModalOpen: boolean;
11+
}
12+
13+
const DomainResourceGroupAlert: React.FC<DomainResourceGroupAlertProps> = ({
14+
domainFairShareFrgmt,
15+
isModalOpen,
16+
...alertProps
17+
}) => {
18+
'use memo';
19+
20+
const { t } = useTranslation();
21+
22+
const { domainName, resourceGroupName } = useFragment(
23+
graphql`
24+
fragment DomainResourceGroupAlertFragment on DomainFairShare {
25+
domainName
26+
resourceGroupName
27+
}
28+
`,
29+
domainFairShareFrgmt,
30+
);
31+
32+
const { domain } = useLazyLoadQuery<DomainResourceGroupAlertQuery>(
33+
graphql`
34+
query DomainResourceGroupAlertQuery($domainName: String) {
35+
domain(name: $domainName) {
36+
scaling_groups
37+
}
38+
}
39+
`,
40+
{ domainName },
41+
{
42+
fetchPolicy: isModalOpen ? 'network-only' : 'store-only',
43+
},
44+
);
45+
46+
if (
47+
!resourceGroupName ||
48+
_.includes(domain?.scaling_groups ?? [], resourceGroupName)
49+
) {
50+
return null;
51+
}
52+
53+
return (
54+
<Alert
55+
type="warning"
56+
title={t('fairShare.DomainNotAllowedInResourceGroup', {
57+
resourceGroup: resourceGroupName,
58+
})}
59+
showIcon
60+
{...alertProps}
61+
/>
62+
);
63+
};
64+
65+
export default DomainResourceGroupAlert;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { Tooltip, theme } from 'antd';
2+
import _ from 'lodash';
3+
import { TriangleAlert } from 'lucide-react';
4+
import { useTranslation } from 'react-i18next';
5+
import { graphql, useFragment, useLazyLoadQuery } from 'react-relay';
6+
import type { DomainResourceGroupWarningIconFragment$key } from 'src/__generated__/DomainResourceGroupWarningIconFragment.graphql';
7+
import type { DomainResourceGroupWarningIconQuery } from 'src/__generated__/DomainResourceGroupWarningIconQuery.graphql';
8+
9+
interface DomainResourceGroupWarningIconProps {
10+
domainFairShareFrgmt: DomainResourceGroupWarningIconFragment$key;
11+
}
12+
13+
const DomainResourceGroupWarningIcon: React.FC<
14+
DomainResourceGroupWarningIconProps
15+
> = ({ domainFairShareFrgmt }) => {
16+
'use memo';
17+
18+
const { t } = useTranslation();
19+
const { token } = theme.useToken();
20+
21+
const { domainName, resourceGroupName } = useFragment(
22+
graphql`
23+
fragment DomainResourceGroupWarningIconFragment on DomainFairShare {
24+
domainName
25+
resourceGroupName
26+
}
27+
`,
28+
domainFairShareFrgmt,
29+
);
30+
31+
const { domain } = useLazyLoadQuery<DomainResourceGroupWarningIconQuery>(
32+
graphql`
33+
query DomainResourceGroupWarningIconQuery($domainName: String) {
34+
domain(name: $domainName) {
35+
scaling_groups
36+
}
37+
}
38+
`,
39+
{ domainName },
40+
{
41+
fetchPolicy: 'store-and-network',
42+
},
43+
);
44+
45+
const scalingGroups = domain?.scaling_groups ?? [];
46+
47+
if (!resourceGroupName || _.includes(scalingGroups, resourceGroupName)) {
48+
return null;
49+
}
50+
51+
return (
52+
<Tooltip
53+
title={t('fairShare.DomainNotAllowedInResourceGroup', {
54+
resourceGroup: resourceGroupName,
55+
})}
56+
>
57+
<TriangleAlert
58+
style={{
59+
color: token.colorWarning,
60+
}}
61+
/>
62+
</Tooltip>
63+
);
64+
};
65+
66+
export default DomainResourceGroupWarningIcon;

0 commit comments

Comments
 (0)