Skip to content

Commit

Permalink
Merge branch 'master' into issue-28658-add-empty-category-field
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra authored Jun 4, 2024
2 parents d04e798 + 59540fa commit fa8b9e4
Show file tree
Hide file tree
Showing 116 changed files with 5,039 additions and 1,836 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cli-release-process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
description: 'Release version'
default: '1.0.0-SNAPSHOT'
required: false
notify_slack:
description: 'Notify Slack'
default: 'true'
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
Expand Down Expand Up @@ -459,6 +463,19 @@ jobs:
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > ~/.npmrc
npm publish --access public --tag ${NPM_PACKAGE_VERSION_TAG}
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.RELEASE_SLACK_WEBHOOK }}
SLACK_TITLE: "Important news!"
SLACK_MESSAGE: "<!channel> This automated script is excited to announce the release of a new version of *dotCLI* `${{ needs.precheck.outputs.RELEASE_VERSION }}` :package: is available on the `NPM` registry!"
SLACK_USERNAME: dotBot
SLACK_MSG_AUTHOR: " "
MSG_MINIMAL: true
SLACK_FOOTER: ""
SLACK_ICON: https://avatars.slack-edge.com/temp/2021-12-08/2830145934625_e4e464d502865ff576e4.png
if: success() && github.event.inputs.notify_slack == 'true'

clean-up:
name: "Clean Up"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable, Subject } from 'rxjs';

import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { FormControl, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Params } from '@angular/router';

import { SelectItem } from 'primeng/api';
Expand Down Expand Up @@ -116,11 +116,15 @@ export class DotLoginComponent implements OnInit, OnDestroy {
this.setInitialMessage(loginInfo);
}

private isEmail(potentialEmail: string): boolean {
return !!new FormControl(potentialEmail, Validators.email).errors?.email;
}

