Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from plone/control-panels
Control panels
- Loading branch information
Showing
37 changed files
with
1,315 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Controlpanel actions. | ||
* @module actions/controlpanel/controlpanel | ||
*/ | ||
|
||
import { | ||
EDIT_CONTROLPANEL, | ||
GET_CONTROLPANEL, | ||
} from '../../constants/ActionTypes'; | ||
|
||
/** | ||
* Get controlpanel function. | ||
* @function getControlpanel | ||
* @param {id} id Controlpanel id. | ||
* @returns {Object} Get controlpanel action. | ||
*/ | ||
export function getControlpanel(id) { | ||
return { | ||
type: GET_CONTROLPANEL, | ||
promise: api => api.get(`/@controlpanels/${id}`), | ||
}; | ||
} | ||
|
||
/** | ||
* Edit controlpanel function. | ||
* @function editControlpanel | ||
* @param {string} url Controlpanel url. | ||
* @param {Object} data Controlpanel data. | ||
* @returns {Object} Edit controlpanel action. | ||
*/ | ||
export function editControlpanel(url, data) { | ||
return { | ||
type: EDIT_CONTROLPANEL, | ||
promise: api => api.patch(url, { data }), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { editControlpanel, getControlpanel } from './controlpanel'; | ||
import { | ||
EDIT_CONTROLPANEL, | ||
GET_CONTROLPANEL, | ||
} from '../../constants/ActionTypes'; | ||
|
||
describe('Controlpanel action', () => { | ||
describe('getControlpanel', () => { | ||
it('should create an action to get the controlpanel', () => { | ||
const url = 'my-url'; | ||
const action = getControlpanel(url); | ||
|
||
expect(action.type).toEqual(GET_CONTROLPANEL); | ||
|
||
const apiMock = { | ||
get: jest.fn(), | ||
}; | ||
action.promise(apiMock); | ||
|
||
expect(apiMock.get).toBeCalledWith(`/@controlpanels/${url}`); | ||
}); | ||
}); | ||
|
||
describe('editControlpanel', () => { | ||
it('should create an action to edit a controlpanel', () => { | ||
const url = 'http://localhost'; | ||
const data = 'Hello World!'; | ||
const action = editControlpanel(url, data); | ||
|
||
expect(action.type).toEqual(EDIT_CONTROLPANEL); | ||
|
||
const apiMock = { | ||
patch: jest.fn(), | ||
}; | ||
action.promise(apiMock); | ||
|
||
expect(apiMock.patch).toBeCalledWith(url, { data }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Controlpanels actions. | ||
* @module actions/controlpanels/controlpanels | ||
*/ | ||
|
||
import { GET_CONTROLPANELS } from '../../constants/ActionTypes'; | ||
|
||
/** | ||
* Get controlpanels function. | ||
* @function getControlpanels | ||
* @returns {Object} Get controlpanels action. | ||
*/ | ||
export default function getControlpanels() { | ||
return { | ||
type: GET_CONTROLPANELS, | ||
promise: api => api.get('/@controlpanels'), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import getControlpanels from './controlpanels'; | ||
import { GET_CONTROLPANELS } from '../../constants/ActionTypes'; | ||
|
||
describe('Controlpanels action', () => { | ||
describe('getControlpanels', () => { | ||
it('should create an action to get the controlpanels', () => { | ||
const action = getControlpanels(); | ||
|
||
expect(action.type).toEqual(GET_CONTROLPANELS); | ||
|
||
const apiMock = { | ||
get: jest.fn(), | ||
}; | ||
action.promise(apiMock); | ||
|
||
expect(apiMock.get).toBeCalledWith('/@controlpanels'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.