Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #34 from PanSpagetka/tagging-changes
Browse files Browse the repository at this point in the history
Tagging changes
  • Loading branch information
karelhala authored Jun 7, 2018
2 parents bd64b46 + 7765854 commit 4f7503f
Show file tree
Hide file tree
Showing 19 changed files with 277 additions and 124 deletions.
3 changes: 1 addition & 2 deletions src/tagging/components/tag.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { Label } from 'patternfly-react';
import styles from './tag.scss';


const Tag = ({
Expand All @@ -12,7 +11,7 @@ const Tag = ({
key={tagValue.id}
bsStyle="primary"
onRemoveClick={() => onTagDeleteClick(tagCategory, tagValue)}
style={{ color: styles.defaultColor }}
className="tagColor"
>
{tagValue.description}
</Label>
Expand Down
16 changes: 0 additions & 16 deletions src/tagging/components/tag.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/tagging/components/tagCategory.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import Tag from './tag';
import './tagCategory.scss';

class TagCategory extends React.Component {
generateTag = tagValue =>
Expand Down
21 changes: 0 additions & 21 deletions src/tagging/components/tagCategory.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/tagging/components/tagSelector.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import Select from 'react-select';
import PropTypes from 'prop-types';
import './tagSelector.scss';

class TagSelector extends React.Component {
handleChange = (selectedOption) => {
Expand Down
17 changes: 0 additions & 17 deletions src/tagging/components/tagSelector.scss

This file was deleted.

2 changes: 1 addition & 1 deletion src/tagging/components/taggingWithButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TaggingWithButtons extends React.Component {
<ButtonToolbar>
<ButtonGroup>
<Button
onClick={this.props.saveButton.onClick}
onClick={() => this.props.saveButton.onClick(this.props.assignedTags)}
href={this.props.saveButton.href}
disabled={this.props.saveButton.disabled}
type={this.props.saveButton.type}
Expand Down
10 changes: 5 additions & 5 deletions src/tagging/containers/tagging.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Tagging from '../components/tagging';
import TaggingWithButtons from '../components/taggingWithButtons';

// container compo
const mapStateToProps = state => ({
tags: state.tagging.appState.tags,
selectedTagCategory: state.tagging.appState.selected.tagCategory,
selectedTagValue: state.tagging.appState.selected.tagValue,
assignedTags: state.tagging.appState.assignedTags,
const mapStateToProps = ({ tagging }) => ({
tags: tagging.appState.tags,
selectedTagCategory: tagging.appState.selected.tagCategory,
selectedTagValue: tagging.appState.selected.tagValue,
assignedTags: tagging.appState.assignedTags,
});


Expand Down
Empty file removed src/tagging/index.scss
Empty file.
3 changes: 2 additions & 1 deletion src/tagging/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { combineReducers } from 'redux';
import { modifyassignedTags as assignedTags, toggle as selected, tags, initialize } from './reducers';
import { modifyassignedTags as assignedTags, toggle as selected, tags, initialize, affectedItems } from './reducers';

const combinedReducers = combineReducers({
tags,
assignedTags,
selected,
affectedItems,
});


Expand Down
16 changes: 11 additions & 5 deletions src/tagging/reducers/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,22 @@ export const toggle = (state = { tagCategory: {}, tagValue: {} }, action) => {
};

export const tags = (state = []) => state;
export const affectedItems = (state = []) => state;

export const initialize = (state = {}, action) => {
switch (action.type) {
case actionsConstants.LOAD_STATE:
return Object.assign(
{ initialState: action.initialState },
{ appState: { tags: action.initialState.tags, assignedTags: action.initialState.assignedTags } },
);
return {
...state,
initialState: action.initialState,
appState: {
tags: action.initialState.tags,
assignedTags: action.initialState.assignedTags,
affectedItems: action.initialState.affectedItems,
},
};
case actionsConstants.RESET_STATE:
return { ...state, appState: state.initialState };
return { ...state, appState: { ...state.initialState } };
default:
return { ...state };
}
Expand Down
6 changes: 4 additions & 2 deletions src/tagging/stories/tagging.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const singleTags = [
},
];
const assignedTags = [{ tagCategory: { description: 'Name', id: 1 }, tagValues: [{ description: 'Pepa', id: 11 }] }];
const selectedTagCategory = 'animal';
const selectedTagValue = 'pig';
const selectedTagCategory = {};
const selectedTagValue = {};
const defaultState = { tags, assignedTags };
const defaultStateSingle = { singleTags, assignedTags };
const store = createStore(taggingApp);
Expand All @@ -53,6 +53,8 @@ storiesOf('Tagging', module)
selectedTagCategory={selectedTagCategory}
selectedTagValue={selectedTagValue}
/>));


storiesOf('Tagging', module)
.add('Simple Tagging', () => <Provider store={store}><TaggingConnected /></Provider>);
storiesOf('Tagging', module)
Expand Down
14 changes: 2 additions & 12 deletions src/tagging/tests/__snapshots__/tag.category.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ exports[`TagCategory Component match snapshot 1`] = `
className="tag"
>
<span
className="label label-primary"
style={
Object {
"color": "defaultColor",
}
}
className="tagColor label label-primary"
>
duck
<a
Expand All @@ -42,12 +37,7 @@ exports[`TagCategory Component match snapshot 1`] = `
className="tag"
>
<span
className="label label-primary"
style={
Object {
"color": "defaultColor",
}
}
className="tagColor label label-primary"
>
lion
<a
Expand Down
Loading

0 comments on commit 4f7503f

Please sign in to comment.