Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Mar 7, 2024
1 parent 64dee2c commit 8ff32e7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 181 deletions.
53 changes: 3 additions & 50 deletions packages/collaboration-extension/src/collaboration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@ import { ITranslator, nullTranslator, TranslationBundle } from '@jupyterlab/tran

import { Menu, MenuBar } from '@lumino/widgets';

import { IAwareness, ISharedNotebook, ISuggestions, NotebookChange } from '@jupyter/ydoc';
import { IAwareness, ISharedNotebook, NotebookChange } from '@jupyter/ydoc';

import {
CollaboratorsPanel,
SuggestionsPanel,
IGlobalAwareness,
IUserMenu,
remoteUserCursors,
RendererUserMenu,
UserInfoPanel,
UserMenu,
UserMenu
} from '@jupyter/collaboration';

import * as Y from 'yjs';
Expand Down Expand Up @@ -148,12 +147,11 @@ export const rtcPanelPlugin: JupyterFrontEndPlugin<void> = {
id: '@jupyter/collaboration-extension:rtcPanel',
description: 'Add side panel to display all currently connected users.',
autoStart: true,
requires: [IGlobalAwareness, ISuggestions],
requires: [IGlobalAwareness],
optional: [ITranslator],
activate: (
app: JupyterFrontEnd,
awareness: Awareness,
suggestions: ISuggestions,
translator: ITranslator | null
): void => {
const { user } = app.serviceManager;
Expand Down Expand Up @@ -185,10 +183,6 @@ export const rtcPanelPlugin: JupyterFrontEndPlugin<void> = {
);
collaboratorsPanel.title.label = trans.__('Online Collaborators');
userPanel.addWidget(collaboratorsPanel);

const suggestionsPanel = new SuggestionsPanel(fileopener, suggestions);
suggestionsPanel.title.label = trans.__('Suggestions');
userPanel.addWidget(suggestionsPanel);
}
};

Expand Down Expand Up @@ -306,8 +300,6 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
reviewCommands.addCommand('merge', {
label: 'Merge',
execute: () => {
console.log('currentRoomId', context.model.sharedModel.currentRoomId);
console.log('rootRoomId', context.model.sharedModel.rootRoomId);
requestDocMerge(context.model.sharedModel.currentRoomId, context.model.sharedModel.rootRoomId);
}
});
Expand Down Expand Up @@ -396,42 +388,3 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
});
}
}

/**
* A plugin to provide shared document suggestions.
*/
export const suggestions: JupyterFrontEndPlugin<ISuggestions> = {
id: '@jupyter/collaboration-extension:rtcGlobalSuggestions',
description: 'A plugin to provide shared document suggestions.',
autoStart: true,
provides: ISuggestions,
activate: (app: JupyterFrontEnd): ISuggestions => {
console.log('suggestions plugin activated');
return new Suggestions();
},
};

export class Suggestions implements ISuggestions {
private _forkIds: string[];
private _callbacks: any[];

constructor() {
this._forkIds = [];
this._callbacks = [];
}

addFork(forkId: string) {
this._forkIds.push(forkId);
for (const callback of this._callbacks) {
callback(forkId);
}
}

addCallback(callback: any) {
this._callbacks.push(callback);
}

get forks(): string[] {
return this._forkIds;
}
}
9 changes: 4 additions & 5 deletions packages/collaboration-extension/src/filebrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation';

import { CommandRegistry } from '@lumino/commands';

import { ISuggestions, YFile, YNotebook } from '@jupyter/ydoc';
import { YFile, YNotebook } from '@jupyter/ydoc';

import { ICollaborativeDrive, YDrive } from '@jupyter/docprovider';

Expand All @@ -42,15 +42,14 @@ export const drive: JupyterFrontEndPlugin<ICollaborativeDrive> = {
id: '@jupyter/collaboration-extension:drive',
description: 'The default collaborative drive provider',
provides: ICollaborativeDrive,
requires: [ITranslator, ISuggestions],
requires: [ITranslator],
optional: [],
activate: (
app: JupyterFrontEnd,
translator: ITranslator,
suggestions: ISuggestions
translator: ITranslator
): ICollaborativeDrive => {
const trans = translator.load('jupyter_collaboration');
const drive = new YDrive(app.serviceManager.user, trans, suggestions);
const drive = new YDrive(app.serviceManager.user, trans);
app.serviceManager.contents.addDrive(drive);
return drive;
}
Expand Down
6 changes: 2 additions & 4 deletions packages/collaboration-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
rtcGlobalAwarenessPlugin,
rtcPanelPlugin,
userEditorCursors,
editingMode,
suggestions
editingMode
} from './collaboration';
import { sharedLink } from './sharedlink';

Expand All @@ -40,8 +39,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
rtcPanelPlugin,
sharedLink,
userEditorCursors,
editingMode,
suggestions
editingMode
];

