Skip to content

Add edit DataDoc backend - #48243

Merged
TurnerRiley merged 12 commits into
stagingfrom
edit-data-doc-backend
Sep 26, 2022
Merged

Add edit DataDoc backend#48243
TurnerRiley merged 12 commits into
stagingfrom
edit-data-doc-backend

Conversation

@TurnerRiley

@TurnerRiley TurnerRiley commented Sep 22, 2022

Copy link
Copy Markdown
Contributor

This is part of this Jira ticket for adding an editing interface for existing DataDocs (to be able to change the name and content of them). This PR is just focused on updating/adding backend files to prep for the next PR which will add the actual editing form itself.

To see where the editor will be:

  1. Go to http://localhost-studio.code.org:3000/data_docs/new (it should make you add Levelbuilder permissions to your local account before you can view the page)
  2. Create a new DataDoc
  3. Go to http://localhost-studio.code.org:3000/data_docs/{the_slug_name_you_made}/edit to see a text placeholder for the editor which will be coming in a future PR

Links

Jira ticket: here
Spec: requirement #2 here
Following up work from previous DataDoc PR's: New DataDoc backend, New DataDoc frontend, and Add DataDoc show page

Testing story

Local testing to ensure the addition of these files do not disrupt the current DataDoc creation and viewing behavior. Backend tests were also added for these changes.

Follow-up work

  • Adding the edit page frontend
  • Adding unit tests

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@TurnerRiley
TurnerRiley requested a review from a team September 22, 2022 22:26
@TurnerRiley
TurnerRiley requested a review from a team September 23, 2022 20:44
Comment thread apps/src/sites/studio/pages/data_docs/edit.js
Comment thread dashboard/test/controllers/data_docs_controller_test.rb
Comment thread dashboard/test/controllers/data_docs_controller_test.rb Outdated
Comment thread dashboard/test/controllers/data_docs_controller_test.rb

@megcrenshaw megcrenshaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I added a couple of small changes, but this looks great! Love how you split up the PR

@TurnerRiley
TurnerRiley requested a review from a team September 23, 2022 21:33
@TurnerRiley TurnerRiley changed the title Add edit DataDoc Backend Add edit DataDoc backend Sep 23, 2022
@TurnerRiley TurnerRiley mentioned this pull request Sep 23, 2022
8 tasks

# GET /data_docs/:key/edit
def edit
@data_doc = DataDoc.find_by(key: params[:key])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

up to you but if all the routes are fetching the data doc by key, it might be worth moving this into a private method and using before_action :set_data_doc, like in scripts_controller.rb.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good call. I tried using load_resource id_param: :key but had no luck ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! Thank you

@bethanyaconnor bethanyaconnor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm after addressing Meg's comment


def set_data_doc
@data_doc = DataDoc.find_by(key: params[:key])
return render :not_found unless @data_doc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not to keep on this but I've struggled with rendering not found in the private method. Does this work correctly? If so, looks great!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I re-tested locally and was able to go through all the routes of creating, editing, and submitting data docs so I think it still works correctly! I'm waiting to make sure all drone tests still pass just in case but I think it should be good

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @TurnerRiley , what happens when you do one of these actions (edit or update) with a key that does not exist? that's what needs to be tested to evaluate Bethany's concern.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just closing the loop, it looks like this is giving a 404 as expected: http://localhost-studio.code.org:3000/data_docs/foo/edit

@TurnerRiley
TurnerRiley merged commit a99b17d into staging Sep 26, 2022
@TurnerRiley
TurnerRiley deleted the edit-data-doc-backend branch September 26, 2022 18:41
@TurnerRiley TurnerRiley mentioned this pull request Oct 6, 2022
8 tasks
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.

4 participants