fix: column encryption support for other attributes#2884
Conversation
Console (appwrite/console)Project ID: Tip Every Git commit and branch gets its own deployment URL automatically |
Greptile SummaryAdded encryption support for text-based database columns (text, varchar, longtext, mediumtext) with a new reusable Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 1649d9b |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds encryption support for text-based columns by introducing a new EncryptCheckbox Svelte component and wiring an Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte:
- Around line 47-65: The nested Tag's click handler causes event bubbling to
also trigger the parent button's on:click (double toggle); remove the Tag's
on:click={toggle} and let the parent button's on:click handler (which calls
toggle(e) when !supportsEncryption) manage opening/closing the popover, keeping
the Tag as a passive child; ensure you only update the Tag element (no changes
to the button's on:click, supportsEncryption logic, or encrypt variable).
- Around line 29-30: Replace the incorrect fallback for organizationId so it
uses the project's teamId (page.data?.project?.teamId) instead of
page.data?.project?.$id, and make supportsEncryption reactive by deriving it
from the isCloud flag and the currentPlan store (use Svelte's derived store)
rather than a const so it updates when $currentPlan loads; update references to
the symbols organizationId and supportsEncryption and import/use derived from
'svelte/store' to compute supportsEncryption from isCloud and currentPlan.
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte:
- Line 19: Remove the irregular extra whitespace in the import list so Prettier
can pass: locate the import that includes isSpatialType and isTextType (the
symbols isSpatialType, isTextType) and make the comma-separated spacing
consistent (e.g., "isSpatialType, isTextType") so there is exactly one space
after the comma.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/+page.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/longtext.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/mediumtext.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/text.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/varchar.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/createColumn.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
| const organizationId = page.data?.organization?.$id ?? page.data?.project?.$id; | ||
| const supportsEncryption = isCloud ? $currentPlan?.databasesAllowEncrypt : true; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's examine the file mentioned in the review
fd encryptCheckbox.svelte --type fRepository: appwrite/console
Length of output: 182
🏁 Script executed:
# Search for getChangePlanUrl usage to understand what ID it expects
rg "getChangePlanUrl" --type=svelte -B 3 -A 3Repository: appwrite/console
Length of output: 90
🏁 Script executed:
# Search for project.teamId usage pattern in the codebase
rg "project\?\.teamId" --type=svelte -B 2 -A 2Repository: appwrite/console
Length of output: 90
🏁 Script executed:
# Search for how organizationId is typically derived from page.data
rg "page\.data\?\.project\?" --type=svelte -B 1 -A 1 | head -50Repository: appwrite/console
Length of output: 90
🏁 Script executed:
# Search for getChangePlanUrl without file type restriction
rg "getChangePlanUrl" -B 3 -A 3Repository: appwrite/console
Length of output: 50372
🏁 Script executed:
# Search for project.teamId pattern
rg "project\.teamId" -B 2 -A 2Repository: appwrite/console
Length of output: 20752
🏁 Script executed:
# Read the encryptCheckbox.svelte file
cat -n "src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte"Repository: appwrite/console
Length of output: 4540
🏁 Script executed:
# Search for organizationId patterns in similar context
rg "organizationId.*project.*\$id" -B 1 -A 1Repository: appwrite/console
Length of output: 42
Fix organizationId fallback and make encryption support reactive.
Line 29 uses page.data?.project?.$id as the fallback for organizationId, but $id is the project ID. It should be page.data?.project?.teamId to get the organization ID, matching the pattern used elsewhere in the codebase.
Line 30's supportsEncryption is a const that reads $currentPlan, which may load asynchronously. It won't update after initialization. Use $derived to make it reactive.
Proposed fix
- const organizationId = page.data?.organization?.$id ?? page.data?.project?.$id;
- const supportsEncryption = isCloud ? $currentPlan?.databasesAllowEncrypt : true;
+ const organizationId = page.data?.organization?.$id ?? page.data?.project?.teamId;
+ const supportsEncryption = $derived(isCloud ? $currentPlan?.databasesAllowEncrypt : true);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const organizationId = page.data?.organization?.$id ?? page.data?.project?.$id; | |
| const supportsEncryption = isCloud ? $currentPlan?.databasesAllowEncrypt : true; | |
| const organizationId = page.data?.organization?.$id ?? page.data?.project?.teamId; | |
| const supportsEncryption = $derived(isCloud ? $currentPlan?.databasesAllowEncrypt : true); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte
around lines 29 - 30, Replace the incorrect fallback for organizationId so it
uses the project's teamId (page.data?.project?.teamId) instead of
page.data?.project?.$id, and make supportsEncryption reactive by deriving it
from the isCloud flag and the currentPlan store (use Svelte's derived store)
rather than a const so it updates when $currentPlan loads; update references to
the symbols organizationId and supportsEncryption and import/use derived from
'svelte/store' to compute supportsEncryption from isCloud and currentPlan.
...region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte
Show resolved
Hide resolved
...e)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/routes/`(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte:
- Around line 50-51: The label's class binding allows cursor-pointer when
disabled is true (class:cursor-pointer={!editing}) which conflicts with the
disabled state; update the conditional so cursor-pointer only applies when not
editing AND not disabled (e.g., change the class binding on the element that
currently has class:cursor-pointer={!editing} to class:cursor-pointer={!editing
&& !disabled}) and keep class:cursor-not-allowed={editing || disabled} as-is so
the disabled state always wins visually; reference the class bindings using the
editing and disabled variables on the label/button.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte
...region]-[project]/databases/database-[database]/table-[table]/columns/encryptCheckbox.svelte
Outdated
Show resolved
Hide resolved
…base-[database]/table-[table]/columns/encryptCheckbox.svelte Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit
New Features
Improvements