Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/backend.ai-ui/src/components/BAISelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ const useStyles = createStyles(({ css, token }) => ({
color: ${token.colorBgBase};
}
}

/* In ghost mode the border-color is hard-overridden with !important,
which would otherwise swallow antd's status="error" red border.
Restore the error treatment with a higher-specificity rule so a
ghost select (e.g. the header ProjectSelect) can still surface an
error state. */
&.ant-select.ant-select-status-error {
border-color: ${token.colorError} !important;

.ant-select-suffix {
color: ${token.colorError};
}

&:hover .ant-select-suffix,
&:active .ant-select-suffix {
color: ${token.colorError};
}
}
`,
customStyle: css`
/* Hide selected value content (except search input) when the user is typing a search query.
Expand Down
26 changes: 26 additions & 0 deletions react/src/components/ProjectSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSuspendedBackendaiClient } from '../hooks';
import { useCurrentUserInfo, useCurrentUserRole } from '../hooks/backendai';
import useControllableState_deprecated from '../hooks/useControllableState';
import { useCurrentUserProjectRoles } from '../hooks/useCurrentUserProjectRoles';
import { InfoCircleOutlined } from '@ant-design/icons';
import { theme, Tooltip } from 'antd';
import { BAIFlex, BAISelect, BAISelectProps } from 'backend.ai-ui';
import * as _ from 'lodash-es';
Expand Down Expand Up @@ -153,6 +154,13 @@ const ProjectSelect: React.FC<ProjectSelectProps> = ({
},
);

const showNoProjectError =
!accessibleProjects?.length &&
!selectProps.disabled &&
!selectProps.loading;

const noAccessibleProjectsMessage = t('projectSelect.NoAccessibleProjects');

return (
<BAISelect
onChange={(value, option) => {
Expand All @@ -169,6 +177,24 @@ const ProjectSelect: React.FC<ProjectSelectProps> = ({
options={
_.size(groupOptions) > 1 ? groupOptions : groupOptions[0]?.options
}
status={showNoProjectError ? 'error' : selectProps.status}
// Surface the empty-state reason on the focusable control itself,
// not only on the non-focusable suffix icon. `tooltip` wraps the
// whole BAISelect in an antd Tooltip (hover over the entire control,
// not just the tiny icon), and `aria-label` gives keyboard /
// screen-reader users a persistent accessible description that does
// not depend on the tooltip being open.
tooltip={
showNoProjectError ? noAccessibleProjectsMessage : selectProps.tooltip
}
aria-label={
showNoProjectError
? noAccessibleProjectsMessage
: selectProps['aria-label']
}
suffixIcon={
showNoProjectError ? <InfoCircleOutlined /> : selectProps.suffixIcon
}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "Mitglied"
},
"projectSelect": {
"NoAccessibleProjects": "Keine zugänglichen Projekte.",
"ProjectAdminBadge": "Projektadministrator"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Μέλος"
},
"projectSelect": {
"NoAccessibleProjects": "Δεν υπάρχουν προσβάσιμα έργα.",
"ProjectAdminBadge": "Διαχειριστής έργου"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,7 @@
"RoleMember": "Member"
},
"projectSelect": {
"NoAccessibleProjects": "No accessible projects.",
"ProjectAdminBadge": "Project Admin"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Miembro"
},
"projectSelect": {
"NoAccessibleProjects": "No hay proyectos accesibles.",
"ProjectAdminBadge": "Administrador del proyecto"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Jäsen"
},
"projectSelect": {
"NoAccessibleProjects": "Ei saatavilla olevia projekteja.",
"ProjectAdminBadge": "Projektin ylläpitäjä"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "Membre"
},
"projectSelect": {
"NoAccessibleProjects": "Aucun projet accessible.",
"ProjectAdminBadge": "Administrateur de projet"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,7 @@
"RoleMember": "Anggota"
},
"projectSelect": {
"NoAccessibleProjects": "Tidak ada proyek yang dapat diakses.",
"ProjectAdminBadge": "Admin Proyek"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Membro"
},
"projectSelect": {
"NoAccessibleProjects": "Nessun progetto accessibile.",
"ProjectAdminBadge": "Amministratore del progetto"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "メンバー"
},
"projectSelect": {
"NoAccessibleProjects": "アクセス可能なプロジェクトがありません。",
"ProjectAdminBadge": "プロジェクト管理者"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,7 @@
"RoleMember": "구성원"
},
"projectSelect": {
"NoAccessibleProjects": "선택 가능한 프로젝트가 없습니다.",
"ProjectAdminBadge": "프로젝트 관리자"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,7 @@
"RoleMember": "Гишүүн"
},
"projectSelect": {
"NoAccessibleProjects": "Боломжтой төсөл байхгүй байна.",
"ProjectAdminBadge": "Төслийн администратор"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Ahli"
},
"projectSelect": {
"NoAccessibleProjects": "Tiada projek yang boleh diakses.",
"ProjectAdminBadge": "Pentadbir Projek"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "Członek"
},
"projectSelect": {
"NoAccessibleProjects": "Brak dostępnych projektów.",
"ProjectAdminBadge": "Administrator projektu"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Membro"
},
"projectSelect": {
"NoAccessibleProjects": "Nenhum projeto acessível.",
"ProjectAdminBadge": "Administrador do projeto"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "Membro"
},
"projectSelect": {
"NoAccessibleProjects": "Nenhum projeto acessível.",
"ProjectAdminBadge": "Administrador do projeto"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Участник"
},
"projectSelect": {
"NoAccessibleProjects": "Нет доступных проектов.",
"ProjectAdminBadge": "Администратор проекта"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "สมาชิก"
},
"projectSelect": {
"NoAccessibleProjects": "ไม่มีโปรเจกต์ที่สามารถเข้าถึงได้",
"ProjectAdminBadge": "ผู้ดูแลโปรเจกต์"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,7 @@
"RoleMember": "Üye"
},
"projectSelect": {
"NoAccessibleProjects": "Erişilebilir proje bulunmuyor.",
"ProjectAdminBadge": "Proje Yöneticisi"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "Thành viên"
},
"projectSelect": {
"NoAccessibleProjects": "Không có dự án nào có thể truy cập.",
"ProjectAdminBadge": "Quản trị dự án"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,7 @@
"RoleMember": "成员"
},
"projectSelect": {
"NoAccessibleProjects": "没有可访问的项目。",
"ProjectAdminBadge": "项目管理员"
},
"prometheusQueryPreset": {
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,7 @@
"RoleMember": "成員"
},
"projectSelect": {
"NoAccessibleProjects": "沒有可存取的專案。",
"ProjectAdminBadge": "專案管理員"
},
"prometheusQueryPreset": {
Expand Down
Loading