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

@@ -25,7 +25,7 @@
organizationPermissions.MANAGE_INVITES
)
"
@keypress.enter="() => onInviteTeamMember(organization.team_id, currentUsername)"
@keypress.enter="() => onInviteTeamMember(organization.team, currentUsername)"
/>
<label for="username" class="hidden">Username</label>
<Button
@@ -49,7 +49,11 @@
Remove yourself as a member of this organization.
</span>
</span>
<Button color="danger" :disabled="currentMember.role === 'Owner'" @click="leaveProject()">
<Button
color="danger"
:disabled="currentMember.role === 'Owner'"
@click="() => onLeaveProject(organization.team_id, auth.user.id)"
>
<UserRemoveIcon />
Leave organization
</Button>
@@ -287,11 +291,13 @@ const permToLabel = (key) => {
return o.charAt(0).toUpperCase() + o.slice(1).toLowerCase()
}
const leaveProject = async () => {
await removeTeamMember(organization.value.team_id, auth.user.id)
await navigateTo(`/organization/${organization.value.slug}`)
const leaveProject = async (teamId, uid) => {
await removeTeamMember(teamId, uid)
await navigateTo(`/organization/${organization.value.id}`)
}
const onLeaveProject = useClientTry(leaveProject)
const onInviteTeamMember = useClientTry(async (teamId, username) => {
const user = await useBaseFetch(`user/${username}`)
const data = {

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',