Skip to content

Commit

Permalink
feat(admin-ui): design the layout for api role management #327
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Dec 2, 2021
1 parent 5d17005 commit 7ed9533
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 50 deletions.
20 changes: 15 additions & 5 deletions plugins/admin/redux/api/PermissionApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@ export default class PermissionApi {
this.api = api
}
getPermissions = () => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}
getPermission = (options) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

addPermission = (data) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

editPermission = (data) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

deletePermission = async (inum) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

handleResponse(error, reject, resolve, data) {
Expand Down
20 changes: 15 additions & 5 deletions plugins/admin/redux/api/RoleApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@ export default class RoleApi {
this.api = api
}
getRoles = () => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}
getRole = (options) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

addRole = (data) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

editRole = (data) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

deleteRole = async (inum) => {
return new Promise((resolve, reject) => {})
return new Promise((resolve, reject) => {
console.log('=============')
})
}

handleResponse(error, reject, resolve, data) {
Expand Down
32 changes: 12 additions & 20 deletions plugins/admin/redux/reducers/ApiPermissionReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const reducerName = 'apiPermissionReducer'
export default function apiPermissionReducer(state = INIT_STATE, action) {
switch (action.type) {
case GET_PERMISSIONS:
return {
...state,
loading: true,
}
return handleLoading()
case GET_PERMISSIONS_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -37,10 +34,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
return handleDefault()
}
case GET_PERMISSION:
return {
...state,
loading: true,
}
return handleLoading()
case GET_PERMISSION_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -52,10 +46,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
return handleDefault()
}
case ADD_PERMISSION:
return {
...state,
loading: true,
}
return handleLoading()
case ADD_PERMISSION_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -68,10 +59,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
}

case EDIT_PERMISSION:
return {
...state,
loading: true,
}
return handleLoading()
case EDIT_PERMISSION_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -84,10 +72,7 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
}

case DELETE_PERMISSION:
return {
...state,
loading: true,
}
return handleLoading()
case DELETE_PERMISSION_RESPONSE:
if (action.payload.inum) {
return {
Expand Down Expand Up @@ -122,5 +107,12 @@ export default function apiPermissionReducer(state = INIT_STATE, action) {
loading: false,
}
}

function handleLoading() {
return {
...state,
loading: true,
}
}
}
reducerRegistry.register(reducerName, apiPermissionReducer)
32 changes: 12 additions & 20 deletions plugins/admin/redux/reducers/ApiRoleReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ const reducerName = 'apiRoleReducer'
export default function apiRoleReducer(state = INIT_STATE, action) {
switch (action.type) {
case GET_ROLES:
return {
...state,
loading: true,
}
return handleLoading()
case GET_ROLES_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -39,10 +36,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
return handleDefault()
}
case GET_ROLE:
return {
...state,
loading: true,
}
return handleLoading()
case GET_ROLE_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -54,10 +48,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
return handleDefault()
}
case ADD_ROLE:
return {
...state,
loading: true,
}
return handleLoading()
case ADD_ROLE_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -70,10 +61,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
}

case EDIT_ROLE:
return {
...state,
loading: true,
}
return handleLoading()
case EDIT_ROLE_RESPONSE:
if (action.payload.data) {
return {
Expand All @@ -86,10 +74,7 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
}

case DELETE_ROLE:
return {
...state,
loading: true,
}
return handleLoading()
case DELETE_ROLE_RESPONSE:
if (action.payload.inum) {
return {
Expand Down Expand Up @@ -118,6 +103,13 @@ export default function apiRoleReducer(state = INIT_STATE, action) {
return handleDefault()
}

function handleLoading() {
return {
...state,
loading: true,
}
}

function handleDefault() {
return {
...state,
Expand Down

0 comments on commit 7ed9533

Please sign in to comment.