Skip to content
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

Add share and remix option to Python Lab #58820

Merged
merged 9 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,7 @@
"projectTypePlaylab": "Play Lab",
"projectTypePlaylabPreReader": "Play Lab (Pre-reader)",
"projectTypePoetry": "Poetry",
"projectTypePythonlab": "Python Lab",
"projectTypeScience": "Science",
"projectTypeStarwars": "Star Wars",
"projectTypeStarwarsBlocks": "Star Wars (Blocks)",
Expand Down
2 changes: 2 additions & 0 deletions apps/src/lab2/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ export enum PERMISSIONS {
}

export const START_SOURCES = 'start_sources';

export const LABS_USING_NEW_SHARE_DIALOG = ['music', 'pythonlab'];
3 changes: 2 additions & 1 deletion apps/src/lab2/views/Lab2ShareDialogWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {useSelector} from 'react-redux';
import {LabState} from '../lab2Redux';
import {isSignedIn as getIsSignedIn} from '@cdo/apps/templates/currentUserRedux';
import popupWindow from '@cdo/apps/code-studio/popup-window';
import {LABS_USING_NEW_SHARE_DIALOG} from '@cdo/apps/lab2/constants';

/**
* Wrapper around ShareDialog that plumbs in the necessary props for a Lab2 project.
Expand Down Expand Up @@ -51,7 +52,7 @@ const Lab2ShareDialogWrapper: React.FunctionComponent<
return null;
}

if (appType === 'music') {
if (LABS_USING_NEW_SHARE_DIALOG.includes(appType)) {
if (!isOpen) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lab2/views/dialogs/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CopyToClipboardButton: React.FunctionComponent<{shareUrl: string}> = ({

/**
* A new implementation of the project share dialog for Lab2 labs. Currently only used
* by Music Lab and only supports a minimal subset of functionality.
* by Music Lab and Python Lab, and only supports a minimal subset of functionality.
*/
const ShareDialog: React.FunctionComponent<{shareUrl: string}> = ({
shareUrl,
Expand Down
1 change: 1 addition & 0 deletions apps/src/templates/projects/projectTypeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const PROJECT_TYPE_MAP = {
music: i18n.projectTypeMusic(),
poetry: i18n.projectTypePoetry(),
poetry_hoc: i18n.projectTypePoetry(),
pythonlab: i18n.projectTypePythonlab(),
thebadguys: i18n.projectTypeThebadguys(),
science: i18n.projectTypeScience(),
story: i18n.projectTypeStory(),
Expand Down
3 changes: 3 additions & 0 deletions dashboard/app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class ProjectsController < ApplicationController
},
game_design: {
name: 'New Game Design Project'
},
pythonlab: {
name: 'New Python Lab Project'
}
}.with_indifferent_access.freeze

Expand Down
4 changes: 1 addition & 3 deletions dashboard/app/views/levels/editors/_pythonlab.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
= render partial: 'levels/editors/fields/long_instructions', locals: {f: f}

= render partial: 'levels/editors/fields/help_and_tips', locals: {f: f}

= render partial: 'levels/editors/fields/pythonlab_fields', locals: {f: f}

= render partial: 'levels/editors/fields/sharing', locals: {f: f}
= render partial: 'levels/editors/fields/audit_log', locals: {f: f}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
= render partial: 'levels/editors/fields/checkboxes', locals: {f: f, field_name: :disable_sharing, description: "Disable sharing"}
%p If set, this level cannot be shared or saved to galleries even if it's free play.

= render partial: 'levels/editors/fields/checkboxes', locals: {f: f, field_name: :hide_share_and_remix, description: "Hide Share and Remix buttons in header"} if (@level.uses_droplet?) || @level.is_a?(Blockly) || @level.is_a?(Weblab) ||@level.is_a?(Javalab)
= render partial: 'levels/editors/fields/checkboxes', locals: {f: f, field_name: :hide_share_and_remix, description: "Hide Share and Remix buttons in header"} if (@level.uses_droplet?) || @level.is_a?(Blockly) || @level.is_a?(Weblab) || @level.is_a?(Javalab) || @level.uses_lab2?

= render partial: 'levels/editors/fields/checkboxes', locals: {f: f, field_name: :shareable, description: "Make Shareable?"} if @level.is_a?(Flappy)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
}
},
"long_instructions": "## Welcome to Python Lab\r\n\r\nPress the Run button and see what happens.",
"hide_share_and_remix": "true",
"reference_links": [
"/courses/csa-2023/guides/instantiating-objects"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
<Pythonlab>
<config><![CDATA[{
"published": true,
"game_id": 72,
"created_at": "2024-03-08T08:07:49.000Z",
"created_at": "2024-05-21T06:04:01.000Z",
"level_num": "custom",
"user_id": 6959,
"user_id": 2,
"properties": {
"encrypted": "false",
"long_instructions": "## Python Lab Basics\r\n\r\nTry adding some new code."
"long_instructions": "## Python Lab Basics\r\n\r\nTry adding some new code.",
"hide_share_and_remix": "false",
"source": {
"files": {
"1": {
"id": "1",
"name": "main.py",
"language": "py",
"contents": "print(\"Hello from level 2!\")",
"folderId": "0",
"active": true,
"open": true
}
},
"folders": {
}
}
},
"audit_log": "[{\"changed_at\":\"2024-03-07T16:07:49.125-08:00\",\"changed\":[\"cloned from \\\"Allthethings Python Lab 1\\\"\"],\"cloned_from\":\"Allthethings Python Lab 1\"}]"
"published": true,
"audit_log": "[{\"changed_at\":\"2024-05-20 16:17:34 -0700\",\"changed\":[],\"changed_by_id\":2,\"changed_by_email\":\"molly+levelbuilder@code.org\"},{\"changed_at\":\"2024-05-20 16:31:46 -0700\",\"changed\":[\"source\"],\"changed_by_id\":2,\"changed_by_email\":\"molly+levelbuilder@code.org\"},{\"changed_at\":\"2024-05-20 16:41:01 -0700\",\"changed\":[\"source\"],\"changed_by_id\":2,\"changed_by_email\":\"molly+levelbuilder@code.org\"}]"
}]]></config>
</Pythonlab>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Pythonlab>
<config><![CDATA[{
"game_id": 72,
"created_at": "2024-05-20T20:38:29.000Z",
"level_num": "custom",
"user_id": 2,
"properties": {
"is_project_level": "true",
"encrypted": "false"
},
"published": true
}]]></config>
</Pythonlab>