Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3368368
D8140.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8140.diff
View Options
diff --git a/web/modals/threads/members/change-member-role-modal.react.js b/web/modals/threads/members/change-member-role-modal.react.js
--- a/web/modals/threads/members/change-member-role-modal.react.js
+++ b/web/modals/threads/members/change-member-role-modal.react.js
@@ -3,8 +3,16 @@
import invariant from 'invariant';
import * as React from 'react';
+import {
+ changeThreadMemberRoles,
+ changeThreadMemberRolesActionTypes,
+} from 'lib/actions/thread-actions.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
import type { RelativeMemberInfo, ThreadInfo } from 'lib/types/thread-types';
+import {
+ useDispatchActionPromise,
+ useServerCall,
+} from 'lib/utils/action-utils.js';
import { values } from 'lib/utils/objects.js';
import css from './change-member-role-modal.css';
@@ -22,6 +30,8 @@
function ChangeMemberRoleModal(props: ChangeMemberRoleModalProps): React.Node {
const { memberInfo, threadInfo } = props;
const { pushModal, popModal } = useModalContext();
+ const dispatchActionPromise = useDispatchActionPromise();
+ const callChangeThreadMemberRoles = useServerCall(changeThreadMemberRoles);
const roleOptions = React.useMemo(
() =>
@@ -46,6 +56,35 @@
pushModal(<UnsavedChangesModal />);
}, [initialSelectedRole, popModal, pushModal, selectedRole]);
+ const onSave = React.useCallback(() => {
+ if (selectedRole === initialSelectedRole) {
+ popModal();
+ return;
+ }
+
+ const createChangeThreadMemberRolesPromise = () => {
+ return callChangeThreadMemberRoles(
+ threadInfo.id,
+ [memberInfo.id],
+ selectedRole,
+ );
+ };
+
+ dispatchActionPromise(
+ changeThreadMemberRolesActionTypes,
+ createChangeThreadMemberRolesPromise(),
+ );
+ popModal();
+ }, [
+ callChangeThreadMemberRoles,
+ dispatchActionPromise,
+ initialSelectedRole,
+ memberInfo.id,
+ popModal,
+ selectedRole,
+ threadInfo.id,
+ ]);
+
return (
<Modal name="Change Role" onClose={popModal} size="large">
<div className={css.roleModalDescription}>
@@ -77,6 +116,7 @@
variant="filled"
className={css.roleModalSaveButton}
buttonColor={buttonThemes.primary}
+ onClick={onSave}
>
Save
</Button>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 7:29 PM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585909
Default Alt Text
D8140.diff (2 KB)
Attached To
Mode
D8140: [web] Add functionality on save to actually change a member's role
Attached
Detach File
Event Timeline
Log In to Comment