Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3388047
D8419.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D8419.diff
View Options
diff --git a/web/components/button.react.js b/web/components/button.react.js
--- a/web/components/button.react.js
+++ b/web/components/button.react.js
@@ -9,6 +9,7 @@
export type ButtonColor = {
+backgroundColor?: string,
+color?: string,
+ +borderColor?: string,
};
export const buttonThemes: { [string]: ButtonColor } = {
diff --git a/web/invite-links/manage-invite-links-modal.react.js b/web/invite-links/manage-invite-links-modal.react.js
--- a/web/invite-links/manage-invite-links-modal.react.js
+++ b/web/invite-links/manage-invite-links-modal.react.js
@@ -7,6 +7,7 @@
import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
import type { InviteLink } from 'lib/types/link-types.js';
+import DisableLinkModal from './manage/disable-link-modal.react.js';
import EditLinkModal from './manage/edit-link-modal.react.js';
import EmptyLinkContent from './manage/empty-link-content.react.js';
import ExistingLinkContent from './manage/existing-link-content.react.js';
@@ -31,17 +32,32 @@
const [modalStage, setModalStage] = React.useState('view');
const enterEditMode = React.useCallback(() => setModalStage('edit'), []);
const enterViewMode = React.useCallback(() => setModalStage('view'), []);
+ const enterDisableMode = React.useCallback(
+ () => setModalStage('disable'),
+ [],
+ );
if (modalStage === 'edit') {
return (
<EditLinkModal
inviteLink={inviteLink}
enterViewMode={enterViewMode}
+ enterDisableMode={enterDisableMode}
community={community}
/>
);
}
+ if (modalStage === 'disable' && inviteLink) {
+ return (
+ <DisableLinkModal
+ inviteLink={inviteLink}
+ enterEditMode={enterEditMode}
+ enterViewMode={enterViewMode}
+ />
+ );
+ }
+
let content;
if (inviteLink) {
content = (
diff --git a/web/invite-links/manage/disable-link-modal.react.js b/web/invite-links/manage/disable-link-modal.react.js
new file mode 100644
--- /dev/null
+++ b/web/invite-links/manage/disable-link-modal.react.js
@@ -0,0 +1,57 @@
+// @flow
+
+import classnames from 'classnames';
+import * as React from 'react';
+
+import { useModalContext } from 'lib/components/modal-provider.react.js';
+import { useInviteLinksActions } from 'lib/hooks/invite-links.js';
+import type { InviteLink } from 'lib/types/link-types.js';
+
+import css from './manage-invite-links-modal.css';
+import Button, { buttonThemes } from '../../components/button.react.js';
+import Modal from '../../modals/modal.react.js';
+
+type Props = {
+ +inviteLink: InviteLink,
+ +enterEditMode: () => mixed,
+ +enterViewMode: () => mixed,
+};
+
+function DisableLinkModal(props: Props): React.Node {
+ const { inviteLink, enterEditMode, enterViewMode } = props;
+ const { popModal } = useModalContext();
+ const { isLoading, disableInviteLink } = useInviteLinksActions(
+ inviteLink.communityID,
+ inviteLink,
+ );
+ const disableLink = React.useCallback(async () => {
+ await disableInviteLink();
+ enterViewMode();
+ }, [disableInviteLink, enterViewMode]);
+
+ return (
+ <Modal name="Disable public link" onClose={popModal} size="large">
+ <div className={classnames(css.container, css.editLinkContainer)}>
+ <div className={css.editLinkDescription}>
+ <p>Are you sure you want to disable your public link?</p>
+ <p>Other communities will be able to claim the same URL.</p>
+ </div>
+ <div className={css.disableLinkButtons}>
+ <Button
+ variant="filled"
+ buttonColor={buttonThemes.danger}
+ disabled={isLoading}
+ onClick={disableLink}
+ >
+ Confirm disable
+ </Button>
+ <Button variant="outline" onClick={enterEditMode}>
+ Cancel
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ );
+}
+
+export default DisableLinkModal;
diff --git a/web/invite-links/manage/edit-link-modal.react.js b/web/invite-links/manage/edit-link-modal.react.js
--- a/web/invite-links/manage/edit-link-modal.react.js
+++ b/web/invite-links/manage/edit-link-modal.react.js
@@ -17,11 +17,16 @@
type Props = {
+inviteLink: ?InviteLink,
+enterViewMode: () => mixed,
+ +enterDisableMode: () => mixed,
+community: ThreadInfo,
};
+const disableButtonColor = {
+ color: 'var(--error-primary)',
+ borderColor: 'var(--error-primary)',
+};
function EditLinkModal(props: Props): React.Node {
- const { inviteLink, enterViewMode, community } = props;
+ const { inviteLink, enterViewMode, enterDisableMode, community } = props;
const { popModal } = useModalContext();
const { error, isLoading, name, setName, createOrUpdateInviteLink } =
@@ -38,6 +43,25 @@
errorComponent = <div className={css.errorContainer}>{error}</div>;
}
+ let disableLinkComponent = null;
+ if (inviteLink) {
+ disableLinkComponent = (
+ <>
+ <hr className={css.separator} />
+ <div className={css.disableLinkRow}>
+ <div>You may also disable the community public link</div>
+ <Button
+ variant="outline"
+ buttonColor={disableButtonColor}
+ onClick={enterDisableMode}
+ >
+ Disable
+ </Button>
+ </div>
+ </>
+ );
+ }
+
return (
<Modal name="Public link" onClose={popModal} size="large">
<div className={classnames(css.container, css.editLinkContainer)}>
@@ -77,6 +101,7 @@
</Button>
</div>
</div>
+ {disableLinkComponent}
</div>
</Modal>
);
diff --git a/web/invite-links/manage/manage-invite-links-modal.css b/web/invite-links/manage/manage-invite-links-modal.css
--- a/web/invite-links/manage/manage-invite-links-modal.css
+++ b/web/invite-links/manage/manage-invite-links-modal.css
@@ -81,3 +81,17 @@
font-size: var(--s-font-14);
color: var(--error-primary);
}
+
+.disableLinkRow {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ align-items: center;
+ font-size: var(--s-font-14);
+}
+
+.disableLinkButtons {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 12:27 PM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2600937
Default Alt Text
D8419.diff (6 KB)
Attached To
Mode
D8419: [web] Introduce disable link modal
Attached
Detach File
Event Timeline
Log In to Comment