Creator update hotfixes

* Responsive avatar sizing fix

* random mounting bug

* User owned project list correctly filtered

* fix accepted member count

* Leave team fix

* Remove debug

* Remove debug

* hide view button if collections view
This commit is contained in:
Carter
2024-01-07 01:30:23 -08:00
committed by GitHub
parent 1fa556cd00
commit a037d24b0f
6 changed files with 57 additions and 14 deletions

View File

@@ -166,7 +166,7 @@
Create a project
</Button>
<OrganizationProjectTransferModal
:projects="userProjects || []"
:projects="usersOwnedProjects || []"
@submit="onProjectTransferSubmit"
/>
</div>
@@ -325,7 +325,7 @@ const { organization, projects, refresh } = inject('organizationContext')
const auth = await useAuth()
const { data: userProjects } = await useAsyncData(
const { data: userProjects, refresh: refreshUserProjects } = await useAsyncData(
`user/${auth.value.user.id}/projects`,
() => useBaseFetch(`user/${auth.value.user.id}/projects`),
{
@@ -333,6 +333,34 @@ const { data: userProjects } = await useAsyncData(
}
)
const usersOwnedProjects = ref([])
watch(
() => userProjects.value,
async () => {
if (!userProjects.value) return
if (!userProjects.value.length) return
const projects = userProjects.value.filter((project) => project.organization === null)
const teamIds = projects.map((project) => project?.team).filter((x) => x)
// Shape of teams is member[][]
const teams = await useBaseFetch(`teams?ids=${JSON.stringify(teamIds)}`, {
apiVersion: 3,
})
// for each team id, figure out if the user is a member, and is_owner. Then filter the projects to only include those that are owned by the user
const ownedTeamIds = teamIds.filter((_tid, i) => {
const team = teams?.[i]
if (!team) return false
const member = team.find((member) => member.user.id === auth.value.user.id)
return member && member.is_owner
})
const ownedProjects = projects.filter((project) => ownedTeamIds.includes(project.team))
usersOwnedProjects.value = ownedProjects
}, // watch options
{ immediate: true, deep: true }
)
const onProjectTransferSubmit = async (projects) => {
try {
for (const project of projects) {
@@ -346,6 +374,7 @@ const onProjectTransferSubmit = async (projects) => {
}
await refresh()
await refreshUserProjects()
addNotification({
group: 'main',