private setInitialMessage(loginInfo: DotLoginInformation): void {
this.route.queryParams.pipe(take(1)).subscribe((params: Params) => {
if (params['changedPassword']) {
this.setMessage(loginInfo.i18nMessagesMap['reset-password-success']);
} else if (params['resetEmailSent']) {
} else if (params['resetEmailSent'] && !this.isEmail(params['resetEmail'])) {
this.setMessage(
loginInfo.i18nMessagesMap['a-new-password-has-been-sent-to-x'].replace(
'{0}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class DotCardContentlet {
<dot-card>
<dot-contentlet-thumbnail
showVideoThumbnail={this.showVideoThumbnail}
backgroundImage={true}
contentlet={contentlet}
width={this.thumbnailSize}
height={this.thumbnailSize}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect } from '@jest/globals';
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
import { of } from 'rxjs';
import { of, throwError } from 'rxjs';

import { MessageService } from 'primeng/api';

Expand Down Expand Up @@ -68,6 +68,7 @@ describe('EditEmaStore', () => {
describe('EditEmaStore Headless', () => {
let spectator: SpectatorService<EditEmaStore>;
let dotPageApiService: SpyObject<DotPageApiService>;
let dotExperimentsService: DotExperimentsService;

const createService = createServiceFactory({
service: EditEmaStore,
Expand Down Expand Up @@ -127,6 +128,7 @@ describe('EditEmaStore', () => {
spectator = createService();

dotPageApiService = spectator.inject(DotPageApiService);
dotExperimentsService = spectator.inject(DotExperimentsService);
jest.spyOn(dotPageApiService, 'get').mockImplementation(({ url }) => {
return of({
...MOCK_RESPONSE_HEADLESS,
Expand Down Expand Up @@ -229,6 +231,7 @@ describe('EditEmaStore', () => {
editor: MOCK_RESPONSE_HEADLESS,
currentExperiment: null,
apiURL: 'http://localhost/api/v1/page/json/test-url?language_id=1&com.dotmarketing.persona.id=modes.persona.no.persona&variantName=DEFAULT&mode=EDIT_MODE',
pureURL: 'http://localhost:3000/test-url',
iframeURL:
'http://localhost:3000/test-url?language_id=1&com.dotmarketing.persona.id=modes.persona.no.persona&variantName=DEFAULT&mode=EDIT_MODE',
isEnterpriseLicense: true,
Expand Down Expand Up @@ -671,6 +674,51 @@ describe('EditEmaStore', () => {
});
});

it('should handle successful data loading even if experiments throw an error', (done) => {
jest.spyOn(dotExperimentsService, 'getById').mockReturnValue(throwError(null));

spectator.service.load({
clientHost: 'http://localhost:3000',
language_id: '1',
url: 'test-url',
'com.dotmarketing.persona.id': '123',
experimentId: 'i-have-a-draft-experiment',
variantName: ''
});

spectator.service.editorState$.subscribe((state) => {
expect(state).toEqual({
bounds: [],
contentletArea: null,
clientHost: 'http://localhost:3000',
editor: MOCK_RESPONSE_HEADLESS,
currentExperiment: null,
apiURL: 'http://localhost/api/v1/page/json/test-url?language_id=1&com.dotmarketing.persona.id=modes.persona.no.persona&variantName=&mode=EDIT_MODE',
iframeURL:
'http://localhost:3000/test-url?language_id=1&com.dotmarketing.persona.id=modes.persona.no.persona&variantName=&mode=EDIT_MODE',
isEnterpriseLicense: true,
favoritePageURL: '/test-url?host_id=123-xyz-567-xxl&language_id=1',
state: EDITOR_STATE.IDLE,
editorData: {
mode: EDITOR_MODE.EDIT,
canEditPage: true,
canEditVariant: true,
variantId: '',
page: {
canLock: true,
isLocked: false,
lockedByUser: ''
}
},
dragItem: undefined,
showContentletTools: false,
showDropzone: false,
showPalette: true
});
done();
});
});

it("should call save method from dotPageApiService when 'save' action is dispatched", () => {
const dotPageApiService = spectator.inject(DotPageApiService);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -980,6 +1028,7 @@ describe('EditEmaStore', () => {
done();
});
});

it('should update inline edited contentlet for variants', (done) => {
const payload: SaveInlineEditing = {
contentlet: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { EMPTY, Observable, forkJoin } from 'rxjs';
import { EMPTY, Observable, forkJoin, of } from 'rxjs';

import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
Expand All @@ -19,6 +19,7 @@ import {
DEFAULT_VARIANT_ID,
DotContainerMap,
DotDevice,
DotExperiment,
DotExperimentStatus,
DotLayout,
DotPageContainerStructure
Expand Down Expand Up @@ -156,6 +157,12 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
(state) => '/' + sanitizeURL(state.editor.page.pageURI)
);
private readonly error$ = this.select((state) => state.error);
private readonly pureURL$ = this.select(
this.clientHost$,
this.currentUrl$,
(clientHost, pageURI) => `${clientHost || window.location.origin}${pageURI}`
);

/**
* Before this was layoutProperties, but are separate to "temp" selector.
* And then is merged with templateIdentifier in layoutProperties$.
Expand Down Expand Up @@ -299,7 +306,8 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
readonly editorToolbarData$ = this.select(
this.editorState$,
this.previewURL$,
(editorState, previewURL) => ({
this.pureURL$,
(editorState, previewURL, pureURL) => ({
...editorState,
showWorkflowActions:
editorState.editorData.mode === EDITOR_MODE.EDIT ||
Expand All @@ -308,7 +316,8 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
!editorState.editorData.canEditPage ||
(editorState.editorData.mode !== EDITOR_MODE.EDIT &&
editorState.editorData.mode !== EDITOR_MODE.INLINE_EDITING),
previewURL
previewURL,
pureURL
})
);

Expand Down Expand Up @@ -377,7 +386,7 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
}
}),
switchMap(({ pageData, licenseData, currentUser }) =>
this.dotExperimentsService.getById(params.experimentId ?? '').pipe(
this.getExperiment(params.experimentId).pipe(
tap({
next: (experiment) => {
// Can be blocked by an experiment if there is a running experiment or a scheduled one
Expand Down Expand Up @@ -425,12 +434,6 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
},
shouldReload: true
});
},
error: ({ status }: HttpErrorResponse) => {
this.createEmptyState(
{ canEdit: false, canRead: false },
status
);
}
})
)
Expand Down Expand Up @@ -923,6 +926,22 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
});
}

/**
* Get the experiment data
*
* @private
* @param {string} [experimentId='']
* @return {*}
* @memberof EditEmaStore
*/
private getExperiment(experimentId = ''): Observable<DotExperiment | null> {
return this.dotExperimentsService.getById(experimentId).pipe(
// If there is an error, we return null
// This is to avoid blocking the page if there is an error with the experiment
catchError(() => of(null))
);
}

/**
* Get the containers data
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<dot-ema-bookmarks [url]="es.favoritePageURL" />
<p-button
[cdkCopyToClipboard]="es.iframeURL"
[cdkCopyToClipboard]="es.pureURL"
[label]="'editpage.header.copy' | dm"
(cdkCopyToClipboardCopied)="triggerCopyToast()"
icon="pi pi-copy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('EditEmaToolbarComponent', () => {
iframeURL: 'http://localhost:8080/index',
clientHost: 'http://localhost:3000',
apiURL: 'http://localhost/api/v1/page/json/page-one',
pureURL: 'http://localhost:8080/index',
editorData: {
mode: EDITOR_MODE.EDIT,
canEditPage: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
:host {
display: grid;
grid-template-rows: min-content 1fr;
grid-template-columns: 1fr 15.5rem;
height: 100%;

// Only set two columns if the palette is present
&:has(dot-edit-ema-palette) {
grid-template-columns: 1fr 15.5rem;
}
}

dot-device-selector-seo {
Expand Down
25 changes: 25 additions & 0 deletions core-web/libs/sdk/angular/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../../.eslintrc.base.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
Loading

0 comments on commit fa8b9e4

Please sign in to comment.