[JENKINS-35831] fix bug during toggle of Favorite: incorrect property names
This commit is contained in:
parent
43f0ed1ec8
commit
196bc993bb
|
@ -4,6 +4,7 @@
|
|||
import React, { Component, PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { List } from 'immutable';
|
||||
|
||||
import { Favorite } from '@jenkins-cd/design-language';
|
||||
|
||||
|
@ -71,8 +72,8 @@ export class FavoritePipeline extends Component {
|
|||
if (this.props.toggleFavorite) {
|
||||
this.props.toggleFavorite(
|
||||
this.context.config,
|
||||
value,
|
||||
this.props.pipeline,
|
||||
value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ export class FavoritePipeline extends Component {
|
|||
FavoritePipeline.propTypes = {
|
||||
className: PropTypes.string,
|
||||
pipeline: PropTypes.object,
|
||||
favorites: PropTypes.array,
|
||||
favorites: PropTypes.instanceOf(List),
|
||||
toggleFavorite: PropTypes.func,
|
||||
};
|
||||
|
||||
|
|
|
@ -58,10 +58,10 @@ export const actions = {
|
|||
};
|
||||
},
|
||||
|
||||
toggleFavorite(config, pipeline, favorite) {
|
||||
toggleFavorite(config, addFavorite, branch) {
|
||||
return (dispatch) => {
|
||||
const baseUrl = config.getRootURL();
|
||||
const url = `${baseUrl}/${pipeline._links.self.href}/favorite`;
|
||||
const url = `${baseUrl}/${branch._links.self.href}/favorite`;
|
||||
const fetchOptions = {
|
||||
...defaultFetchOptions,
|
||||
method: 'PUT',
|
||||
|
@ -69,7 +69,7 @@ export const actions = {
|
|||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{ favorite }
|
||||
{ favorite: addFavorite }
|
||||
),
|
||||
};
|
||||
|
||||
|
@ -77,7 +77,7 @@ export const actions = {
|
|||
return dispatch(actions.generateData(
|
||||
{ url, fetchOptions },
|
||||
ACTION_TYPES.TOGGLE_FAVORITE,
|
||||
{ pipeline, favorite },
|
||||
{ addFavorite, branch },
|
||||
));
|
||||
};
|
||||
},
|
||||
|
|
|
@ -30,7 +30,7 @@ const actionHandlers = {
|
|||
const favoriteList = new List(payload);
|
||||
return state.set('favorites', favoriteList);
|
||||
},
|
||||
[ACTION_TYPES.TOGGLE_FAVORITE](state, { addFavorite, branchToRemove, payload }) {
|
||||
[ACTION_TYPES.TOGGLE_FAVORITE](state, { addFavorite, branch, payload }) {
|
||||
const favoritesList = state.get('favorites');
|
||||
|
||||
if (addFavorite) {
|
||||
|
@ -38,7 +38,7 @@ const actionHandlers = {
|
|||
return state.set('favorites', appendedList);
|
||||
}
|
||||
|
||||
const toggledBranchHref = branchToRemove._links.self.href;
|
||||
const toggledBranchHref = branch._links.self.href;
|
||||
const prunedList = favoritesList.filter(fav => {
|
||||
const favoritedBranch = fav.item;
|
||||
return favoritedBranch._links.self.href !== toggledBranchHref;
|
||||
|
|
|
@ -80,7 +80,7 @@ describe('favoritesStore', () => {
|
|||
{
|
||||
type: ACTION_TYPES.TOGGLE_FAVORITE,
|
||||
addFavorite: false,
|
||||
branchToRemove: createBranch(
|
||||
branch: createBranch(
|
||||
'/blue/rest/organizations/jenkins/pipelines/blueocean/branches/UX-301/'
|
||||
),
|
||||
payload: null,
|
||||
|
@ -117,7 +117,7 @@ describe('favoritesStore', () => {
|
|||
{
|
||||
type: ACTION_TYPES.TOGGLE_FAVORITE,
|
||||
addFavorite: true,
|
||||
branchToRemove: null,
|
||||
branch: null,
|
||||
payload: favoriteToAdd,
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue