Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-24032: Adding Fix for Internal QA #24255

Conversation

manuelrojas
Copy link
Contributor

@manuelrojas manuelrojas commented Mar 2, 2023

Proposed Changes

Fixing the following the changes:

New errors in the console:

Image

If you pass the customBlocks and have no actions, it trows an error as well:

Image

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

Using the following JSON:

{
    "extensions": [
        {
            "url": "http://localhost:8080/application/customBlocks.js"
            
        }
    ]
}

Screenshots

Original Updated
image image

@manuelrojas manuelrojas changed the title dotcms/core#24032 Adding Fix for Internal QA issue-24032: Adding Fix for Internal QA Mar 2, 2023
@manuelrojas manuelrojas linked an issue Mar 2, 2023 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Mar 2, 2023

Postman Tests Report

     65 files  ±0  1 403 suites  ±0   3h 12m 50s ⏱️ - 1m 44s
   625 tests ±0     619 ✔️  - 4  0 💤 ±0    6 +4 
2 335 runs  ±0  2 325 ✔️  - 6  0 💤 ±0  10 +6 

For more details on these failures, see this check.

Results for commit 3ca8dfc. ± Comparison against base commit 9ddae51.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 2, 2023

Unit Tests Report

1 418 tests  ±0   1 408 ✔️ ±0   3m 58s ⏱️ +3s
   140 suites ±0        10 💤 ±0 
   140 files   ±0          0 ±0 

Results for commit 543f52a. ± Comparison against base commit bf41437.

♻️ This comment has been updated with latest results.

@manuelrojas manuelrojas requested a review from fmontes March 2, 2023 23:22
Comment on lines 201 to 231

const extensionUrls = data.extensions.map((extension) => extension.url);
const extensionUrls = data?.extensions.map((extension) => extension.url);
const customModules = await this.loadCustomBlocks(extensionUrls);
const blockNames = [];

data.extensions.forEach((extension) => {
blockNames.push(...extension.actions.map((item) => item.name));
blockNames.push(...(extension.actions?.map((item) => item.name) || []));
});

