Skip to content

Frappe Draw: optional Frappe Drive integration (register diagram as a Drive file)#14

Merged
vibhavkatre merged 1 commit into
mainfrom
feat/drive-integration
Jul 17, 2026
Merged

Frappe Draw: optional Frappe Drive integration (register diagram as a Drive file)#14
vibhavkatre merged 1 commit into
mainfrom
feat/drive-integration

Conversation

@vibhavkatre

Copy link
Copy Markdown
Collaborator

What & why

Roadmap item — a diagram can live on Frappe Drive like a Sheets/Slides/Writer doc. Soft-coupled: Draw does not add Drive to required_apps, so it stays installable standalone (incl. Frappe Cloud without Drive). Every entry point no-ops cleanly when Drive is absent or not set up (no team).

Changes

  • draw/api/drive_integration.py: register_in_drive(name[, team]) creates a Drive "native document" File (content_doctype="Draw Diagram", content_docname=name, mime_type=frappe_doc) in a team, idempotently reusing an existing link. Team defaults to the user's first Drive team → first team on the site → else no-op. Whitelisted add_to_drive(name) for a future "Add to Drive" button.
  • Tests: with Drive installed, registration creates a File + is idempotent; without Drive it returns None.

Testing

  • Verified locally with Drive actually installed on the bench: run-tests --app draw9 pass (I installed Drive, created a team, confirmed a File links to the diagram and repeat calls don't duplicate).
  • The Drive-present test skips on CI (fresh site has no Drive); the no-op test runs everywhere. CI stays green and Draw stays standalone.

Explicitly NOT included (needs a Drive-side change, outside this repo)

A Drive viewer that renders the Draw Diagram content type so opening the Drive file shows the diagram. Registration makes the diagram appear in Drive today; rendering it inside Drive's UI is a Drive-repo follow-up (a /drive/g/<name> renderer or a redirect to /draw/d/<name>).

🤖 Generated with Claude Code

…s a Drive file

Roadmap item: a diagram can live on Frappe Drive like a Sheets/Slides/Writer doc.
Soft-coupled: Draw does NOT add Drive to required_apps, so it stays installable
standalone (Frappe Cloud without Drive). Every entry point no-ops cleanly when
Drive is absent or not set up (no team).

- draw/api/drive_integration.py: register_in_drive(name[, team]) creates a Drive
  "native document" File (content_doctype="Draw Diagram", content_docname=name,
  mime_type=frappe_doc) in a team, idempotently reusing an existing link. Team
  defaults to the user's first Drive team, else the first on the site, else no-op.
  Whitelisted add_to_drive(name) entry point for a future "Add to Drive" action.
- tests: with Drive installed, registration creates a File + is idempotent; when
  Drive is absent it returns None. The Drive-present test skips on CI (fresh site
  has no Drive); the no-op test runs everywhere.

Verified locally (Drive installed on the dev bench): run-tests --app draw → 9 pass.
CI (no Drive) will skip the Drive-present case and pass.

Not included (needs a Drive-side change, out of this repo's scope): a Drive viewer
that renders a Draw diagram content type, so opening the Drive file shows the
diagram. Registration makes the diagram APPEAR in Drive today.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown

Confidence Score: 3/5

The whitelisted endpoint exposes a permission bypass that lets any logged-in user link private diagrams to their Drive account.

The add_to_drive endpoint skips Frappe's document-level permission check, so a user who cannot read a diagram can still register it into their Drive by guessing or knowing its name. This affects the access-control boundary of the new feature.

draw/api/drive_integration.py — specifically the add_to_drive whitelisted function and the register_in_drive existence check.

Reviews (1): Last reviewed commit: "Frappe Draw: optional Frappe Drive integ..." | Re-trigger Greptile

Comment on lines +63 to +69

@frappe.whitelist()
def add_to_drive(name: str) -> dict:
"""Whitelisted entry point for an "Add to Drive" action. Returns whether Drive
is available and the linked File name if created."""
file_name = register_in_drive(name)
return {"drive_installed": drive_installed(), "file": file_name}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Missing permission check before Drive registrationfrappe.db.exists("Draw Diagram", diagram_name) bypasses Frappe's permission layer, so any authenticated user can call add_to_drive with any diagram name (including private diagrams they can't read) and link it into their Drive. Add frappe.has_permission("Draw Diagram", doc=name, throw=True) at the top of add_to_drive before calling register_in_drive.

Comment on lines +136 to +143
)
# Idempotent — a second call reuses the same File.
self.assertEqual(register_in_drive(doc.name, team=team), file_name)

def test_drive_registration_noops_without_team(self):
# Registration is a safe no-op when Drive isn't set up / not installed.
from draw.api import drive_integration

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Test asserts nothing when Drive is installedtest_drive_registration_noops_without_team only calls assertIsNone inside the if not drive_installed() branch, so on a bench with Drive installed but no team the test body is empty and passes vacuously. Add an else branch (or an unconditional assertion) to cover the "installed but no team" path the test name promises.

@vibhavkatre
vibhavkatre merged commit c618205 into main Jul 17, 2026
2 of 3 checks passed
@vibhavkatre
vibhavkatre deleted the feat/drive-integration branch July 17, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants