From d967896874f384c8eed12714b2dc6fe33a8d73f7 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 2 May 2024 13:50:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5(app-impress)=20remove=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We will generate the templates internally. We remove the template editor. --- .../app-impress/template-editor.spec.ts | 174 ------------------ src/frontend/apps/impress/package.json | 1 - .../apps/impress/src/features/menu/Menu.tsx | 6 - .../features/menu/assets/icon-template.svg | 20 -- .../impress/src/features/templates/index.ts | 3 - .../templates/template-create/api/index.ts | 1 - .../template-create/api/useCreateTemplate.tsx | 41 ----- .../components/CardCreateTemplate.tsx | 77 -------- .../components/InputTemplateName.tsx | 54 ------ .../template-create/components/index.ts | 1 - .../templates/template-create/index.ts | 2 - .../__tests__/PanelTemplates.test.tsx | 174 ------------------ .../templates/template-panel/api/index.ts | 1 - .../template-panel/assets/icon-add.svg | 6 - .../template-panel/assets/icon-none.svg | 13 -- .../template-panel/assets/icon-open-close.svg | 14 -- .../template-panel/assets/icon-sort.svg | 13 -- .../template-panel/components/Panel.tsx | 83 --------- .../components/PanelActions.tsx | 60 ------ .../components/TemplateItem.tsx | 102 ---------- .../components/TemplateList.tsx | 105 ----------- .../template-panel/components/index.ts | 1 - .../templates/template-panel/index.ts | 2 - .../templates/template-panel/store/index.ts | 1 - .../store/useTemplatePanelStore.tsx | 19 -- .../features/templates/template/api/index.ts | 1 - .../templates/template/api/useTemplate.tsx | 37 ---- .../template/api/useUpdateTemplate.tsx | 60 ------ .../api/useUpdateTemplateCodeEditor.tsx | 39 ---- .../template/components/TemplateEditor.tsx | 124 ------------- .../template/components/TemplateTools.tsx | 78 -------- .../templates/template/components/index.ts | 1 - .../src/features/templates/template/index.tsx | 3 - .../impress/src/layouts/TemplateLayout.tsx | 26 --- .../apps/impress/src/layouts/index.ts | 1 - .../apps/impress/src/pages/templates/[id].tsx | 67 ------- .../impress/src/pages/templates/create.tsx | 20 -- .../impress/src/pages/templates/index.tsx | 30 --- src/frontend/yarn.lock | 5 - 39 files changed, 1466 deletions(-) delete mode 100644 src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts delete mode 100644 src/frontend/apps/impress/src/features/menu/assets/icon-template.svg delete mode 100644 src/frontend/apps/impress/src/features/templates/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-create/api/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-create/components/CardCreateTemplate.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-create/components/InputTemplateName.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-create/components/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-create/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/__tests__/PanelTemplates.test.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/api/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-add.svg delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-none.svg delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-open-close.svg delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/assets/icon-sort.svg delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/components/Panel.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/components/PanelActions.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateItem.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/components/TemplateList.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/components/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/store/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template-panel/store/useTemplatePanelStore.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template/api/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template/api/useTemplate.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplate.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template/api/useUpdateTemplateCodeEditor.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template/components/TemplateEditor.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template/components/TemplateTools.tsx delete mode 100644 src/frontend/apps/impress/src/features/templates/template/components/index.ts delete mode 100644 src/frontend/apps/impress/src/features/templates/template/index.tsx delete mode 100644 src/frontend/apps/impress/src/layouts/TemplateLayout.tsx delete mode 100644 src/frontend/apps/impress/src/pages/templates/[id].tsx delete mode 100644 src/frontend/apps/impress/src/pages/templates/create.tsx delete mode 100644 src/frontend/apps/impress/src/pages/templates/index.tsx diff --git a/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts deleted file mode 100644 index 0a8f95dc..00000000 --- a/src/frontend/apps/e2e/__tests__/app-impress/template-editor.spec.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { expect, test } from '@playwright/test'; - -import { createTemplate, keyCloakSignIn } from './common'; - -test.beforeEach(async ({ page, browserName }) => { - await page.goto('/'); - await keyCloakSignIn(page, browserName); -}); - -test.describe('Template Editor', () => { - test('checks the template editor interact correctly', async ({ - page, - browserName, - }) => { - const randomTemplate = await createTemplate( - page, - 'template-editor', - browserName, - 1, - ); - - await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible(); - - await page.getByTitle('Open Blocks').click(); - await expect( - page.locator('.gjs-editor .gjs-block[title="Text"]'), - ).toBeVisible(); - }); - - test('checks the template editor save on changed', async ({ - page, - browserName, - }) => { - // eslint-disable-next-line playwright/no-skipped-test - test.skip( - browserName !== 'chromium', - 'This test failed with safary because of the dragNdrop', - ); - - const randomTemplate = await createTemplate( - page, - 'template-editor', - browserName, - 1, - ); - - await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible(); - - const iframe = page.frameLocator('iFrame.gjs-frame'); - - await page.getByTitle('Open Blocks').click(); - await page - .locator('.gjs-editor .gjs-block[title="Text"]') - .dragTo(iframe.locator('body.gjs-dashed')); - - await iframe.getByText('Insert your text here').fill('Hello World'); - await iframe.locator('body.gjs-dashed').click(); - - // Come on the page again to check the changes are saved - await page.locator('menu').first().getByLabel(`Template button`).click(); - const panel = page.getByLabel('Templates panel').first(); - await panel.locator('li').getByText(randomTemplate[0]).click(); - - await expect(iframe.getByText('Hello World')).toBeVisible({ - timeout: 5000, - }); - }); - - test('it saves the html generated by the template', async ({ - page, - browserName, - }) => { - // eslint-disable-next-line playwright/no-skipped-test - test.skip( - browserName !== 'chromium', - 'This test failed with safary because of the dragNdrop', - ); - - const randomTemplate = await createTemplate( - page, - 'template-html', - browserName, - 1, - ); - - await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible(); - - const iframe = page.frameLocator('iFrame.gjs-frame'); - - await page.getByTitle('Open Blocks').click(); - await page - .locator('.gjs-editor .gjs-block[title="Text"]') - .dragTo(iframe.locator('body.gjs-dashed')); - - await iframe.getByText('Insert your text here').fill('Hello World'); - await iframe.locator('body.gjs-dashed').click(); - - await page.getByText('Save template').click(); - await expect(page.getByText('Template save successfully')).toBeVisible(); - }); - - test('it shows a warning if body tag not present', async ({ - page, - browserName, - }) => { - // eslint-disable-next-line playwright/no-skipped-test - test.skip( - browserName !== 'chromium', - 'This test failed with safary because of the dragNdrop', - ); - - const randomTemplate = await createTemplate( - page, - 'template-html', - browserName, - 1, - ); - - await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible(); - - await expect( - page.getByText('The {{body}} tag is necessary to works with the pads.'), - ).toBeVisible(); - - const iframe = page.frameLocator('iFrame.gjs-frame'); - - await page.getByTitle('Open Blocks').click(); - await page - .locator('.gjs-editor .gjs-block[title="Text"]') - .dragTo(iframe.locator('body.gjs-dashed')); - - await iframe.getByText('Insert your text here').fill('{{body}}'); - await iframe.locator('body.gjs-dashed').click(); - - await expect( - page.getByText('The {{body}} tag is necessary to works with the pads.'), - ).toBeHidden(); - }); - - test('it duplicates the template', async ({ page, browserName }) => { - // eslint-disable-next-line playwright/no-skipped-test - test.skip( - browserName !== 'chromium', - 'This test failed with safary because of the dragNdrop', - ); - - const randomTemplate = await createTemplate( - page, - 'template-duplicate', - browserName, - 1, - ); - - await expect(page.locator('h2').getByText(randomTemplate[0])).toBeVisible(); - - const iframe = page.frameLocator('iFrame.gjs-frame'); - - await page.getByTitle('Open Blocks').click(); - await page - .locator('.gjs-editor .gjs-block[title="Text"]') - .dragTo(iframe.locator('body.gjs-dashed')); - - await iframe.getByText('Insert your text here').fill('Hello World'); - await iframe.locator('body.gjs-dashed').click(); - - await page.getByText('Duplicate template').click(); - - await expect( - page.getByText('Template duplicated successfully'), - ).toBeVisible(); - const panel = page.getByLabel('Templates panel').first(); - await expect(panel.getByText(`${randomTemplate[0]} - Copy`)).toBeVisible(); - }); -}); diff --git a/src/frontend/apps/impress/package.json b/src/frontend/apps/impress/package.json index 6d49825c..7fdb1990 100644 --- a/src/frontend/apps/impress/package.json +++ b/src/frontend/apps/impress/package.json @@ -35,7 +35,6 @@ "zustand": "4.5.2" }, "devDependencies": { - "@grapesjs/react": "1.0.0", "@svgr/webpack": "8.1.0", "@tanstack/react-query-devtools": "5.32.0", "@testing-library/jest-dom": "6.4.2", diff --git a/src/frontend/apps/impress/src/features/menu/Menu.tsx b/src/frontend/apps/impress/src/features/menu/Menu.tsx index ffa42004..8ab3ed03 100644 --- a/src/frontend/apps/impress/src/features/menu/Menu.tsx +++ b/src/frontend/apps/impress/src/features/menu/Menu.tsx @@ -6,7 +6,6 @@ import useCunninghamTheme from '@/cunningham/useCunninghamTheme'; import MenuItem from './MenuItems'; import IconPad from './assets/icon-pad.svg'; -import IconTemplate from './assets/icon-template.svg'; export const Menu = () => { const { colorsTokens } = useCunninghamTheme(); @@ -22,11 +21,6 @@ export const Menu = () => { > - ); diff --git a/src/frontend/apps/impress/src/features/menu/assets/icon-template.svg b/src/frontend/apps/impress/src/features/menu/assets/icon-template.svg deleted file mode 100644 index f7b184d7..00000000 --- a/src/frontend/apps/impress/src/features/menu/assets/icon-template.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/src/frontend/apps/impress/src/features/templates/index.ts b/src/frontend/apps/impress/src/features/templates/index.ts deleted file mode 100644 index 2abeb7e5..00000000 --- a/src/frontend/apps/impress/src/features/templates/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './template'; -export * from './template-create'; -export * from './template-panel'; diff --git a/src/frontend/apps/impress/src/features/templates/template-create/api/index.ts b/src/frontend/apps/impress/src/features/templates/template-create/api/index.ts deleted file mode 100644 index f0040687..00000000 --- a/src/frontend/apps/impress/src/features/templates/template-create/api/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useCreateTemplate'; diff --git a/src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx b/src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx deleted file mode 100644 index 4bccc8ea..00000000 --- a/src/frontend/apps/impress/src/features/templates/template-create/api/useCreateTemplate.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { useMutation, useQueryClient } from '@tanstack/react-query'; - -import { APIError, errorCauses, fetchAPI } from '@/api'; -import { KEY_LIST_TEMPLATE, Template } from '@/features/templates'; - -type CreateTemplateParam = Partial