Description
Steps to reproduce
- As an admin, create a public project with no fleets, e.g.
pub, and add a non-admin user to one other project, e.g.main. - Sign in to the UI as that user.
- Open Runs → Launch, or the Offers page.
- Open the Project property in the offer filter.
Actual behaviour
The filter suggests both main and pub, although the user is not a member of pub. The user gets 403 on that project's resources (e.g. POST /api/project/pub/fleets/list), so picking it leads nowhere.
The project isn't pre-selected either, even though the user has a single project: the auto-selection checks for exactly one project, and the public one makes it two.
The offer filter requests projects without username, so /api/projects/list returns every project visible to the user, public ones included:
| const { data: projectsData } = useGetProjectsQuery({ limit: 2 }); |
dstack/frontend/src/pages/Offers/List/hooks/useFilters.ts
Lines 473 to 480 in 927b982
| await getProjects( | |
| getTokenAwareNamePatternFilterRequestParams({ | |
| filteringText, | |
| limit, | |
| propertyKey: filterKeys.PROJECT_NAME, | |
| tokens: propertyFilterQuery.tokens, | |
| }), | |
| ) |
| let projectName = projectsData.data.length === 1 ? projectsData.data[0].project_name : undefined; |
Expected behaviour
The filter suggests only the projects the user is a member of, and pre-selects the project when there is only one, like the project picker that #4449 switched to the user's projects:
dstack/frontend/src/hooks/useProjectFilter.ts
Lines 22 to 23 in 927b982
| const userName = useAppSelector(selectUserName); | |
| const { data: projectsData, isLoading } = useGetProjectsQuery({ username: userName ?? '' }, { skip: !userName }); |
Open question: whether global admins should keep seeing all projects here, since they can use any of them.
dstack version
master (927b982), after 0.22.6
Activity