fix: permissions for server compatibility (#5525)
* disable buttons for server compatibility settings * update permissions checkboxes
This commit is contained in:
@@ -40,13 +40,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ButtonStyled v-if="content" type="outlined">
|
<ButtonStyled v-if="content" type="outlined">
|
||||||
<button class="!border-[1px]" @click="handleSwitchCompatibility">
|
<button
|
||||||
|
class="!border-[1px]"
|
||||||
|
@click="handleSwitchCompatibility"
|
||||||
|
:disabled="!hasPermission"
|
||||||
|
>
|
||||||
<ArrowLeftRightIcon />
|
<ArrowLeftRightIcon />
|
||||||
Switch type
|
Switch type
|
||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
<ButtonStyled v-else>
|
<ButtonStyled v-else>
|
||||||
<button @click="handleSetCompatibility">
|
<button @click="handleSetCompatibility" :disabled="!hasPermission">
|
||||||
<ComponentIcon />
|
<ComponentIcon />
|
||||||
Set compatibility
|
Set compatibility
|
||||||
</button>
|
</button>
|
||||||
@@ -183,14 +187,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ButtonStyled v-if="content">
|
<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 />
|
<RefreshCwIcon />
|
||||||
Update
|
Update
|
||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ServerCompatibilityModal ref="serverCompatibilityModal" />
|
<ServerCompatibilityModal v-if="hasPermission" ref="serverCompatibilityModal" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -224,10 +232,15 @@ const serverCompatibilityModal = useTemplateRef<InstanceType<typeof ServerCompat
|
|||||||
'serverCompatibilityModal',
|
'serverCompatibilityModal',
|
||||||
)
|
)
|
||||||
|
|
||||||
const { projectV3 } = injectProjectPageContext()
|
const { projectV3, currentMember } = injectProjectPageContext()
|
||||||
const { labrinth } = injectModrinthClient()
|
const { labrinth } = injectModrinthClient()
|
||||||
const tags = useGeneratedState()
|
const tags = useGeneratedState()
|
||||||
|
|
||||||
|
const hasPermission = computed(() => {
|
||||||
|
const EDIT_DETAILS = 1 << 2
|
||||||
|
return ((currentMember.value?.permissions ?? 0) & EDIT_DETAILS) === EDIT_DETAILS
|
||||||
|
})
|
||||||
|
|
||||||
const content = computed(() => {
|
const content = computed(() => {
|
||||||
if (!projectV3.value) return null
|
if (!projectV3.value) return null
|
||||||
|
|
||||||
|
|||||||
@@ -129,10 +129,11 @@
|
|||||||
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
|
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
|
||||||
(currentMember?.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION
|
(currentMember?.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION
|
||||||
"
|
"
|
||||||
label="Upload version"
|
:label="isServerProject ? 'Update content' : 'Upload version'"
|
||||||
@update:model-value="allTeamMembers[index].permissions ^= UPLOAD_VERSION"
|
@update:model-value="allTeamMembers[index].permissions ^= UPLOAD_VERSION"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
v-if="!isServerProject"
|
||||||
:model-value="(member?.permissions & DELETE_VERSION) === DELETE_VERSION"
|
:model-value="(member?.permissions & DELETE_VERSION) === DELETE_VERSION"
|
||||||
:disabled="
|
:disabled="
|
||||||
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
|
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
|
||||||
@@ -401,10 +402,11 @@
|
|||||||
(currentMember?.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION ||
|
(currentMember?.permissions & UPLOAD_VERSION) !== UPLOAD_VERSION ||
|
||||||
!allOrgMembers[index].override
|
!allOrgMembers[index].override
|
||||||
"
|
"
|
||||||
label="Upload version"
|
:label="isServerProject ? 'Update content' : 'Upload version'"
|
||||||
@update:model-value="allOrgMembers[index].permissions ^= UPLOAD_VERSION"
|
@update:model-value="allOrgMembers[index].permissions ^= UPLOAD_VERSION"
|
||||||
/>
|
/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
v-if="!isServerProject"
|
||||||
:model-value="(member?.permissions & DELETE_VERSION) === DELETE_VERSION"
|
:model-value="(member?.permissions & DELETE_VERSION) === DELETE_VERSION"
|
||||||
:disabled="
|
:disabled="
|
||||||
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
|
(currentMember?.permissions & EDIT_MEMBER) !== EDIT_MEMBER ||
|
||||||
@@ -557,12 +559,15 @@ import { removeSelfFromTeam } from '~/helpers/teams.js'
|
|||||||
const { addNotification } = injectNotificationManager()
|
const { addNotification } = injectNotificationManager()
|
||||||
const {
|
const {
|
||||||
projectV2: project,
|
projectV2: project,
|
||||||
|
projectV3,
|
||||||
organization,
|
organization,
|
||||||
allMembers,
|
allMembers,
|
||||||
currentMember,
|
currentMember,
|
||||||
invalidate,
|
invalidate,
|
||||||
} = injectProjectPageContext()
|
} = injectProjectPageContext()
|
||||||
|
|
||||||
|
const isServerProject = computed(() => projectV3.value?.minecraft_server != null)
|
||||||
|
|
||||||
const cosmetics = useCosmetics()
|
const cosmetics = useCosmetics()
|
||||||
const auth = await useAuth()
|
const auth = await useAuth()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user