-
Notifications
You must be signed in to change notification settings - Fork 481
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
Use ProgrammingEnvironmentCategory in ProgrammingExpression #44735
Conversation
programming_environment_categories and update two blocks based on their category on curriculumbuilder
…ramming expressions
575c7ee
to
bf1f9d8
Compare
How soon will this break things? Why will it break things? |
@@ -7,7 +7,8 @@ export default function OrderableList({ | |||
list, | |||
setList, | |||
addButtonText, | |||
renderItem | |||
renderItem, | |||
checkItemDeletionAllowed = item => true |
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.
Can you tell me about how this works?
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.
Is this just setting a default if checkItemDeletionAllowed is not passed?
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.
Yes it's just a default. All items can be deleted unless a specific function is passed in to check.
@@ -39,9 +39,12 @@ describe('OrderableList', () => { | |||
const wrapper = shallow(<OrderableList {...defaultProps} />); | |||
wrapper | |||
.find('.fa-trash') | |||
.at(1) | |||
.at('1') |
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.
Should this at be changing to '1'
too?
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.
oops good catch. This is what I get for a too optimistic search/replace...
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.
Gotta love JS allowing this to still work though
checkItemDeletionAllowed={item => item.key === '3'} | ||
/> | ||
); | ||
expect(wrapper.find('.fa-trash').length).to.equal(1); |
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.
It looks like there should be 2 trash icons because there should be 3 items. Is that right?
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.
Only the third item is deletable. I waffled on which was to frame the function, i.e. checkItemDeletionAllowed
or preventItemDeletion
. Do you think the second one is clearer?
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.
Ohhhh I see. I think thats fine. I think I just didn't fully understand before.
programming_expression.palette_params = programming_expression_params[:parameters] | ||
programming_environment_category = programming_expression.programming_environment.categories.find_by_key(programming_expression_params[:category_key]) | ||
programming_expression.programming_environment_category_id = programming_environment_category&.id | ||
# TODO: get rid of this when we remove the category column |
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.
Is this the issue with search on lesson edit you called out?
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.
Yes, it's related. The category column doesn't serve a function anymore so I was going to get rid of that column, but the lesson edit page allows searching by category.
@@ -17,6 +17,7 @@ | |||
# | |||
class ProgrammingEnvironmentCategory < ApplicationRecord | |||
belongs_to :programming_environment | |||
has_many :programming_expressions, dependent: :restrict_with_error |
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.
TIL!
Right now, it's fine. But with |
if env_category | ||
nil | ||
else | ||
environment_name == 'spritelab' ? expression_config['color'] : ProgrammingExpression.get_category_color(expression_config['category']) |
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.
what still falls back on the second case here?
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.
There are a bunch of programming expressions that don't have a ProgrammingEnvironmentCateogry. I'm going to clean a bunch of those up over the next several days then hopefully we won't need this case anymore.
exp = create :programming_expression, key: 'myExp', category: 'World', examples: 'myexamples', palette_params: 'some parameters', programming_environment_id: programming_environment.id | ||
exp.color = ProgrammingExpression.get_category_color('World') | ||
category = create :programming_environment_category, programming_environment: programming_environment, name: 'World', color: '#ABCDEF' | ||
exp = create :programming_expression, key: 'myExp', category: 'World', examples: 'myexamples', palette_params: 'some parameters', programming_environment_id: programming_environment.id, programming_environment_category_id: category.id |
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.
Shoudl this still have category set separate from programming_environment_category?
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.
Yeah probably. I'll add that back.
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.
Oh sorry, misunderstood the comment. I think that's fine for now as we still seed and serialize the category column
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.
I only spot checked random of the json file changes but I think it looks good. Thanks for all your hard work on this
Put programming expressions in the new categories! This PR does a best attempt to match the expressions with a ProgrammingEnvironmentCategory and updates the programming expression edit page to use these. It also prevents deletion of any ProgrammingEnvironmentCategory that has a programming expression.
Note to reviewers: I'd suggest reviewing this in two parts. The code changes load a bit better by filtering out the json files. All the json file changes were in commit ca1ee8b so a quick look at that commit should be good for those changes.
Categories where some can be deleted and some can't:
Follow-up work
I realized that this will soon break our search for code docs on the lesson edit page. I'll fix that in the coming week or so.
PR Checklist: