Page MenuHomePhabricator

D8140.diff
No OneTemporary

D8140.diff

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

Mime Type
text/plain
Expires
Fri, Nov 29, 3:04 PM (5 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597349
Default Alt Text
D8140.diff (2 KB)

Event Timeline