Fix ability for non-owners to change team visibility (#385)

This fixes #384 

* Hides "Change party visibility" button when a user is viewing an
unlisted team they did not create
* Prevents updating team at all if the `editable` flag is not set (which
might break something else for anonymous teams... we'll see)
This commit is contained in:
Justin Edmund 2023-10-11 11:25:08 +09:00 committed by GitHub
parent 7dd5d6988a
commit 6135b5bed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 17 deletions

View file

@ -143,7 +143,7 @@ const Party = (props: Props) => {
// Methods: Updating the party's details // Methods: Updating the party's details
async function updateDetails(details: DetailsObject) { async function updateDetails(details: DetailsObject) {
if (!props.team) return await createParty(details) if (!props.team) return await createParty(details)
else return await updateParty(details) else if (party.editable) return await updateParty(details)
} }
function formatDetailsObject(details: DetailsObject) { function formatDetailsObject(details: DetailsObject) {

View file

@ -345,13 +345,15 @@ const PartyHeader = (props: Props) => {
text={t('party.notices.buttons.copy_link')} text={t('party.notices.buttons.copy_link')}
onClick={copyToClipboard} onClick={copyToClipboard}
/> />
<Button {party.editable && (
bound={true} <Button
className="notice no-shrink" bound={true}
key="change_visibility" className="notice no-shrink"
text={t('party.notices.buttons.change_visibility')} key="change_visibility"
onClick={() => handleVisibilityDialogChange(true)} text={t('party.notices.buttons.change_visibility')}
/> onClick={() => handleVisibilityDialogChange(true)}
/>
)}
</div> </div>
</div> </div>
) )
@ -362,15 +364,17 @@ const PartyHeader = (props: Props) => {
<PrivateIcon /> <PrivateIcon />
</div> </div>
<p>{t('party.notices.private')}</p> <p>{t('party.notices.private')}</p>
<div className={styles.buttons}> {party.editable && (
<Button <div className={styles.buttons}>
bound={true} <Button
className="notice" bound={true}
key="change_visibility" className="notice"
text={t('party.notices.buttons.change_visibility')} key="change_visibility"
onClick={() => handleVisibilityDialogChange(true)} text={t('party.notices.buttons.change_visibility')}
/> onClick={() => handleVisibilityDialogChange(true)}
</div> />
</div>
)}
</div> </div>
) )