const moduleObj = customModules.reduce(
(prevModule, module) => ({ ...prevModule, ...module }),
{}
);
const moduleObj = customModules.reduce(this.parsedCustomModules, {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be more robust here... for example, if a user adds the customBlocks variable, and it doesn't have the right properties, this will break, example:

image

I think we can do better checking here before doing the maps and if we found something wrong, we can warn the users like:

Should have a experiment property array
experiment property should be an array of bla bla bla
actions should be an array of bla bla bla.

We can do some extra here to give the user more information on debugging.

Copy link
Contributor Author

@manuelrojas manuelrojas Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this detailed warning:

image

Also validate the schema using this library, example:

    import { assert, object, string, array, is } from "superstruct";

    /**
     * assert call throws a detailed error
     * @param data 
     * @returns if the schema is valid to use
     */
     private isValidSchema(data: RemoteCustomExtensions): void {
        const RemoteExtensionsSchema = object({
            extensions: array(
                object({
                    url: string(),
                    actions: optional(
                        array(
                            object({
                                command: string(),
                                menuLabel: string(),
                                icon: string()
                            })
                        )
                    )
                })
            )
        });

        assert(data, RemoteExtensionsSchema);
    }

Size information for superstruct: https://bundlephobia.com/package/superstruct@1.0.3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.12 MB <- 3.05MB

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

Integration Tests [postgres] Report

   409 files  ±0     409 suites  ±0   1h 9m 35s ⏱️ +34s
3 902 tests +2  3 878 ✔️ +2  23 💤 ±0  1 ±0 
3 923 runs  +2  3 899 ✔️ +2  23 💤 ±0  1 ±0 

For more details on these failures, see this check.

Results for commit bf3b5f4. ± Comparison against base commit 9ddae51.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

Integration Tests [mssql] Report

   408 files  +   408     408 suites  +408   3h 3m 37s ⏱️ + 3h 3m 37s
3 897 tests +3 897  3 861 ✔️ +3 861  23 💤 +23  13 +13 
3 918 runs  +3 918  3 882 ✔️ +3 882  23 💤 +23  13 +13 

For more details on these failures, see this check.

Results for commit c03e402. ± Comparison against base commit 9ddae51.

♻️ This comment has been updated with latest results.

@manuelrojas manuelrojas requested a review from fmontes March 3, 2023 19:57
* @param data
* @throws if the schema is not valid to use
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this extra line breaks the typedoc script.

@@ -31,6 +31,7 @@ export function DotBubbleMenuExtension(viewContainerRef: ViewContainerRef) {
const changeToElement = changeToComponent.location.nativeElement;

return BubbleMenu.extend<BubbleMenuOptions>({
name: 'bubbleMenu',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjvelazco turns out if you don't add name to a extension tiptap add "extension" as default and when you have more than one it shows a "duplicated extension" warn in the console.

@@ -133,7 +138,7 @@ export class DotBlockEditorComponent implements OnInit, OnDestroy {
) {}

async loadCustomBlocks(urls: string[]) {
return Promise.all(urls.map(async (url) => import(/* webpackIgnore: true */ url)));
return Promise.allSettled(urls.map(async (url) => import(/* webpackIgnore: true */ url)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please type this, because right nos TSC is guessing: PromiseSettledResult<any>[]

@@ -112,6 +112,7 @@
"react-dom": "^18.2.0",
"regenerator-runtime": "^0.13.9",
"rxjs": "~6.6.3",
"superstruct": "^1.0.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check the final file size after adding this? nothing to worry about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size information for superstruct: https://bundlephobia.com/package/superstruct@1.0.3

It was 3.05MB -> 3.12 MB

@manuelrojas manuelrojas requested a review from fmontes March 6, 2023 18:53
@dotcms-sonarqube
Copy link

SonarQube Quality Gate

Quality Gate failed

Failed condition 0.0% 0.0% Coverage on New Code (is less than 80%)

See analysis details on SonarQube

@dotcms-sonarqube
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@fmontes fmontes merged commit cc4edb8 into release-23.03 Mar 6, 2023
@fmontes fmontes deleted the issue-24032-block-editor-allow-users-to-add-options-to-the-suggestion-menu-fix branch March 6, 2023 21:03
fmontes added a commit that referenced this pull request Mar 9, 2023
* Update release version for dotcms-ui and dotcms-webcomponents

* Modify dotcmsReleaseVersion to 23.03, coreWebReleaseVersion, webComponentsReleaseVersion to rc and dot-cicd branch version to release-23.03

* Update branch in git submodule to release-23.03

* Excluding from triggering test at folder: dotCMS/src/main/webapp/html

* #23977 Block editor freeze scroll on tippy menus show (#24180)

* dev: freeze scroll on show forms #23977

* clean up

* refactor

* clean up v2

* feedback

* clean up

* #24172 Refresh Page portlet's data when site changed (#24175)

* #24031 fix block editor not saving (#24222)

* Fix #24032 Bring it to 22.03 (#24229)

* Fix #24032 Bring it to 22.03

* Build de lib

---------

Co-authored-by: Manuel Rojas <manuel.rojas.21@gmail.com>

* #24240 Fix data-access tests in 23.03 (#24244)

* #24240 fix test cases

* #24240 fix lint

* fire release docker image generation

* #24221 fix Snapshots should be displayed when the language is changed (#24234)

* Fix #23449 show dotAssets in folder listing

* Bock Editor: Allow user to insert videos from local files#23863 (#24248)

* dev: remove fileSize limit and fit the video in the block editor #23863

* clean up

* Fix 24032: Adding for Internal QA (#24255)

* #24032 Adding Fix for Internal QA

* #24032 Adding PR Feedback

* #24032 Adding PR Feedback

* #24032 Adding PR Feedback

* #24032 Logging error

* dotCMS/core#issue-20432 adding const

* dotCMS/core#issue-20432 adding const

* #24032 validation schema

* Adding empty extensions

* Adding empty extensions

* Get all modules no actions required

* Adding optional validation for actions

* Adding optional validation for actions

* Adding id insted of name

* Adding Type for promise

* Adding dot-cms-block-editor

* Adding lock file

---------

Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* #22151 make the message better (#24041)

* #22151 make the message better

* #22151 hides token button if aws

* #24173 Create dialog for 'Create Page' button (#24215)

* #24173 Create dialog for 'Create Page' button

* #24173 Create dialog for 'Create Page' button - tests

* #24173 Create dialog for 'Create Page' button - feedback

* #24173 Create dialog for 'Create Page' button - more feedback

* #23901 fixes the git hash resolution (#23902)

* #23889 fixed content permission load issue (#24296)

* #24308 Can't search for contentlets in edit page palette (#24316)

* #24308 fixed contentlets search

* #24308 refactor test case

* #24308 refactor code

* Update package-lock

* Fix versioning

* Fix versioning and FE tests

* Build

* Add line

* Had to dedupe because some internal pck upgrade nx bin

---------

Co-authored-by: victoralfaro-dotcms <victor.alfaro@dotcms.com>
Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>
Co-authored-by: alfredo-dotcms <37185433+alfredo-dotcms@users.noreply.github.com>
Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>
Co-authored-by: Manuel Rojas <manuel.rojas.21@gmail.com>
Co-authored-by: zulqarnainvd <113915849+zulqarnainvd@users.noreply.github.com>
Co-authored-by: hassan-mustafa-baig <111717530+hassan-mustafa-baig@users.noreply.github.com>
Co-authored-by: Will Ezell <will@dotcms.com>
nollymar pushed a commit that referenced this pull request Mar 15, 2023
* Update release version for dotcms-ui and dotcms-webcomponents

* Modify dotcmsReleaseVersion to 23.03, coreWebReleaseVersion, webComponentsReleaseVersion to rc and dot-cicd branch version to release-23.03

* Update branch in git submodule to release-23.03

* Excluding from triggering test at folder: dotCMS/src/main/webapp/html

* #23977 Block editor freeze scroll on tippy menus show (#24180)

* dev: freeze scroll on show forms #23977

* clean up

* refactor

* clean up v2

* feedback

* clean up

* #24172 Refresh Page portlet's data when site changed (#24175)

* #24031 fix block editor not saving (#24222)

* Fix #24032 Bring it to 22.03 (#24229)

* Fix #24032 Bring it to 22.03

* Build de lib

---------

Co-authored-by: Manuel Rojas <manuel.rojas.21@gmail.com>

* #24240 Fix data-access tests in 23.03 (#24244)

* #24240 fix test cases

* #24240 fix lint

* fire release docker image generation

* #24221 fix Snapshots should be displayed when the language is changed (#24234)

* Fix #23449 show dotAssets in folder listing

* Bugs fixed:
- When I search by URL I need to type exactly the full url to get a match
- If I edit a page using right click and save it, the new changes aren't always displayed in the table and the context menu doesn't list the options correctly

* Bock Editor: Allow user to insert videos from local files#23863 (#24248)

* dev: remove fileSize limit and fit the video in the block editor #23863

* clean up

* Fix 24032: Adding for Internal QA (#24255)

* #24032 Adding Fix for Internal QA

* #24032 Adding PR Feedback

* #24032 Adding PR Feedback

* #24032 Adding PR Feedback

* #24032 Logging error

* dotCMS/core#issue-20432 adding const

* dotCMS/core#issue-20432 adding const

* #24032 validation schema

* Adding empty extensions

* Adding empty extensions

* Get all modules no actions required

* Adding optional validation for actions

* Adding optional validation for actions

* Adding id insted of name

* Adding Type for promise

* Adding dot-cms-block-editor

* Adding lock file

---------

Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* #22151 make the message better (#24041)

* #22151 make the message better

* #22151 hides token button if aws

* #24173 Create dialog for 'Create Page' button (#24215)

* #24173 Create dialog for 'Create Page' button

* #24173 Create dialog for 'Create Page' button - tests

* #24173 Create dialog for 'Create Page' button - feedback

* #24173 Create dialog for 'Create Page' button - more feedback

* #23792 feedback

* #23792 More Feedback

* #23792 More Feedback - unit tests

* #23792 More Feedback v2

---------

Co-authored-by: victoralfaro-dotcms <victor.alfaro@dotcms.com>
Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>
Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>
Co-authored-by: Manuel Rojas <manuel.rojas.21@gmail.com>
Co-authored-by: zulqarnainvd <113915849+zulqarnainvd@users.noreply.github.com>
Co-authored-by: hassan-mustafa-baig <111717530+hassan-mustafa-baig@users.noreply.github.com>
Co-authored-by: Will Ezell <will@dotcms.com>
fmontes added a commit that referenced this pull request Mar 28, 2023
* Update release version for dotcms-ui and dotcms-webcomponents

* Modify dotcmsReleaseVersion to 23.03, coreWebReleaseVersion, webComponentsReleaseVersion to rc and dot-cicd branch version to release-23.03

* Update branch in git submodule to release-23.03

* Excluding from triggering test at folder: dotCMS/src/main/webapp/html

* #23977 Block editor freeze scroll on tippy menus show (#24180)

* dev: freeze scroll on show forms #23977

* clean up

* refactor

* clean up v2

* feedback

* clean up

* #24172 Refresh Page portlet's data when site changed (#24175)

* #24031 fix block editor not saving (#24222)

* Fix #24032 Bring it to 22.03 (#24229)

* Fix #24032 Bring it to 22.03

* Build de lib

---------

Co-authored-by: Manuel Rojas <manuel.rojas.21@gmail.com>

* #24240 Fix data-access tests in 23.03 (#24244)

* #24240 fix test cases

* #24240 fix lint

* fire release docker image generation

* #24221 fix Snapshots should be displayed when the language is changed (#24234)

* Fix #23449 show dotAssets in folder listing

* Bock Editor: Allow user to insert videos from local files#23863 (#24248)

* dev: remove fileSize limit and fit the video in the block editor #23863

* clean up

* Fix 24032: Adding for Internal QA (#24255)

* #24032 Adding Fix for Internal QA

* #24032 Adding PR Feedback

* #24032 Adding PR Feedback

* #24032 Adding PR Feedback

* #24032 Logging error

* dotCMS/core#issue-20432 adding const

* dotCMS/core#issue-20432 adding const

* #24032 validation schema

* Adding empty extensions

* Adding empty extensions

* Get all modules no actions required

* Adding optional validation for actions

* Adding optional validation for actions

* Adding id insted of name

* Adding Type for promise

* Adding dot-cms-block-editor

* Adding lock file

---------

Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* #22151 make the message better (#24041)

* #22151 make the message better

* #22151 hides token button if aws

* #24173 Create dialog for 'Create Page' button (#24215)

* #24173 Create dialog for 'Create Page' button

* #24173 Create dialog for 'Create Page' button - tests

* #24173 Create dialog for 'Create Page' button - feedback

* #24173 Create dialog for 'Create Page' button - more feedback

* #23901 fixes the git hash resolution (#23902)

* #23889 fixed content permission load issue (#24296)

* #24308 Can't search for contentlets in edit page palette (#24316)

* #24308 fixed contentlets search

* #24308 refactor test case

* #24308 refactor code

* #24243 fixed squash between hint icon  and label (#24298)

* dev: update block editor (#24323)

* [Issue-23863]: Fix #23863 Max Dimensions for Videos and Images (#24338)

* #23863 adding fix for max dimensions

* Adding editor

* Fix label

---------

Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* mockPrintWriter (#24352)

* #24263 prevent empty save block editor field (#24342)

* Fix #24230 Block editor markdown content with javascript code is breaking the app (#24359)

* #24230

* #24230  clean up

* #24230 moving logic to the JSP

* [Issue 24370] block editor crashing with allowed blocks (#24375)

* #24370  Fixing undefined this

* #24370  Fixing undefined this

* Fix #23863 block editor allow user to insert videos from local files fix size (#24374)

* dev: prevent close form while uploading asset #23863

* fix: large videos preview

* clean up

* update block editor

* feedback

* dev: update dotcms-block-editor.js file

* Block Editor: Allow users to insert videos from external sources#23861 (#24409)

* dev: validate video url

* dev: add video validation #23861

* clean up

* fix merge conflicts

* update dotcms-block-editor.js

* dev: add support link to unknown errors

* Update core-web/libs/block-editor/src/lib/extensions/asset-form/components/dot-external-asset/utils/index.ts

* Update core-web/libs/block-editor/src/lib/extensions/asset-form/components/dot-external-asset/utils/index.ts

* update dotcms-block-editor.js

---------

Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* Fix #24361 block editor code block should not show suggestions or placeholder (#24403)

* #24361 Blocking suggestions and placeholder

* #24361 Blocking suggestions and placeholder

* #24361 Blocking suggestions and placeholder

* #24361 Blocking suggestions and placeholder

* build file

---------

Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* #24422 fixes render

* Update LTS check

* Fix #23863 let user cancel upload (#24417)

* dev: let user cancel upload #23863

* update dotcms-block-editor.js

* clean up

* feedback

* update dotcms-block-editor.js

* dev: upload automatically after selecting the video

* Fix #24263: get the correct input element for block editor (#24429)

* Fix #23449 Filter does not work on the image selector for image fields 

* Moved code to a new branch

* Fix for the DB query

* Fixed failing ITs also addressed the PR feedback

* Added javadoc

* Fixed the failing test

* Fixed some ITs

* Fix postman tests

* Fixed postman tests

* Addressed PR feedback

* Making sonar happy

* Adding more code changes.

* Removed unnecessary file

* Fixed luceneQuery to fix failing ITs

* Adding `showOnMenu` term to lucene query.

* Updating reindex policy in Integration Test to wait for the ES reindex to be done when saving the test files.

* Adding temporary logging to the Integration Test

* Force indexation.

* Print more info.

* Removing `SYSTEM_HOST` from DB query.

* Fixing Integration Test.

---------

Co-authored-by: Jose Castro <jose.castro@dotcms.com>

* Fix #24299 now the get dependencies do not throw an exception when the story block value is not a json (#24439)

* Bock Editor: Allow user to insert videos from local files #23863 (#24451)

* dev: support video file and dotAsset #23863

* update dotcms-block-editor.js file

* dev: update label to Library and dotcms-block-editor.js file

* Block editor value [Object, object] fix (#24474)

* Updating branch references

* dev: rename video node (#24477)

* dev: restore data mock time (#24478)

* Fix conflict

* Fix lock

* Point to master

* Fix lock

* Fixing merging conflict.

---------

Co-authored-by: victoralfaro-dotcms <victor.alfaro@dotcms.com>
Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>
Co-authored-by: alfredo-dotcms <37185433+alfredo-dotcms@users.noreply.github.com>
Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>
Co-authored-by: Manuel Rojas <manuel.rojas.21@gmail.com>
Co-authored-by: zulqarnainvd <113915849+zulqarnainvd@users.noreply.github.com>
Co-authored-by: hassan-mustafa-baig <111717530+hassan-mustafa-baig@users.noreply.github.com>
Co-authored-by: Will Ezell <will@dotcms.com>
Co-authored-by: erickgonzalez <erick.gonzalez@dotcms.com>
Co-authored-by: Jonathan <jonathan.sanchez@dotcms.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block Editor: Allow users to add options to the suggestion menu
2 participants