Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3168595
D3770.id11756.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D3770.id11756.diff
View Options
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<HTMLInputElement>) => void,
+onChangeAccountPassword: (event: SyntheticEvent<HTMLInputElement>) => void,
+ +hasPermissionForTab: (thread: ThreadInfo, tab: TabType) => boolean,
};
class ThreadSettingsModal extends React.PureComponent<Props> {
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(
<Tab
@@ -466,6 +453,26 @@
[],
);
+ const hasPermissionForTab = React.useCallback(
+ (thread: ThreadInfo, tab: TabType) => {
+ 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 (
<Modal onClose={modalContext.clearModal} name="Invalid thread">
@@ -502,6 +509,7 @@
onChangeColor={onChangeColor}
onChangeThreadType={onChangeThreadType}
onChangeAccountPassword={onChangeAccountPassword}
+ hasPermissionForTab={hasPermissionForTab}
/>
);
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 7:07 AM (13 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2440362
Default Alt Text
D3770.id11756.diff (3 KB)
Attached To
Mode
D3770: [web] Move `hasPermissionForTab` up from `ThreadSettingsModal` to `ConnectedThreadSettingsModal`
Attached
Detach File
Event Timeline
Log In to Comment