Changeset View
Changeset View
Standalone View
Standalone View
web/modals/threads/settings/thread-settings-modal.react.js
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | function ConnectedThreadSettingsModal(props) { | ||||
const viewerID = useSelector( | const viewerID = useSelector( | ||||
state => state.currentUserInfo && state.currentUserInfo.id, | state => state.currentUserInfo && state.currentUserInfo.id, | ||||
); | ); | ||||
const userInfos = useSelector(state => state.userStore.userInfos); | const userInfos = useSelector(state => state.userStore.userInfos); | ||||
const threadInfo: ?ThreadInfo = useSelector( | const threadInfo: ?ThreadInfo = useSelector( | ||||
state => threadInfoSelector(state)[props.threadID], | state => threadInfoSelector(state)[props.threadID], | ||||
); | ); | ||||
const modalContext = useModalContext(); | const modalContext = useModalContext(); | ||||
const [errorMessage, setErrorMessage] = React.useState(''); | const [errorMessage, setErrorMessage] = React.useState<?string>(''); | ||||
const [currentTabType, setCurrentTabType] = React.useState<TabType>( | const [currentTabType, setCurrentTabType] = React.useState<TabType>( | ||||
'general', | 'general', | ||||
); | ); | ||||
const [queuedChanges, setQueuedChanges] = React.useState<ThreadChanges>( | const [queuedChanges, setQueuedChanges] = React.useState<ThreadChanges>( | ||||
Object.freeze({}), | Object.freeze({}), | ||||
); | ); | ||||
const namePlaceholder: string = React.useMemo(() => { | const namePlaceholder: string = React.useMemo(() => { | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | const tabs = [ | ||||
<div className={css.tab_body}> | <div className={css.tab_body}> | ||||
<ThreadSettingsGeneralTab | <ThreadSettingsGeneralTab | ||||
threadSettingsOperationInProgress={changeInProgress} | threadSettingsOperationInProgress={changeInProgress} | ||||
threadInfo={threadInfo} | threadInfo={threadInfo} | ||||
threadNamePlaceholder={namePlaceholder} | threadNamePlaceholder={namePlaceholder} | ||||
queuedChanges={queuedChanges} | queuedChanges={queuedChanges} | ||||
setQueuedChanges={setQueuedChanges} | setQueuedChanges={setQueuedChanges} | ||||
setErrorMessage={setErrorMessage} | setErrorMessage={setErrorMessage} | ||||
errorMessage={errorMessage} | |||||
/> | /> | ||||
<div className={css.modal_form_error}>{errorMessage}</div> | |||||
</div> | </div> | ||||
</Tabs.Item>, | </Tabs.Item>, | ||||
]; | ]; | ||||
// This UI needs to be updated to handle sidebars but we haven't gotten | // This UI needs to be updated to handle sidebars but we haven't gotten | ||||
// there yet. We'll probably end up ripping it out anyways, so for now we | // there yet. We'll probably end up ripping it out anyways, so for now we | ||||
// are just hiding the privacy tab for any thread that was created as a | // are just hiding the privacy tab for any thread that was created as a | ||||
// sidebar | // sidebar | ||||
const canSeePrivacyTab = | const canSeePrivacyTab = | ||||
(queuedChanges['parentThreadID'] ?? threadInfo['parentThreadID']) && | (queuedChanges['parentThreadID'] ?? threadInfo['parentThreadID']) && | ||||
!threadInfo.sourceMessageID && | !threadInfo.sourceMessageID && | ||||
(threadInfo.type === threadTypes.COMMUNITY_OPEN_SUBTHREAD || | (threadInfo.type === threadTypes.COMMUNITY_OPEN_SUBTHREAD || | ||||
threadInfo.type === threadTypes.COMMUNITY_SECRET_SUBTHREAD); | threadInfo.type === threadTypes.COMMUNITY_SECRET_SUBTHREAD); | ||||
if (canSeePrivacyTab) { | if (canSeePrivacyTab) { | ||||
tabs.push( | tabs.push( | ||||
<Tabs.Item id="privacy" header="Privacy" key="privacy"> | <Tabs.Item id="privacy" header="Privacy" key="privacy"> | ||||
<div className={css.tab_body}> | <div className={css.tab_body}> | ||||
<ThreadSettingsPrivacyTab | <ThreadSettingsPrivacyTab | ||||
threadSettingsOperationInProgress={changeInProgress} | threadSettingsOperationInProgress={changeInProgress} | ||||
threadInfo={threadInfo} | threadInfo={threadInfo} | ||||
queuedChanges={queuedChanges} | queuedChanges={queuedChanges} | ||||
setQueuedChanges={setQueuedChanges} | setQueuedChanges={setQueuedChanges} | ||||
setErrorMessage={setErrorMessage} | setErrorMessage={setErrorMessage} | ||||
errorMessage={errorMessage} | |||||
/> | /> | ||||
<div className={css.modal_form_error}>{errorMessage}</div> | |||||
</div> | </div> | ||||
</Tabs.Item>, | </Tabs.Item>, | ||||
); | ); | ||||
} | } | ||||
if (availableRelationshipActions.length > 0 && otherUserInfo) { | if (availableRelationshipActions.length > 0 && otherUserInfo) { | ||||
tabs.push( | tabs.push( | ||||
<Tabs.Item id="relationship" header="Relationship" key="relationship"> | <Tabs.Item id="relationship" header="Relationship" key="relationship"> | ||||
Show All 13 Lines | function ConnectedThreadSettingsModal(props) { | ||||
if (canDeleteThread) { | if (canDeleteThread) { | ||||
tabs.push( | tabs.push( | ||||
<Tabs.Item id="delete" header="Delete" key="delete"> | <Tabs.Item id="delete" header="Delete" key="delete"> | ||||
<div className={css.tab_body}> | <div className={css.tab_body}> | ||||
<ThreadSettingsDeleteTab | <ThreadSettingsDeleteTab | ||||
threadSettingsOperationInProgress={changeInProgress} | threadSettingsOperationInProgress={changeInProgress} | ||||
threadInfo={threadInfo} | threadInfo={threadInfo} | ||||
setErrorMessage={setErrorMessage} | setErrorMessage={setErrorMessage} | ||||
errorMessage={errorMessage} | |||||
/> | /> | ||||
<div className={css.modal_form_error}>{errorMessage}</div> | |||||
</div> | </div> | ||||
</Tabs.Item>, | </Tabs.Item>, | ||||
); | ); | ||||
} | } | ||||
return ( | return ( | ||||
<Modal | <Modal | ||||
name="Chat settings" | name="Chat settings" | ||||
Show All 15 Lines |