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

Add js api #395

Merged
merged 2 commits into from
Nov 8, 2024
Merged

Add js api #395

merged 2 commits into from
Nov 8, 2024

Conversation

trungleduc
Copy link
Member

@trungleduc trungleduc commented Nov 4, 2024

Code Changes:

  • New token IForkManagerToken in @jupyter/docprovider-extension.
  • This token implements the following interface:
    /**
     * Creates a new fork for a given document.
     *
     * @param options.rootId - The ID of the root document to fork.
     * @param options.synchronize - A flag indicating whether the fork should be kept
     * synchronized with the root document.
     * @param options.title - An optional label for the fork.
     * @param options.description - An optional description for the fork.
     *
     * @returns A promise that resolves to an `IForkCreationResponse` if the fork
     * is created successfully, or `undefined` if the creation fails.
     */
    createFork(options: {
        rootId: string;
        synchronize: boolean;
        title?: string;
        description?: string;
    }): Promise<IForkCreationResponse | undefined>;
    /**
     * Retrieves all forks associated with a specific document.
     *
     * @param documentId - The ID of the document for which forks are to be retrieved.
     *
     * @returns A promise that resolves to an `IAllForksResponse` containing information about all forks.
     */
    getAllForks(documentId: string): Promise<IAllForksResponse>;
    /**
     * Deletes a specified fork and optionally merges its changes.
     *
     * @param options - Options for deleting the fork.
     * @param options.forkId - The ID of the fork to be deleted.
     * @param options.merge - A flag indicating whether changes from the fork should be merged back into the root document.
     *
     * @returns A promise that resolves when the fork is successfully deleted.
     */
    deleteFork(options: {
        forkId: string;
        merge: boolean;
    }): Promise<void>;
    /**
     * Signal emitted when a new fork is added.
     *
     * @event forkAdded
     * @type ISignal<IForkManager, IForkChangedEvent>
     */
    forkAdded: ISignal<IForkManager, IForkChangedEvent>;
    /**
     * Signal emitted when a fork is deleted.
     *
     * @event forkDeleted
     * @type ISignal<IForkManager, IForkChangedEvent>
     */
    forkDeleted: ISignal<IForkManager, IForkChangedEvent>;

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Binder 👈 Launch a Binder on branch trungleduc/jupyter-collaboration/fork-js-api

@trungleduc trungleduc added the enhancement New feature or request label Nov 4, 2024
@trungleduc trungleduc force-pushed the fork-js-api branch 9 times, most recently from b527451 to ad954cc Compare November 8, 2024 09:48
@trungleduc trungleduc marked this pull request as ready for review November 8, 2024 09:56
* Add forking API

* Add GET forks of root

* Add fork Jupyter events

* Replace query parameter merge=1 with merge=true

* Add fork title and description
Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @trungleduc, this is great.
I just have a minor comment.

packages/docprovider/src/requests.ts Show resolved Hide resolved
@trungleduc trungleduc marked this pull request as ready for review November 8, 2024 20:49
@trungleduc trungleduc merged commit a3ab041 into jupyterlab:suggestions Nov 8, 2024
27 checks passed
trungleduc added a commit that referenced this pull request Nov 29, 2024
* Add forking API (#394)

* Add forking API

* Add GET forks of root

* Add fork Jupyter events

* Replace query parameter merge=1 with merge=true

* Add fork title and description

* Add JS APIs

---------

Co-authored-by: David Brochart <[email protected]>
trungleduc added a commit that referenced this pull request Nov 29, 2024
* Add forking API (#394)

* Add forking API

* Add GET forks of root

* Add fork Jupyter events

* Replace query parameter merge=1 with merge=true

* Add fork title and description

* Add JS APIs

---------

Co-authored-by: David Brochart <[email protected]>
davidbrochart added a commit that referenced this pull request Nov 29, 2024
* Add forking API (#394)

* Add forking API

* Add GET forks of root

* Add fork Jupyter events

* Replace query parameter merge=1 with merge=true

* Add fork title and description

* Add js api (#395)

* Add forking API (#394)

* Add forking API

* Add GET forks of root

* Add fork Jupyter events

* Replace query parameter merge=1 with merge=true

* Add fork title and description

* Add JS APIs

---------

Co-authored-by: David Brochart <[email protected]>

* Fix test_fork_handler

* again

* Allow time for update to propagate

---------

Co-authored-by: David Brochart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants