Merge "UI: remove immutability-helper dependency"

This commit is contained in:
Zuul
2021-09-22 10:43:14 +00:00
committed by Gerrit Code Review
9 changed files with 37 additions and 48 deletions

View File

@@ -10,7 +10,6 @@
"@patternfly/react-core": "4.152.4",
"@patternfly/react-table": "4.29.58",
"axios": "^0.19.0",
"immutability-helper": "^2.8.1",
"js-yaml": "^3.13.0",
"lodash": "^4.17.10",
"moment": "^2.22.2",

View File

@@ -12,8 +12,6 @@
// License for the specific language governing permissions and limitations
// under the License.
import update from 'immutability-helper'
import {
ADD_ERROR,
CLEAR_ERROR,
@@ -31,14 +29,13 @@ export default (state = [], action) => {
case ADD_ERROR:
if (state.filter(error => (
error.url === action.error.url &&
error.status === action.error.status)).length > 0)
error.status === action.error.status)).length > 0)
return state
action.error.id = action.id
action.error.date = Date.now()
return update(state, {$push: [action.error]})
return [
...state,
{ ...action.error, id: action.id, date: Date.now() }]
case CLEAR_ERROR:
return update(state, {$splice: [[state.indexOf(
state.filter(item => (item.id === action.id))[0]), 1]]})
return state.filter(item => (item.id !== action.id))
case CLEAR_ERRORS:
return []
default:

View File

@@ -18,8 +18,6 @@ import {
JOBS_FETCH_SUCCESS
} from '../actions/jobs'
import update from 'immutability-helper'
export default (state = {
isFetching: false,
jobs: {},
@@ -33,7 +31,10 @@ export default (state = {
case JOBS_FETCH_SUCCESS:
return {
isFetching: false,
jobs: update(state.jobs, {$merge: {[action.tenant]: action.jobs}}),
jobs: {
...state.jobs,
[action.tenant]: action.jobs
},
}
case JOBS_FETCH_FAIL:
return {

View File

@@ -18,8 +18,6 @@ import {
LABELS_FETCH_SUCCESS
} from '../actions/labels'
import update from 'immutability-helper'
export default (state = {
isFetching: false,
labels: {},
@@ -33,8 +31,10 @@ export default (state = {
case LABELS_FETCH_SUCCESS:
return {
isFetching: false,
labels: update(
state.labels, {$merge: {[action.tenant]: action.labels}}),
labels: {
...state.labels,
[action.tenant]: action.labels,
}
}
case LABELS_FETCH_FAIL:
return {

View File

@@ -18,8 +18,6 @@ import {
NODES_FETCH_SUCCESS
} from '../actions/nodes'
import update from 'immutability-helper'
export default (state = {
receivedAt: 0,
isFetching: false,
@@ -27,15 +25,22 @@ export default (state = {
}, action) => {
switch (action.type) {
case NODES_FETCH_REQUEST:
return update(state, {$merge: {isFetching: true}})
return {
...state,
isFetching: true,
}
case NODES_FETCH_SUCCESS:
return update(state, {$merge: {
return {
...state,
isFetching: false,
nodes: action.nodes,
receivedAt: action.receivedAt
}})
receivedAt: action.receivedAt,
}
case NODES_FETCH_FAIL:
return update(state, {$merge: {isFetching: false}})
return {
...state,
isFetching: false
}
default:
return state
}

View File

@@ -12,8 +12,6 @@
// License for the specific language governing permissions and limitations
// under the License.
import update from 'immutability-helper'
import {
PREFERENCE_SET,
} from '../actions/preferences'
@@ -35,7 +33,7 @@ export default (state = {
let newstate
switch (action.type) {
case PREFERENCE_SET:
newstate = update(state, {$merge: {[action.key]: action.value}})
newstate = { ...state, [action.key]: action.value }
localStorage.setItem('preferences', JSON.stringify(newstate))
return newstate
default:

View File

@@ -18,12 +18,11 @@ import {
PROJECT_FETCH_SUCCESS
} from '../actions/project'
import update from 'immutability-helper'
export default (state = {
isFetching: false,
projects: {},
}, action) => {
let state_projects
switch (action.type) {
case PROJECT_FETCH_REQUEST:
return {
@@ -31,18 +30,18 @@ export default (state = {
projects: state.projects,
}
case PROJECT_FETCH_SUCCESS:
if (!state.projects[action.tenant]) {
state.projects = update(state.projects, {$merge: {[action.tenant]: {}}})
}
state_projects = !state.projects[action.tenant] ?
{ ...state.projects, [action.tenant]: {} } :
{ ...state.projects }
return {
isFetching: false,
projects: update(state.projects, {
projects: {
...state_projects,
[action.tenant]: {
$merge: {
[action.projectName]: action.project
}
...state_projects[action.tenant],
[action.projectName]: action.project
}
})
}
}
case PROJECT_FETCH_FAIL:
return {

View File

@@ -18,8 +18,6 @@ import {
PROJECTS_FETCH_SUCCESS
} from '../actions/projects'
import update from 'immutability-helper'
export default (state = {
isFetching: false,
projects: {},
@@ -33,8 +31,7 @@ export default (state = {
case PROJECTS_FETCH_SUCCESS:
return {
isFetching: false,
projects: update(
state.projects, {$merge: {[action.tenant]: action.projects}}),
projects: { ...state.projects, [action.tenant]: action.projects },
}
case PROJECTS_FETCH_FAIL:
return {

View File

@@ -7110,13 +7110,6 @@ immer@1.10.0:
resolved "https://registry.yarnpkg.com/immer/-/immer-1.10.0.tgz#bad67605ba9c810275d91e1c2a47d4582e98286d"
integrity sha512-O3sR1/opvCDGLEVcvrGTMtLac8GJ5IwZC4puPrLuRj3l7ICKvkmA0vGuU9OW8mV9WIBRnaxp5GJh9IEAaNOoYg==
immutability-helper@^2.8.1:
version "2.9.1"
resolved "https://registry.yarnpkg.com/immutability-helper/-/immutability-helper-2.9.1.tgz#71c423ba387e67b6c6ceba0650572f2a2a6727df"
integrity sha512-r/RmRG8xO06s/k+PIaif2r5rGc3j4Yhc01jSBfwPCXDLYZwp/yxralI37Df1mwmuzcCsen/E/ITKcTEvc1PQmQ==
dependencies:
invariant "^2.2.0"
immutable@^3.8.1, immutable@^3.x.x:
version "3.8.2"
resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3"
@@ -7316,7 +7309,7 @@ into-stream@^5.0.0:
from2 "^2.3.0"
p-is-promise "^3.0.0"
invariant@^2.0.0, invariant@^2.1.0, invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2, invariant@^2.2.4:
invariant@^2.0.0, invariant@^2.1.0, invariant@^2.2.1, invariant@^2.2.2, invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==