diff --git a/package.json b/package.json index 8f9fc14..2908d79 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "1.0.0", "private": true, "dependencies": { - "@databraid/github-widget": "^1.0.23", - "@databraid/sheets-widget": "^1.0.5", - "@databraid/slack-widget": "^1.0.24", - "@databraid/transit-widget": "^1.0.26", + "@databraid/github-widget": "^1.0.29", + "@databraid/sheets-widget": "^1.0.10", + "@databraid/slack-widget": "^1.0.27", + "@databraid/transit-widget": "^1.0.29", "localforage": "1.5.0", "prop-types": "15.5.10", "react": "15.6.1", diff --git a/src/actions/actions.test.js b/src/actions/actions.test.js index 67629c5..0948a90 100644 --- a/src/actions/actions.test.js +++ b/src/actions/actions.test.js @@ -5,55 +5,55 @@ describe('actions', () => { it('should create an action to add a transit widget', () => { const expectedAction = { type: TYPES.ADD_WIDGET, - id: TYPES.TRANSIT_WIDGET_ID, + widgetType: TYPES.TRANSIT_WIDGET, }; - expect(actions.addWidget(TYPES.TRANSIT_WIDGET_ID)).toEqual(expectedAction); + expect(actions.addWidget(TYPES.TRANSIT_WIDGET)).toEqual(expectedAction); }); it('should create an action to add a slack widget', () => { const expectedAction = { type: TYPES.ADD_WIDGET, - id: TYPES.SLACK_WIDGET_ID, + widgetType: TYPES.SLACK_WIDGET, }; - expect(actions.addWidget(TYPES.SLACK_WIDGET_ID)).toEqual(expectedAction); + expect(actions.addWidget(TYPES.SLACK_WIDGET)).toEqual(expectedAction); }); it('should create an action to add a github widget', () => { const expectedAction = { type: TYPES.ADD_WIDGET, - id: TYPES.GITHUB_WIDGET_ID, + widgetType: TYPES.GITHUB_WIDGET, }; - expect(actions.addWidget(TYPES.GITHUB_WIDGET_ID)).toEqual(expectedAction); + expect(actions.addWidget(TYPES.GITHUB_WIDGET)).toEqual(expectedAction); }); it('should create an action to remove a transit widget', () => { const expectedAction = { type: TYPES.REMOVE_WIDGET, - id: TYPES.TRANSIT_WIDGET_ID, + id: TYPES.TRANSIT_WIDGET, }; - expect(actions.removeWidget(TYPES.TRANSIT_WIDGET_ID)).toEqual(expectedAction); + expect(actions.removeWidget(TYPES.TRANSIT_WIDGET)).toEqual(expectedAction); }); it('should create an action to remove a slack widget', () => { const expectedAction = { type: TYPES.REMOVE_WIDGET, - id: TYPES.SLACK_WIDGET_ID, + id: TYPES.SLACK_WIDGET, }; - expect(actions.removeWidget(TYPES.SLACK_WIDGET_ID)).toEqual(expectedAction); + expect(actions.removeWidget(TYPES.SLACK_WIDGET)).toEqual(expectedAction); }); it('should create an action to remove a github widget', () => { const expectedAction = { type: TYPES.REMOVE_WIDGET, - id: TYPES.GITHUB_WIDGET_ID, + id: TYPES.GITHUB_WIDGET, }; - expect(actions.removeWidget(TYPES.GITHUB_WIDGET_ID)).toEqual(expectedAction); + expect(actions.removeWidget(TYPES.GITHUB_WIDGET)).toEqual(expectedAction); }); it('should create an action to show widget modal', () => { @@ -91,55 +91,55 @@ describe('actions', () => { it('should create an action to show a transit widget sidebar', () => { const expectedAction = { type: TYPES.SHOW_WIDGET_SIDEBAR, - id: TYPES.TRANSIT_WIDGET_ID, + id: TYPES.TRANSIT_WIDGET, }; - expect(actions.showWidgetSidebar(TYPES.TRANSIT_WIDGET_ID)).toEqual(expectedAction); + expect(actions.showWidgetSidebar(TYPES.TRANSIT_WIDGET)).toEqual(expectedAction); }); it('should create an action to show a slack widget sidebar', () => { const expectedAction = { type: TYPES.SHOW_WIDGET_SIDEBAR, - id: TYPES.SLACK_WIDGET_ID, + id: TYPES.SLACK_WIDGET, }; - expect(actions.showWidgetSidebar(TYPES.SLACK_WIDGET_ID)).toEqual(expectedAction); + expect(actions.showWidgetSidebar(TYPES.SLACK_WIDGET)).toEqual(expectedAction); }); it('should create an action to show a github widget sidebar', () => { const expectedAction = { type: TYPES.SHOW_WIDGET_SIDEBAR, - id: TYPES.GITHUB_WIDGET_ID, + id: TYPES.GITHUB_WIDGET, }; - expect(actions.showWidgetSidebar(TYPES.GITHUB_WIDGET_ID)).toEqual(expectedAction); + expect(actions.showWidgetSidebar(TYPES.GITHUB_WIDGET)).toEqual(expectedAction); }); it('should create an action to hide a transit widget sidebar', () => { const expectedAction = { type: TYPES.HIDE_WIDGET_SIDEBAR, - id: TYPES.TRANSIT_WIDGET_ID, + id: TYPES.TRANSIT_WIDGET, }; - expect(actions.hideWidgetSidebar(TYPES.TRANSIT_WIDGET_ID)).toEqual(expectedAction); + expect(actions.hideWidgetSidebar(TYPES.TRANSIT_WIDGET)).toEqual(expectedAction); }); it('should create an action to hide a slack widget sidebar', () => { const expectedAction = { type: TYPES.HIDE_WIDGET_SIDEBAR, - id: TYPES.SLACK_WIDGET_ID, + id: TYPES.SLACK_WIDGET, }; - expect(actions.hideWidgetSidebar(TYPES.SLACK_WIDGET_ID)).toEqual(expectedAction); + expect(actions.hideWidgetSidebar(TYPES.SLACK_WIDGET)).toEqual(expectedAction); }); it('should create an action to hide a github widget sidebar', () => { const expectedAction = { type: TYPES.HIDE_WIDGET_SIDEBAR, - id: TYPES.GITHUB_WIDGET_ID, + id: TYPES.GITHUB_WIDGET, }; - expect(actions.hideWidgetSidebar(TYPES.GITHUB_WIDGET_ID)).toEqual(expectedAction); + expect(actions.hideWidgetSidebar(TYPES.GITHUB_WIDGET)).toEqual(expectedAction); }); it('should create an action to lock the widgets', () => { diff --git a/src/actions/index.js b/src/actions/index.js index 23182be..b24da8b 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -13,7 +13,7 @@ import { } from '../constants'; export function addWidget(widgetType) { - return { type: ADD_WIDGET, id: widgetType }; + return { type: ADD_WIDGET, widgetType }; } export function removeWidget(widgetId) { diff --git a/src/components/ModalAddWidget/index.jsx b/src/components/ModalAddWidget/index.jsx index d3de5ca..73d0e06 100644 --- a/src/components/ModalAddWidget/index.jsx +++ b/src/components/ModalAddWidget/index.jsx @@ -3,17 +3,13 @@ import { Button, Header, Icon, Modal } from 'semantic-ui-react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { - TRANSIT_WIDGET_ID, - SLACK_WIDGET_ID, - GITHUB_WIDGET_ID, - SHEETS_WIDGET_ID, -} from '../../constants'; import { addWidget, hideAddWidgetModal, } from '../../actions'; +import widgetConfigs from '../../configurations'; +/* eslint-disable react/no-unused-prop-types */ export const AddWidgetModal = props => (
@@ -21,42 +17,21 @@ export const AddWidgetModal = props => (

Please pick the widget you wish to display.

- - - - + { + Object.values(widgetConfigs).map(cfg => ( + + ), + ) + }