Skip to content

Commit b262481

Browse files
committed
feat(FR-26): show error state on ProjectSelect when no accessible projects
When the current user has no accessible projects in the current domain, the project selector now indicates this with an error-colored border and an InfoCircleOutlined suffix icon. Hovering the icon shows a tooltip explaining the state. The guard suppresses the error look while the underlying select is `disabled` or `loading`, so the existing 'please select a domain first' warning in UpdateUsersModal and the project-switching spinner in the header keep their original UX.
1 parent 674da9d commit b262481

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

react/src/components/ProjectSelect.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useSuspendedBackendaiClient } from '../hooks';
77
import { useCurrentUserInfo, useCurrentUserRole } from '../hooks/backendai';
88
import useControllableState_deprecated from '../hooks/useControllableState';
99
import { useCurrentUserProjectRoles } from '../hooks/useCurrentUserProjectRoles';
10+
import { InfoCircleOutlined } from '@ant-design/icons';
1011
import { theme, Tooltip } from 'antd';
1112
import { BAIFlex, BAISelect, BAISelectProps } from 'backend.ai-ui';
1213
import * as _ from 'lodash-es';
@@ -153,6 +154,11 @@ const ProjectSelect: React.FC<ProjectSelectProps> = ({
153154
},
154155
);
155156

157+
const showNoProjectError =
158+
!accessibleProjects?.length &&
159+
!selectProps.disabled &&
160+
!selectProps.loading;
161+
156162
return (
157163
<BAISelect
158164
onChange={(value, option) => {
@@ -169,6 +175,16 @@ const ProjectSelect: React.FC<ProjectSelectProps> = ({
169175
options={
170176
_.size(groupOptions) > 1 ? groupOptions : groupOptions[0]?.options
171177
}
178+
status={showNoProjectError ? 'error' : selectProps.status}
179+
suffixIcon={
180+
showNoProjectError ? (
181+
<Tooltip title={t('projectSelect.NoAccessibleProjects')}>
182+
<InfoCircleOutlined />
183+
</Tooltip>
184+
) : (
185+
selectProps.suffixIcon
186+
)
187+
}
172188
/>
173189
);
174190
};

resources/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,7 @@
21252125
"RoleMember": "Member"
21262126
},
21272127
"projectSelect": {
2128+
"NoAccessibleProjects": "No accessible projects available.",
21282129
"ProjectAdminBadge": "Project Admin"
21292130
},
21302131
"prometheusQueryPreset": {

resources/i18n/ko.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,7 @@
21092109
"RoleMember": "구성원"
21102110
},
21112111
"projectSelect": {
2112+
"NoAccessibleProjects": "선택 가능한 프로젝트가 없습니다.",
21122113
"ProjectAdminBadge": "프로젝트 관리자"
21132114
},
21142115
"prometheusQueryPreset": {

0 commit comments

Comments
 (0)