-
Notifications
You must be signed in to change notification settings - Fork 5
Store and return Scratch project data #720
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
Changes from 8 commits
de6f46f
9eeece3
a94e2f3
5ab6a08
3733743
6d4d4bc
8283e49
23854d0
a867341
e8b84ee
c7c58ef
ce63d8b
2192a3c
3463ed5
700b074
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,12 +5,15 @@ module Scratch | |||||||
| class ProjectsController < ScratchController | ||||||||
| skip_before_action :authorize_user, only: [:show] | ||||||||
| skip_before_action :check_scratch_feature, only: [:show] | ||||||||
| before_action :load_project, only: %i[show update] | ||||||||
|
|
||||||||
| def show | ||||||||
| render :show, formats: [:json] | ||||||||
| render json: @project.scratch_component&.content | ||||||||
| end | ||||||||
|
mwtrew marked this conversation as resolved.
mwtrew marked this conversation as resolved.
|
||||||||
|
|
||||||||
| def update | ||||||||
| @project.scratch_component&.content = params | ||||||||
|
||||||||
| @project.scratch_component&.content = params | |
| scratch_content = params.require(:content) | |
| @project.scratch_component&.content = scratch_content.to_unsafe_h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to note that I can't see any authorization checks on the project to make sure the user is allowed to write to it.
This doesn't have to be done as part of this PR, but we should make sure there's an issue for it if not.
We can't add auth to the show action yet (but I am coming up with a proposal for that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, expecting this to be handled in a separate ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please make sure it's covered by an issue (by adding it to one or creating a new one) - I don't want it to be lost.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ScratchComponent < ApplicationRecord | ||
| belongs_to :project | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class CreateScratchComponents < ActiveRecord::Migration[7.2] | ||
| def change | ||
| create_table :scratch_components, id: :uuid do |t| | ||
| t.jsonb :content | ||
|
mwtrew marked this conversation as resolved.
|
||
| t.references :project, null: false, foreign_key: true, type: :uuid, index: { unique: true } | ||
|
|
||
| t.timestamps | ||
| end | ||
| end | ||
| end | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| FactoryBot.define do | ||
| factory :scratch_component do | ||
| content { { targets: [], monitors: [], extensions: [], meta: {} } } | ||
| project | ||
| end | ||
| end |
Uh oh!
There was an error while loading. Please reload this page.