diff --git a/packages/server/src/api/controllers/screen.js b/packages/server/src/api/controllers/screen.js index 694d171fff..acf6df22f0 100644 --- a/packages/server/src/api/controllers/screen.js +++ b/packages/server/src/api/controllers/screen.js @@ -20,29 +20,13 @@ exports.fetch = async ctx => { ) } -exports.find = async ctx => { - const appId = ctx.user.appId - const db = new CouchDB(appId) - - const screens = await db.allDocs( - getScreenParams(ctx.params.pageId, { - include_docs: true, - }) - ) - - ctx.body = await new AccessController(appId).checkScreensAccess( - screens, - ctx.user.accessLevel._id - ) -} - exports.save = async ctx => { const appId = ctx.user.appId const db = new CouchDB(appId) const screen = ctx.request.body if (!screen._id) { - screen._id = generateScreenID(ctx.params.pageId) + screen._id = generateScreenID() } delete screen._css const response = await db.put(screen) diff --git a/packages/server/src/api/routes/screen.js b/packages/server/src/api/routes/screen.js index ce49f66043..1b21a58452 100644 --- a/packages/server/src/api/routes/screen.js +++ b/packages/server/src/api/routes/screen.js @@ -30,9 +30,8 @@ function generateSaveValidation() { router .get("/api/screens", authorized(BUILDER), controller.fetch) - .get("/api/screens/:pageId", authorized(BUILDER), controller.find) .post( - "/api/screens/:pageId", + "/api/screens", authorized(BUILDER), generateSaveValidation(), controller.save diff --git a/packages/server/src/db/utils.js b/packages/server/src/db/utils.js index 4edb27a416..c3b5866a2a 100644 --- a/packages/server/src/db/utils.js +++ b/packages/server/src/db/utils.js @@ -179,14 +179,6 @@ exports.getAccessLevelParams = (accessLevelId = null, otherProps = {}) => { return getDocParams(DocumentTypes.ACCESS_LEVEL, accessLevelId, otherProps) } -/** - * Generates a new webhook ID. - * @returns {string} The new webhook ID which the webhook doc can be stored under. - */ -exports.generateWebhookID = () => { - return `${DocumentTypes.WEBHOOK}${SEPARATOR}${newid()}` -} - /** * Generates a new page ID. * @returns {string} The new page ID which the page doc can be stored under. @@ -206,15 +198,23 @@ exports.getPageParams = (pageId = null, otherProps = {}) => { * Generates a new screen ID. * @returns {string} The new screen ID which the screen doc can be stored under. */ -exports.generateScreenID = pageId => { - return `${DocumentTypes.SCREEN}${SEPARATOR}${pageId}${SEPARATOR}${newid()}` +exports.generateScreenID = () => { + return `${DocumentTypes.SCREEN}${SEPARATOR}${newid()}` } /** - * Gets parameters for retrieving screens for a particular page, this is a utility function for the getDocParams function. + * Gets parameters for retrieving screens, this is a utility function for the getDocParams function. */ -exports.getScreenParams = (pageId = null, otherProps = {}) => { - return getDocParams(DocumentTypes.SCREEN, pageId, otherProps) +exports.getScreenParams = (screenId = null, otherProps = {}) => { + return getDocParams(DocumentTypes.SCREEN, screenId, otherProps) +} + +/** + * Generates a new webhook ID. + * @returns {string} The new webhook ID which the webhook doc can be stored under. + */ +exports.generateWebhookID = () => { + return `${DocumentTypes.WEBHOOK}${SEPARATOR}${newid()}` } /**