chore(ui): remove unused actions and reducers

pull/5925/head
Pavel Zavora 2022-06-06 09:34:06 +02:00
parent 84ddc0e44f
commit 9d19b98e2f
5 changed files with 0 additions and 74 deletions

View File

@ -84,10 +84,6 @@ export const loadDatabases = databases => ({
},
})
export const addUser = () => ({
type: 'INFLUXDB_ADD_USER',
})
export const addRole = () => ({
type: 'INFLUXDB_ADD_ROLE',
})
@ -136,14 +132,6 @@ export const syncRetentionPolicy = (database, stale, synced) => ({
},
})
export const editUser = (user, updates) => ({
type: 'INFLUXDB_EDIT_USER',
payload: {
user,
updates,
},
})
export const editRole = (role, updates) => ({
type: 'INFLUXDB_EDIT_ROLE',
payload: {
@ -320,8 +308,6 @@ export const createUserAsync = (url, user) => async dispatch => {
dispatch(syncUser(user, data))
} catch (error) {
dispatch(errorThrown(error, notifyDBUserCreationFailed(error.data.message)))
// undo optimistic update
setTimeout(() => dispatch(deleteUser(user)), REVERT_STATE_DELAY)
}
}

View File

@ -1,12 +1,3 @@
export const NEW_DEFAULT_USER = {
name: '',
password: '',
roles: [],
permissions: [],
links: {self: ''},
isNew: true,
}
export const NEW_DEFAULT_ROLE = {
name: '',
permissions: [],

View File

@ -1,6 +1,5 @@
import reject from 'lodash/reject'
import {
NEW_DEFAULT_USER,
NEW_DEFAULT_ROLE,
NEW_DEFAULT_DATABASE,
NEW_EMPTY_RP,
@ -67,14 +66,6 @@ const adminInfluxDB = (state = initialState, action) => {
return {...state, ...action.payload}
}
case 'INFLUXDB_ADD_USER': {
const newUser = {...NEW_DEFAULT_USER, isEditing: true}
return {
...state,
users: [newUser, ...state.users],
}
}
case 'INFLUXDB_ADD_ROLE': {
const newRole = {...NEW_DEFAULT_ROLE, isEditing: true}
return {
@ -164,16 +155,6 @@ const adminInfluxDB = (state = initialState, action) => {
return {...state, ...newState}
}
case 'INFLUXDB_EDIT_USER': {
const {user, updates} = action.payload
const newState = {
users: state.users.map(u =>
u.links.self === user.links.self ? {...u, ...updates} : u
),
}
return {...state, ...newState}
}
case 'INFLUXDB_EDIT_ROLE': {
const {role, updates} = action.payload
const newState = {

View File

@ -25,9 +25,7 @@ export interface User {
self: string
}
// UI only
isEditing?: boolean
password?: string
isNew?: boolean
hidden?: boolean
}

View File

@ -1,13 +1,11 @@
import reducer from 'src/admin/reducers/influxdb'
import {
addUser,
addRole,
addDatabase,
addRetentionPolicy,
syncUser,
syncRole,
editUser,
editRole,
editDatabase,
editRetentionPolicyRequested,
@ -26,7 +24,6 @@ import {
} from 'src/admin/actions/influxdb'
import {
NEW_DEFAULT_USER,
NEW_DEFAULT_ROLE,
NEW_DEFAULT_DATABASE,
NEW_EMPTY_RP,
@ -219,19 +216,6 @@ describe('Admin.InfluxDB.Reducers', () => {
})
})
it('it can add a user', () => {
state = {
users: [u1],
}
const actual = reducer(state, addUser())
const expected = {
users: [{...NEW_DEFAULT_USER, isEditing: true}, u1],
}
expect(actual.users).toEqual(expected.users)
})
it('it can sync a stale user', () => {
const staleUser = {...u1, roles: []}
state = {users: [u2, staleUser]}
@ -255,20 +239,6 @@ describe('Admin.InfluxDB.Reducers', () => {
expect(actual.users).toEqual(expected.users)
})
it('it can edit a user', () => {
const updates = {name: 'onecool'}
state = {
users: [u2, u1],
}
const actual = reducer(state, editUser(u2, updates))
const expected = {
users: [{...u2, ...updates}, u1],
}
expect(actual.users).toEqual(expected.users)
})
it('it can add a role', () => {
state = {
roles: [r1],