export default plugins;
2 changes: 0 additions & 2 deletions packages/collaboration/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

export * from './tokens';
export * from './collaboratorspanel';
export * from './suggestionspanel';
//export * from './suggestions';
export * from './cursors';
export * from './menu';
export * from './sharedlink';
Expand Down
92 changes: 0 additions & 92 deletions packages/collaboration/src/suggestionspanel.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions packages/collaboration/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export const IGlobalAwareness = new Token<IAwareness>(
'@jupyter/collaboration:IGlobalAwareness'
);

///**
// * The global suggestions token.
// */
//export const IGlobalSuggestions = new Token<ISuggestions>(
// '@jupyter/collaboration:IGlobalSuggestions'
//);
//
/**
* An interface describing the user menu.
*/
Expand Down
21 changes: 2 additions & 19 deletions packages/docprovider/src/ydrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
import { TranslationBundle } from '@jupyterlab/translation';
import { Contents, Drive, User } from '@jupyterlab/services';

import { DocumentChange, ISharedDocument, YDocument, ISuggestions } from '@jupyter/ydoc';
import { DocumentChange, ISharedDocument, YDocument } from '@jupyter/ydoc';

import { WebSocketProvider } from './yprovider';
import {
Expand All @@ -14,8 +14,6 @@ import {
SharedDocumentFactory
} from './tokens';

import * as Y from 'yjs';

const DISABLE_RTC =
PageConfig.getOption('disableRTC') === 'true' ? true : false;

Expand All @@ -34,12 +32,11 @@ export class YDrive extends Drive implements ICollaborativeDrive {
*
* @param user - The user manager to add the identity to the awareness of documents.
*/
constructor(user: User.IManager, translator: TranslationBundle, suggestions: ISuggestions) {
constructor(user: User.IManager, translator: TranslationBundle) {
super({ name: 'RTC' });
this._user = user;
this._trans = translator;
this._providers = new Map<string, WebSocketProvider>();
this._suggestions = suggestions;

this.sharedModelFactory = new SharedModelFactory(this._onCreate);
}
Expand Down Expand Up @@ -129,18 +126,6 @@ export class YDrive extends Drive implements ICollaborativeDrive {
return super.save(localPath, options);
}

private _handleForks = (event: Y.YMapEvent<string>) => {
const forkPrefix = 'fork_';
event.changes.keys.forEach((change, key) => {
if (change.action === 'add') {
if (key.startsWith(forkPrefix)) {
const forkId = key.slice(forkPrefix.length);
this._suggestions.addFork(forkId);
}
}
});
};

private _onCreate = (
options: Contents.ISharedFactoryOptions,
sharedModel: YDocument<DocumentChange>
Expand All @@ -162,7 +147,6 @@ export class YDrive extends Drive implements ICollaborativeDrive {
const key = `${options.format}:${options.contentType}:${options.path}`;
this._providers.set(key, provider);

sharedModel.ystate.observe(this._handleForks);
sharedModel.provider = provider;
sharedModel.disposed.connect(() => {
const provider = this._providers.get(key);
Expand All @@ -183,7 +167,6 @@ export class YDrive extends Drive implements ICollaborativeDrive {
private _user: User.IManager;
private _trans: TranslationBundle;
private _providers: Map<string, WebSocketProvider>;
private _suggestions: ISuggestions;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,7 @@ __metadata:

"@jupyter/ydoc@file:.yalc/@jupyter/ydoc::locator=%40jupyter%2Freal-time-collaboration%40workspace%3A.":
version: 2.0.1
resolution: "@jupyter/ydoc@file:.yalc/@jupyter/ydoc#.yalc/@jupyter/ydoc::hash=7b1261&locator=%40jupyter%2Freal-time-collaboration%40workspace%3A."
resolution: "@jupyter/ydoc@file:.yalc/@jupyter/ydoc#.yalc/@jupyter/ydoc::hash=63b59a&locator=%40jupyter%2Freal-time-collaboration%40workspace%3A."
dependencies:
"@jupyterlab/application": ^4.0.0
"@jupyterlab/nbformat": ^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0
Expand All @@ -2165,7 +2165,7 @@ __metadata:
"@lumino/signaling": ^1.10.0 || ^2.0.0
y-protocols: ^1.0.5
yjs: ^13.5.40
checksum: c1f8d5c6854f5854b2754200be67f117586736c08deb5edc6dc7ce419d734d8797e0d009554479ab340ac02cf94f6bd60cce0186f2d1e2df8097a6b9c607b14c
checksum: 9e034badb962ea9d26e8ed279feb7fb85130d11920841e8cdeb930586c23c1b27071a32bf78211043c6dcc1f303736e3abe11f2bfc33cfbc024a2f2cf8e7bd2f
languageName: node
linkType: hard

Expand Down

0 comments on commit 8ff32e7

Please sign in to comment.