Skip to content

Commit

Permalink
Merge pull request #23935 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT (Staging > Test) [ErinP]
  • Loading branch information
Erin Peach committed Jul 26, 2018
2 parents bfe1d45 + 425249c commit d208039
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 76 deletions.
47 changes: 7 additions & 40 deletions apps/src/templates/projects/PersonalProjectsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
personalProjectDataPropType,
FEATURED_PROJECT_TYPE_MAP,
} from './projectConstants';
import QuickActionsCell from '../tables/QuickActionsCell';
import {tableLayoutStyles, sortableOptions} from "../tables/tableConstants";
import PopUpMenu, {MenuBreak} from "@cdo/apps/lib/ui/PopUpMenu";
import PersonalProjectsTableActionsCell from './PersonalProjectsTableActionsCell';

const PROJECT_DEFAULT_IMAGE = '/blockly/media/projects/project_default.png';

Expand Down Expand Up @@ -69,9 +68,6 @@ export const styles = {
justifyContent: 'center',
alignItems: 'center',
},
xIcon: {
paddingRight: 5,
},
};

// Cell formatters.
Expand All @@ -96,40 +92,11 @@ const nameFormatter = (projectName, {rowData}) => {

const actionsFormatter = (actions, {rowData}) => {
return (
<QuickActionsCell>
<PopUpMenu.Item
onClick={() => console.log("Rename was clicked")}
>
{i18n.rename()}
</PopUpMenu.Item>
<PopUpMenu.Item
onClick={() => console.log("Remix was clicked")}
>
{i18n.remix()}
</PopUpMenu.Item>
{!!rowData.isPublished && (
<PopUpMenu.Item
onClick={() => console.log("Unpublish was clicked")}
>
{i18n.unpublish()}
</PopUpMenu.Item>
)}
{!rowData.isPublished && (
<PopUpMenu.Item
onClick={() => console.log("Publish was clicked")}
>
{i18n.publish()}
</PopUpMenu.Item>
)}
<MenuBreak/>
<PopUpMenu.Item
onClick={() => console.log("Delete was clicked")}
color={color.red}
>
<FontAwesome icon="times-circle" style={styles.xIcon}/>
{i18n.delete()}
</PopUpMenu.Item>
</QuickActionsCell>
<PersonalProjectsTableActionsCell
isPublished = {!!rowData.publishedAt}
projectId = {rowData.channel}
projectType = {rowData.type}
/>
);
};

Expand All @@ -148,7 +115,7 @@ const publishedAtFormatter = (publishedAt) => {

class PersonalProjectsTable extends React.Component {
static propTypes = {
personalProjectsList: PropTypes.arrayOf(personalProjectDataPropType).isRequired
personalProjectsList: PropTypes.arrayOf(personalProjectDataPropType).isRequired,
};

state = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {stubFakePersonalProjectData} from './generateFakeProjects';
export default storybook => {
storybook
.storiesOf('Projects/PersonalProjectsTable', module)
.withReduxStore()
.addStoryTable([
{
name: 'Personal Project Table',
Expand Down
80 changes: 80 additions & 0 deletions apps/src/templates/projects/PersonalProjectsTableActionsCell.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, {Component, PropTypes} from 'react';
import {connect} from 'react-redux';
import QuickActionsCell from "../tables/QuickActionsCell";
import PopUpMenu, {MenuBreak} from "@cdo/apps/lib/ui/PopUpMenu";
import color from "../../util/color";
import FontAwesome from '../FontAwesome';
import i18n from '@cdo/locale';
import {showPublishDialog} from './publishDialog/publishDialogRedux';

export const styles = {
xIcon: {
paddingRight: 5,
},
};

class PersonalProjectsTableActionsCell extends Component {
static propTypes = {
isPublished: PropTypes.bool.isRequired,
projectId: PropTypes.string.isRequired,
projectType: PropTypes.string.isRequired,
showPublishDialog: PropTypes.func.isRequired,
};

state = {
deleting: false,
publishing: false,
unpublishing: false,
renaming: false,
remixing: false
};

onPublish = () => {
this.props.showPublishDialog(this.props.projectId, this.props.projectType);
};

render() {
return (
<QuickActionsCell>
<PopUpMenu.Item
onClick={() => console.log("Rename was clicked")}
>
{i18n.rename()}
</PopUpMenu.Item>
<PopUpMenu.Item
onClick={() => console.log("Remix was clicked")}
>
{i18n.remix()}
</PopUpMenu.Item>
{this.props.isPublished && (
<PopUpMenu.Item
onClick={() => console.log("Unpublish was clicked")}
>
{i18n.unpublish()}
</PopUpMenu.Item>
)}
{!this.props.isPublished && (
<PopUpMenu.Item
onClick={this.onPublish}
>
{i18n.publish()}
</PopUpMenu.Item>
)}
<MenuBreak/>
<PopUpMenu.Item
onClick={() => console.log("Delete was clicked")}
color={color.red}
>
<FontAwesome icon="times-circle" style={styles.xIcon}/>
{i18n.delete()}
</PopUpMenu.Item>
</QuickActionsCell>
);
}
}

export default connect(state => ({}), dispatch => ({
showPublishDialog(projectId, projectType) {
dispatch(showPublishDialog(projectId, projectType));
},
}))(PersonalProjectsTableActionsCell);
19 changes: 18 additions & 1 deletion apps/src/templates/projects/projectsRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { combineReducers } from 'redux';
import _ from 'lodash';
import { Galleries } from './projectConstants';

import {PUBLISH_SUCCESS} from './publishDialog/publishDialogRedux';
// Action types

const TOGGLE_GALLERY = 'projects/TOGGLE_GALLERY';
Expand Down Expand Up @@ -92,6 +92,18 @@ function personalProjectsList(state = initialPersonalProjectsList, action) {
...state,
projects: action.personalProjectsList,
};
case PUBLISH_SUCCESS:
var channelOfInterest = action.lastPublishedProjectData.channel;

var publishedProjectIndex = state.projects.findIndex(project => project.channel === channelOfInterest);

var updatedProjects = [...state.projects];
updatedProjects[publishedProjectIndex].publishedAt = action.lastPublishedAt;

return {
...state,
projects: updatedProjects
};
default:
return state;
}
Expand Down Expand Up @@ -151,3 +163,8 @@ export function setHasOlderProjects(hasOlderProjects, projectType) {
export function setPersonalProjectsList(personalProjectsList) {
return {type: SET_PERSONAL_PROJECTS_LIST, personalProjectsList};
}

export function publishSuccess(lastPublishedAt, lastPublishedProjectData) {
return {type: PUBLISH_SUCCESS, lastPublishedAt,
lastPublishedProjectData};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { AllPublishableProjectTypes } from '../../../util/sharedConstants';
const SHOW_PUBLISH_DIALOG = 'publishDialog/SHOW_PUBLISH_DIALOG';
const HIDE_PUBLISH_DIALOG = 'publishDialog/HIDE_PUBLISH_DIALOG';

export const PUBLISH_REQUEST = 'shareDialog/PUBLISH_REQUEST';
export const PUBLISH_SUCCESS = 'shareDialog/PUBLISH_SUCCESS';
export const PUBLISH_FAILURE = 'shareDialog/PUBLISH_FAILURE';
export const PUBLISH_REQUEST = 'publishDialog/PUBLISH_REQUEST';
export const PUBLISH_SUCCESS = 'publishDialog/PUBLISH_SUCCESS';
export const PUBLISH_FAILURE = 'publishDialog/PUBLISH_FAILURE';

// Reducer

Expand Down
20 changes: 12 additions & 8 deletions apps/test/unit/templates/projects/PersonalProjectsTableTest.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import React from 'react';
import {mount} from 'enzyme';
import {expect} from '../../../util/configuredChai';
import {Provider} from 'react-redux';
import {getStore} from '@cdo/apps/redux';
import {UnconnectedPersonalProjectsTable as PersonalProjectsTable} from '@cdo/apps/templates/projects/PersonalProjectsTable';
import {stubFakePersonalProjectData} from '@cdo/apps/templates/projects/generateFakeProjects';

describe('PersonalProjectsTable', () => {
it('renders a table', () => {
const wrapper = mount(
<PersonalProjectsTable
personalProjectsList={stubFakePersonalProjectData}
/>
<Provider store={getStore()}>
<PersonalProjectsTable
personalProjectsList={stubFakePersonalProjectData}
/>
</Provider>
);

expect(wrapper.find('table').exists()).to.be.true;
});

it('renders projects as table rows', () => {
const wrapper = mount(
<PersonalProjectsTable
personalProjectsList={stubFakePersonalProjectData}
/>
<Provider store={getStore()}>
<PersonalProjectsTable
personalProjectsList={stubFakePersonalProjectData}
/>
</Provider>
);

const projectRows = wrapper.find('tbody').find('tr');
expect(projectRows).to.have.length(stubFakePersonalProjectData.length);
});
Expand Down
11 changes: 11 additions & 0 deletions apps/test/unit/templates/projects/projectsReduxTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assert } from '../../../util/configuredChai';
import projects, {
setPersonalProjectsList,
publishSuccess,
} from '@cdo/apps/templates/projects/projectsRedux';
import {stubFakePersonalProjectData} from '@cdo/apps/templates/projects/generateFakeProjects';

Expand All @@ -15,4 +16,14 @@ describe('projectsRedux', () => {
});
});

describe('publishSuccess', () => {
it('sets the publishedAt field for the recently published project', () => {
const action = setPersonalProjectsList(stubFakePersonalProjectData);
const nextState = projects(initialState, action);
const nextAction = publishSuccess('2016-11-30T23:59:59.999-08:00', {channel: 'abcd2'});
const nextNextState = projects(nextState, nextAction);
assert.deepEqual(nextNextState.personalProjectsList.projects[1].channel, 'abcd2');
assert.deepEqual(nextNextState.personalProjectsList.projects[1].publishedAt, '2016-11-30T23:59:59.999-08:00');
});
});
});
8 changes: 4 additions & 4 deletions dashboard/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
end

create_table "blocks", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t|
t.string "name", null: false
t.string "pool", null: false
t.string "name", null: false
t.string "pool", default: "", null: false
t.string "category"
t.text "config", limit: 65535
t.text "helper_code", limit: 65535
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
t.index ["deleted_at"], name: "index_blocks_on_deleted_at", using: :btree
t.index ["pool", "name"], name: "index_blocks_on_pool_and_name", unique: true, using: :btree
Expand Down
2 changes: 1 addition & 1 deletion pegasus/sites.v3/code.org/public/circuitplayground.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ If you meet **all** of the eligibility requirements, you will qualify for a subs
* **For teachers in schools with 40% or greater free/reduced price meals,** the classroom kit will be 100% subsidized, resulting in no cost to the teacher/school, including shipping.
* **For teachers at schools with less than 40% free/reduced price meals,** the classroom kit will not be subsidized. Teachers will be expected to pay for the full cost of the kit (approx. $350), though this price will be reduced by a 10% discount for educators to an approximate total of $315. To get the educator discount, teachers must apply the code ADAEDU at checkout.

If a teacher has a smaller class size and does not qualify for or need a full 15 board kit (which supports 30 students), they may purchase a <a href="https://www.adafruit.com/product/3795", target=_"blank">Code.org Circuit Playground Individual Kit</a>. The Individual Kit is designed for a single student or share-pair, costs $29.95, and is also eligible for the 10% educator discount.
If a teacher has a smaller class size and does not qualify for or need a full 15 board kit (which supports 30 students), they may purchase a <a href="https://www.adafruit.com/product/3795", target=_"blank">Code.org Circuit Playground Individual Kit</a>. The Individual Kit is designed for a single student or share-pair, costs $29.95.

**In January 2019,** teachers will receive an email from us with more information about how to request a subsidy for the Adafruit Circuit Playground classroom kit on our website. In the meantime, qualified teachers should make sure they're on track in the 2018-19 school year to complete the first semester of CS Discoveries (Units 1-3) with their students.

Expand Down

0 comments on commit d208039

Please sign in to comment.