diff --git a/web/modals/threads/thread-settings-modal.react.js b/web/modals/threads/thread-settings-modal.react.js --- a/web/modals/threads/thread-settings-modal.react.js +++ b/web/modals/threads/thread-settings-modal.react.js @@ -100,6 +100,7 @@ +onChangeColor: (color: string) => void, +onChangeThreadType: (event: SyntheticEvent) => void, +onChangeAccountPassword: (event: SyntheticEvent) => void, + +hasPermissionForTab: (thread: ThreadInfo, tab: TabType) => boolean, }; class ThreadSettingsModal extends React.PureComponent { nameInput: ?HTMLInputElement; @@ -119,11 +120,11 @@ return; } - const permissionForDeleteTab = this.hasPermissionForTab( + const permissionForDeleteTab = this.props.hasPermissionForTab( this.props.threadInfo, 'delete', ); - const prevPermissionForDeleteTab = this.hasPermissionForTab( + const prevPermissionForDeleteTab = this.props.hasPermissionForTab( prevProps.threadInfo, 'delete', ); @@ -133,23 +134,6 @@ } } - hasPermissionForTab(threadInfo: ThreadInfo, tab: TabType) { - if (tab === 'general') { - return threadHasPermission( - threadInfo, - threadPermissions.EDIT_THREAD_NAME, - ); - } else if (tab === 'privacy') { - return threadHasPermission( - threadInfo, - threadPermissions.EDIT_PERMISSIONS, - ); - } else if (tab === 'delete') { - return threadHasPermission(threadInfo, threadPermissions.DELETE_THREAD); - } - invariant(false, `invalid tab ${tab}`); - } - possiblyChangedValue(key: string) { const valueChanged = this.props.queuedChanges[key] !== null && @@ -163,7 +147,7 @@ const { threadInfo } = this.props; const inputDisabled = this.props.changeInProgress || - !this.hasPermissionForTab(threadInfo, this.props.currentTabType); + !this.props.hasPermissionForTab(threadInfo, this.props.currentTabType); let mainContent = null; if (this.props.currentTabType === 'general') { @@ -255,7 +239,10 @@ />, ); } - const canDeleteThread = this.hasPermissionForTab(threadInfo, 'delete'); + const canDeleteThread = this.props.hasPermissionForTab( + threadInfo, + 'delete', + ); if (canDeleteThread) { tabs.push( { + if (tab === 'general') { + return threadHasPermission( + thread, + threadPermissions.EDIT_THREAD_NAME, + ); + } else if (tab === 'privacy') { + return threadHasPermission( + thread, + threadPermissions.EDIT_PERMISSIONS, + ); + } else if (tab === 'delete') { + return threadHasPermission(thread, threadPermissions.DELETE_THREAD); + } + invariant(false, `invalid tab: ${tab}`); + }, + [], + ); + if (!threadInfo) { return ( @@ -502,6 +509,7 @@ onChangeColor={onChangeColor} onChangeThreadType={onChangeThreadType} onChangeAccountPassword={onChangeAccountPassword} + hasPermissionForTab={hasPermissionForTab} /> ); },