fix: permissions for server compatibility (#5525)

* disable buttons for server compatibility settings

* update permissions checkboxes
This commit is contained in:
Truman Gao
2026-03-11 11:45:06 -07:00
committed by GitHub
parent 3b21944a75
commit 83ea7f684b
2 changed files with 25 additions and 7 deletions

View File

@@ -40,13 +40,17 @@
</div>
</div>
<ButtonStyled v-if="content" type="outlined">
<button class="!border-[1px]" @click="handleSwitchCompatibility">
<button
class="!border-[1px]"
@click="handleSwitchCompatibility"
:disabled="!hasPermission"
>
<ArrowLeftRightIcon />
Switch type
</button>
</ButtonStyled>
<ButtonStyled v-else>
<button @click="handleSetCompatibility">
<button @click="handleSetCompatibility" :disabled="!hasPermission">
<ComponentIcon />
Set compatibility
</button>
@@ -183,14 +187,18 @@
</div>
<ButtonStyled v-if="content">
<button class="!w-full !max-w-[160px]" @click="handleUpdateContent">
<button
class="!w-full !max-w-[160px]"
@click="handleUpdateContent"
:disabled="!hasPermission"
>
<RefreshCwIcon />
Update
</button>
</ButtonStyled>
</div>
</div>
<ServerCompatibilityModal ref="serverCompatibilityModal" />
<ServerCompatibilityModal v-if="hasPermission" ref="serverCompatibilityModal" />
</div>
</template>
@@ -224,10 +232,15 @@ const serverCompatibilityModal = useTemplateRef<InstanceType<typeof ServerCompat
'serverCompatibilityModal',
)
const { projectV3 } = injectProjectPageContext()
const { projectV3, currentMember } = injectProjectPageContext()
const { labrinth } = injectModrinthClient()
const tags = useGeneratedState()
const hasPermission = computed(() => {
const EDIT_DETAILS = 1 << 2
return ((currentMember.value?.permissions ?? 0) & EDIT_DETAILS) === EDIT_DETAILS
})
const content = computed(() => {
if (!projectV3.value) return null

View File

@@ -129,10 +129,11 @@
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
(currentMember?.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION
"
label="Upload version"
:label="isServerProject ? 'Update content' : 'Upload version'"
@update:model-value="allTeamMembers[index].permissions ^= UPLOAD_VERSION"
/>
<Checkbox
v-if="!isServerProject"
:model-value="(member?.permissions & DELETE_VERSION) === DELETE_VERSION"
:disabled="
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
@@ -401,10 +402,11 @@
(currentMember?.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION ||
!allOrgMembers[index].override
"
label="Upload version"
:label="isServerProject ? 'Update content' : 'Upload version'"
@update:model-value="allOrgMembers[index].permissions ^= UPLOAD_VERSION"
/>
<Checkbox
v-if="!isServerProject"
:model-value="(member?.permissions & DELETE_VERSION) === DELETE_VERSION"
:disabled="
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
@@ -557,12 +559,15 @@ import { removeSelfFromTeam } from '~/helpers/teams.js'
const { addNotification } = injectNotificationManager()
const {
projectV2: project,
projectV3,
organization,
allMembers,
currentMember,
invalidate,
} = injectProjectPageContext()
const isServerProject = computed(() => projectV3.value?.minecraft_server != null)
const cosmetics = useCosmetics()
const auth = await useAuth()