Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3268555
D5281.id17280.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D5281.id17280.diff
View Options
diff --git a/lib/hooks/promote-sidebar.react.js b/lib/hooks/promote-sidebar.react.js
--- a/lib/hooks/promote-sidebar.react.js
+++ b/lib/hooks/promote-sidebar.react.js
@@ -18,6 +18,25 @@
import { useServerCall, useDispatchActionPromise } from '../utils/action-utils';
import { useSelector } from '../utils/redux-utils';
+function canPromoteSidebar(
+ sidebarThreadInfo: ThreadInfo,
+ parentThreadInfo: ?ThreadInfo,
+): boolean {
+ const canChangeThreadType = threadHasPermission(
+ sidebarThreadInfo,
+ threadPermissions.EDIT_PERMISSIONS,
+ );
+ const canCreateSubchannelsInParent = threadHasPermission(
+ parentThreadInfo,
+ threadPermissions.CREATE_SUBCHANNELS,
+ );
+ return (
+ sidebarThreadInfo.type === threadTypes.SIDEBAR &&
+ canChangeThreadType &&
+ canCreateSubchannelsInParent
+ );
+}
+
type PromoteSidebarType = {
+onPromoteSidebar: () => void,
+loading: LoadingStatus,
@@ -39,18 +58,8 @@
const parentThreadInfo: ?ThreadInfo = useSelector(state =>
parentThreadID ? threadInfoSelector(state)[parentThreadID] : null,
);
- const canChangeThreadType = threadHasPermission(
- threadInfo,
- threadPermissions.EDIT_PERMISSIONS,
- );
- const canCreateSubchannelsInParent = threadHasPermission(
- parentThreadInfo,
- threadPermissions.CREATE_SUBCHANNELS,
- );
- const canPromoteSidebar =
- threadInfo.type === threadTypes.SIDEBAR &&
- canChangeThreadType &&
- canCreateSubchannelsInParent;
+
+ const canPromote = canPromoteSidebar(threadInfo, parentThreadInfo);
const onClick = React.useCallback(() => {
try {
@@ -73,12 +82,12 @@
() => ({
onPromoteSidebar: onClick,
loading: loadingStatus,
- canPromoteSidebar,
+ canPromoteSidebar: canPromote,
}),
- [onClick, loadingStatus, canPromoteSidebar],
+ [onClick, loadingStatus, canPromote],
);
return returnValues;
}
-export { usePromoteSidebar };
+export { usePromoteSidebar, canPromoteSidebar };
diff --git a/web/modals/threads/notifications/notifications-modal.css b/web/modals/threads/notifications/notifications-modal.css
--- a/web/modals/threads/notifications/notifications-modal.css
+++ b/web/modals/threads/notifications/notifications-modal.css
@@ -3,8 +3,15 @@
flex-direction: column;
color: var(--fg);
margin: 24px 32px;
- row-gap: 40px;
+ row-gap: 20px;
min-width: 343px;
+ width: min-content;
+}
+
+p.notice {
+ text-align: center;
+ font-size: var(--xs-font-12);
+ color: var(--notification-settings-option-color);
}
div.optionsContainer {
diff --git a/web/modals/threads/notifications/notifications-modal.react.js b/web/modals/threads/notifications/notifications-modal.react.js
--- a/web/modals/threads/notifications/notifications-modal.react.js
+++ b/web/modals/threads/notifications/notifications-modal.react.js
@@ -6,6 +6,7 @@
updateSubscription,
updateSubscriptionActionTypes,
} from 'lib/actions/user-actions';
+import { canPromoteSidebar } from 'lib/hooks/promote-sidebar.react';
import { threadInfoSelector } from 'lib/selectors/thread-selectors';
import { threadTypes } from 'lib/types/thread-types';
import {
@@ -91,6 +92,10 @@
const { onClose, threadID } = props;
const threadInfo = useSelector(state => threadInfoSelector(state)[threadID]);
const { subscription } = threadInfo.currentUser;
+ const { parentThreadID } = threadInfo;
+ const parentThreadInfo = useSelector(state =>
+ parentThreadID ? threadInfoSelector(state)[parentThreadID] : null,
+ );
const isSidebar = threadInfo.type === threadTypes.SIDEBAR;
const initialThreadSetting = React.useMemo<NotificationSettings>(() => {
@@ -192,9 +197,45 @@
? 'Thread notifications'
: 'Channel notifications';
- return (
- <Modal name={modalName} size="fit-content" onClose={onClose}>
- <div className={css.container}>
+ let modalContent;
+ if (isSidebar && !parentThreadInfo?.currentUser.subscription.home) {
+ modalContent = (
+ <>
+ <p>
+ {"It's not possible to change the notif settings for a thread whose parent is in Background. " +
+ "That's because Comm's design always shows threads underneath their parent in the Inbox, " +
+ "which means that if a thread's parent is in Background, the thread must also be there."}
+ </p>
+ <p>
+ {canPromoteSidebar(threadInfo, parentThreadInfo)
+ ? 'If you want to change the notif settings for this thread, ' +
+ 'you can either change the notif settings for the parent, ' +
+ 'or you can promote the thread to a channel.'
+ : 'If you want to change the notif settings for this thread, ' +
+ "you'll have to change the notif settings for the parent."}
+ </p>
+ </>
+ );
+ } else {
+ const noticeText = isSidebar ? (
+ <>
+ <p className={css.notice}>
+ {"It's not possible to move this thread to Background. " +
+ "That's because Comm's design always shows threads underneath their parent in the Inbox, " +
+ "which means that if a thread's parent is in Focused, the thread must also be there."}
+ </p>
+ <p className={css.notice}>
+ {canPromoteSidebar(threadInfo, parentThreadInfo)
+ ? 'If you want to move this thread to Background, ' +
+ 'you can either move the parent to Background, ' +
+ 'or you can promote the thread to a channel.'
+ : 'If you want to move this thread to Background, ' +
+ "you'll have to move the parent to Background."}
+ </p>
+ </>
+ ) : null;
+ modalContent = (
+ <>
<div className={css.optionsContainer}>
{focusedItem}
{focusedBadgeOnlyItem}
@@ -207,7 +248,14 @@
>
Save
</Button>
- </div>
+ {noticeText}
+ </>
+ );
+ }
+
+ return (
+ <Modal name={modalName} size="fit-content" onClose={onClose}>
+ <div className={css.container}>{modalContent}</div>
</Modal>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 3:24 AM (12 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2512143
Default Alt Text
D5281.id17280.diff (5 KB)
Attached To
Mode
D5281: [web] Notifications dialog - add text
Attached
Detach File
Event Timeline
Log In to Comment