Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(collaborate): blocked user shouldn't be able to edit transcript #559

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions components/Collaborate/CollabEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import useCurrentUser from 'lib/useCurrentUser';
import PlaceholderPlugin from './Placeholder';
import getConfig from 'next/config';
import CollabHistory from './CollabHistory';
import { useIsUserBlocked } from 'lib/isUserBlocked';

const {
publicRuntimeConfig: { PUBLIC_COLLAB_SERVER_URL },
Expand Down Expand Up @@ -139,6 +140,7 @@ const CollabEditor = ({ article }) => {
const [showEditor, setShowEditor] = useState(null);
const [isSynced, setIsSynced] = useState(false);
const currentUser = useCurrentUser();
const isUserBlocked = useIsUserBlocked();

// onTranscribe setup provider for both Editor and CollabHistory to use.
// And, to avoid duplicated connection, provider will be destroyed(close connection) when Editor unmounted.
Expand Down Expand Up @@ -208,7 +210,7 @@ const CollabEditor = ({ article }) => {
>
{t`No transcripts yet`}
</Typography>
{!showEditor ? (
{!showEditor && !isUserBlocked ? (
<>
<Button
color="primary"
Expand All @@ -232,20 +234,23 @@ const CollabEditor = ({ article }) => {
>
{t`Transcript`}
</Typography>
{!showEditor ? (
<Button
variant="outlined"
className={classes.editButton}
onClick={onTranscribe}
>
<TranscribePenIcon className={classes.newReplyFabIcon} />
{t`Edit`}
</Button>
) : (
isSynced && (
<CollabHistory ydoc={provider.document} docName={article.id} />
)
)}
{!showEditor
? !isUserBlocked && (
<Button
variant="outlined"
className={classes.editButton}
onClick={onTranscribe}
>
<TranscribePenIcon className={classes.newReplyFabIcon} />
{t`Edit`}
</Button>
)
: isSynced && (
<CollabHistory
ydoc={provider.document}
docName={article.id}
/>
)}
</>
)}
</div>
Expand Down
Loading