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,6 +345,7 @@ const PartyHeader = (props: Props) => {
text={t('party.notices.buttons.copy_link')} text={t('party.notices.buttons.copy_link')}
onClick={copyToClipboard} onClick={copyToClipboard}
/> />
{party.editable && (
<Button <Button
bound={true} bound={true}
className="notice no-shrink" className="notice no-shrink"
@ -352,6 +353,7 @@ const PartyHeader = (props: Props) => {
text={t('party.notices.buttons.change_visibility')} text={t('party.notices.buttons.change_visibility')}
onClick={() => handleVisibilityDialogChange(true)} onClick={() => handleVisibilityDialogChange(true)}
/> />
)}
</div> </div>
</div> </div>
) )
@ -362,6 +364,7 @@ const PartyHeader = (props: Props) => {
<PrivateIcon /> <PrivateIcon />
</div> </div>
<p>{t('party.notices.private')}</p> <p>{t('party.notices.private')}</p>
{party.editable && (
<div className={styles.buttons}> <div className={styles.buttons}>
<Button <Button
bound={true} bound={true}
@ -371,6 +374,7 @@ const PartyHeader = (props: Props) => {
onClick={() => handleVisibilityDialogChange(true)} onClick={() => handleVisibilityDialogChange(true)}
/> />
</div> </div>
)}
</div> </div>
) )