Skip to content

Commit

Permalink
Merge branch 'issue-28563-removing-template-ajax-and-js-deps' of gith…
Browse files Browse the repository at this point in the history
…ub.com:dotCMS/core into issue-28563-removing-template-ajax-and-js-deps
  • Loading branch information
jdotcms committed May 28, 2024
2 parents 0a0bbb3 + 1d94119 commit 93b000e
Show file tree
Hide file tree
Showing 67 changed files with 4,062 additions and 2,060 deletions.
2 changes: 1 addition & 1 deletion .github/data/slack-mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
},
{
"github_user": "jgambarios",
"slack_id": "D04SH7PU16Z"
"slack_id": "U028X13T2"
},
{
"github_user": "fishsmith",
Expand Down
32 changes: 19 additions & 13 deletions .github/workflows/pr-notifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
if: always()
env:
SOURCE_REPOSITORY: ${{ github.repository }}
continue-on-error: true
steps:
- name: Resolve User
id: resolve-user
Expand All @@ -55,22 +56,22 @@ jobs:
githack_core_repo_url=https://${githack_host}/${{ env.SOURCE_REPOSITORY }}
branch=/${{ github.head_ref }}
[[ "${branch}" == '/master' ]] && branch=
slack_mappings_file=.github/data/slack-mappings.json
slack_mapping_url=${githack_core_repo_url}${branch}/${slack_mappings_file}
slack_mappings_file=slack-mappings.json
slack_mappings_path=.github/data/${slack_mappings_file}
slack_mapping_url=${githack_core_repo_url}${branch}/${slack_mappings_path}
if [[ -n "${github_user}" ]]; then
if [[ -f ${slack_mappings_file} ]]; then
json=$(curl -s ${slack_mapping_url})
channel_id=$( \
jq '.[] | select(.github_user == "${github_user}")' <<< "${json}" | \
jq -r '.slack_id' \
)
fi
json=$(curl -s ${slack_mapping_url})
channel_id=$( \
jq ".[] | select(.github_user == \"${github_user}\")" <<< "${json}" | \
jq -r '.slack_id' \
)
echo "Resolved channel id [${channel_id}] from [${slack_mappings_file}]"
if [[ -z "${channel_id}" ]]; then
echo "Channel id could not be resolved from [${slack_mappings_file}]. Attempting to resolve from Github user email."
user_email=$( \
curl \
-u ${{ secrets.CI_MACHINE_USER }}:${{ secrets.CI_MACHINE_TOKEN }} \
Expand All @@ -81,6 +82,7 @@ jobs:
sed "s/\"email\"://g" | \
tr -d '",[:space:]' \
)
echo "Resolved user email: [${user_email}]"
if [[ -n "${user_email}" ]]; then
channel_id=$( \
Expand All @@ -95,11 +97,15 @@ jobs:
sed "s/\"id\"://g" | \
tr -d '",[:space:]' \
)
echo "Resolved channel id [${channel_id}] from email [${user_email}]"
fi
fi
fi
[[ -z "${channel_id}" ]] && channel_id=${{ env.DEFAULT_CHANNEL_ID }}
[[ -z "${channel_id}" ]] \
&& echo "Channel id could not be resolved, defaulting to eng's [${{ env.DEFAULT_CHANNEL_ID }}]" \
&& channel_id=${{ env.DEFAULT_CHANNEL_ID }}
echo "channel_id=${channel_id}" >> $GITHUB_OUTPUT
echo "channel_id=${channel_id}"
Expand Down
8 changes: 5 additions & 3 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>13.0</version>
<version>17.5</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -738,14 +738,16 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>1.0.1</version>
<version>17.1</version>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-java-servlet</artifactId>
<version>9.1.0</version>
<version>13.0.1</version>
</dependency>



<!--
*****************************
Database Support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ export class DotBubbleMenuPluginView extends BubbleMenuView {
/* Run commands */
exeCommand(item: BubbleMenuItem) {
const { markAction: action, active } = item;
const { inode, languageId } = this.selectionNode.attrs.data;

const currentInode = this.getQueryParam('inode');

switch (action) {
case 'bold':
this.editor.commands.toggleBold?.();
Expand Down Expand Up @@ -413,6 +417,26 @@ export class DotBubbleMenuPluginView extends BubbleMenuView {
case 'subscript':
this.editor.commands?.toggleSubscript?.();
break;

case 'goToContentlet':
this.goToContentlet(inode, currentInode, languageId);

break;
}
}

/**
* Navigates to a contentlet by calling a legacy JSP function.
*
* @param {string} newInode - The new contentlet inode to navigate to.
* @param {string} siblingInode - The sibling contentlet inode.
* @param {number} languageId - The language ID of the contentlet.
*/
goToContentlet(newInode: string, siblingInode: string, languageId: number) {
// TODO: Remove JSPRedirectFn when Edit Content JSP is removed.
const JSPRedirectFn = (window as any).rel_BlogblogComment_PeditRelatedContent;
if (JSPRedirectFn) {
JSPRedirectFn(newInode, '', languageId);
}
}

Expand Down Expand Up @@ -547,4 +571,18 @@ export class DotBubbleMenuPluginView extends BubbleMenuView {

this.tippyChangeTo?.hide();
}

/**
* Retrieves the value of the specified query parameter from the URL.
*
* @param {string} param - The name of the query parameter to retrieve.
* @private
*
* @returns {?string} - The value of the query parameter, or null if the parameter does not exist.
*/
private getQueryParam(param: string) {
const urlParams = new URLSearchParams(window.location.search);

return urlParams.get(param);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ export const isListNode = (editor): boolean => {
return editor.isActive('bulletList') || editor.isActive('orderedList');
};

// TODO: Remove JSPRedirectFn when Edit Content JSP is removed.
/**
* JSPRedirectFn
*
* A variable that represents the function to redirect to go to a related content page.
*
* @global
*/
const JSPRedirectFn = (window as any).rel_BlogblogComment_PeditRelatedContent;

const textMarks: Array<BubbleMenuItem> = [
{
icon: 'format_bold',
Expand Down Expand Up @@ -275,6 +285,19 @@ export const getBubbleMenuItem = (nodeType = ''): Array<BubbleMenuItem> => {
return imageOptions;

case 'dotContent':
// TODO: Remove JSPRedirectFn when Edit Content JSP is removed.

if (JSPRedirectFn) {
return [
...dotContentOptions,
{
icon: 'edit',
markAction: 'goToContentlet',
active: false
}
];
}

return dotContentOptions;

case 'table':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ describe('EditEmaStore', () => {
});
});

it('should update inline edited contentlet', () => {
it('should update inline edited contentlet for regular pages', (done) => {
const payload: SaveInlineEditing = {
contentlet: {
body: '',
Expand All @@ -939,7 +939,7 @@ describe('EditEmaStore', () => {
};
const dotPageApiService = spectator.inject(DotPageApiService);
jest.spyOn(dotPageApiService, 'saveContentlet').mockReturnValue(of({}));
jest.spyOn(dotPageApiService, 'get');
jest.spyOn(dotPageApiService, 'get').mockReturnValue(of(MOCK_RESPONSE_HEADLESS));

spectator.service.load({
clientHost: 'http://localhost:3000',
Expand All @@ -953,6 +953,97 @@ describe('EditEmaStore', () => {
contentlet: payload.contentlet
});
expect(dotPageApiService.get).toHaveBeenCalledWith(payload.params);

spectator.service.state$.subscribe((state) => {
expect(state).toEqual({
bounds: [],
contentletArea: null,
clientHost: 'http://localhost:3000',
editor: MOCK_RESPONSE_HEADLESS,
isEnterpriseLicense: true,
currentExperiment: null,
editorState: EDITOR_STATE.IDLE,
editorData: {
mode: EDITOR_MODE.EDIT,
canEditPage: true,
canEditVariant: true,
page: {
canLock: true,
isLocked: false,
lockedByUser: ''
},
variantId: undefined
},
shouldReload: true
});

done();
});
});
it('should update inline edited contentlet for variants', (done) => {
const payload: SaveInlineEditing = {
contentlet: {
body: '',
inode: '123'
},
params: {
url: 'test',
language_id: '1',
'com.dotmarketing.persona.id': '123'
}
};

const mockWithVariant = {
...MOCK_RESPONSE_HEADLESS,
viewAs: {
...MOCK_RESPONSE_HEADLESS.viewAs,
variantId: '123'
}
};

const dotPageApiService = spectator.inject(DotPageApiService);
jest.spyOn(dotPageApiService, 'saveContentlet').mockReturnValue(of({}));
jest.spyOn(dotPageApiService, 'get').mockReturnValue(of(mockWithVariant));

spectator.service.load({
clientHost: 'http://localhost:3000',
language_id: '1',
url: 'test-url',
'com.dotmarketing.persona.id': '123',
variantName: '123'
});
spectator.service.saveFromInlineEditedContentlet(payload);

expect(dotPageApiService.saveContentlet).toHaveBeenCalledWith({
contentlet: payload.contentlet
});
expect(dotPageApiService.get).toHaveBeenCalledWith(payload.params);

spectator.service.state$.subscribe((state) => {
expect(state).toEqual({
bounds: [],
contentletArea: null,
clientHost: 'http://localhost:3000',
editor: mockWithVariant,
isEnterpriseLicense: true,
currentExperiment: null,
editorState: EDITOR_STATE.IDLE,
editorData: {
mode: EDITOR_MODE.EDIT_VARIANT,
canEditPage: true,
canEditVariant: true,
page: {
canLock: true,
isLocked: false,
lockedByUser: ''
},
variantId: '123'
},
shouldReload: true
});

done();
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '@dotcms/data-access';
import { LoginService } from '@dotcms/dotcms-js';
import {
DEFAULT_VARIANT_ID,
DotContainerMap,
DotDevice,
DotExperimentStatus,
Expand Down Expand Up @@ -543,7 +544,10 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
editorState: EDITOR_STATE.IDLE,
editorData: {
...state.editorData,
mode: EDITOR_MODE.EDIT
mode:
pageData.viewAs.variantId === DEFAULT_VARIANT_ID
? EDITOR_MODE.EDIT
: EDITOR_MODE.EDIT_VARIANT
},
shouldReload: true
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3066,6 +3066,30 @@ describe('EditEmaEditorComponent', () => {
'saveFromInlineEditedContentlet'
);
const setEditorModeSpy = jest.spyOn(store, 'setEditorMode');

spectator.setRouteQueryParam('variantName', DEFAULT_VARIANT_ID);
window.dispatchEvent(
new MessageEvent('message', {
origin: HOST,
data: {
action: CUSTOMER_ACTIONS.UPDATE_CONTENTLET_INLINE_EDITING,
payload: null
}
})
);

expect(saveFromInlineEditedContentletSpy).not.toHaveBeenCalled();
expect(setEditorModeSpy).toHaveBeenCalledWith(EDITOR_MODE.EDIT);
});

it('should dont trigger save from inline edited contentlet when dont have changes and does not have variantName', () => {
const saveFromInlineEditedContentletSpy = jest.spyOn(
store,
'saveFromInlineEditedContentlet'
);
const setEditorModeSpy = jest.spyOn(store, 'setEditorMode');

spectator.setRouteQueryParam('variantName', undefined);
window.dispatchEvent(
new MessageEvent('message', {
origin: HOST,
Expand All @@ -3080,6 +3104,29 @@ describe('EditEmaEditorComponent', () => {
expect(setEditorModeSpy).toHaveBeenCalledWith(EDITOR_MODE.EDIT);
});

it('should dont trigger save from inline edited contentlet when dont have changes and its a variant', () => {
const saveFromInlineEditedContentletSpy = jest.spyOn(
store,
'saveFromInlineEditedContentlet'
);
const setEditorModeSpy = jest.spyOn(store, 'setEditorMode');

spectator.setRouteQueryParam('variantName', 'hello-there');

window.dispatchEvent(
new MessageEvent('message', {
origin: HOST,
data: {
action: CUSTOMER_ACTIONS.UPDATE_CONTENTLET_INLINE_EDITING,
payload: null
}
})
);

expect(saveFromInlineEditedContentletSpy).not.toHaveBeenCalled();
expect(setEditorModeSpy).toHaveBeenCalledWith(EDITOR_MODE.EDIT_VARIANT);
});

it('should trigger copy contentlet dialog when inline editing', () => {
const copyContentletSpy = jest.spyOn(dotCopyContentModalService, 'open');
window.dispatchEvent(
Expand Down
Loading

0 comments on commit 93b000e

Please sign in to comment.