Skip to content

Commit

Permalink
Merge branch 'main' into issue-30669-create-import-job-rest-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinogiardino authored Nov 20, 2024
2 parents ea4fa2e + 852d1c2 commit aeb5c8e
Show file tree
Hide file tree
Showing 44 changed files with 431 additions and 206 deletions.
35 changes: 13 additions & 22 deletions .github/workflows/cicd_manual_publish-starter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ on:
old-assets:
description: 'Include old assets'
required: true
type: boolean
type: boolean
changelog:
description: 'Changes description'
required: true
type: string
issue-number:
description: 'Related issue number. Required to create Empty Starter PR.'
required: true
type: string
dry-run:
description: 'Enable dry-run mode'
required: true
Expand Down Expand Up @@ -96,6 +100,7 @@ jobs:
outputs:
filename: ${{ steps.deploy-artifacts.outputs.filename }}
url: ${{ steps.deploy-artifacts.outputs.url }}
pr_created: ${{ steps.create-pull-request.outcome == 'success' }}
steps:
- uses: jfrog/setup-jfrog-cli@v4
env:
Expand Down Expand Up @@ -156,41 +161,27 @@ jobs:
echo "::notice::Changelog: ${{ github.event.inputs.changelog }}"
echo "::endgroup::"
update-pom:
if: ${{ github.event.inputs.type == 'empty' && github.event.inputs.dry-run == 'false' }}
needs: [ deploy-artifacts ]
runs-on: ubuntu-20.04
environment: starter
outputs:
pull-request-url: ${{ steps.create-pull-request.outputs.pull-request-url }}
steps:
- uses: actions/checkout@v4

- name: 'Update pom.xml'
if: ${{ github.event.inputs.type == 'empty' && github.event.inputs.dry-run == 'false' }}
id: update-pom
working-directory: ${{ github.workspace }}/parent
env:
FILENAME: ${{ needs.deploy-artifacts.outputs.filename }}
FILENAME: ${{ steps.deploy-artifacts.outputs.filename }}
run: |
echo "::group::Update pom.xml"
echo "Updating pom.xml"
VERSION="${FILENAME%.*}"
# Create an auxiliary branch for versioning updates
AUXILIARY_BRANCH=update-starter-version-${VERSION}-${{ github.run_id }}
AUXILIARY_BRANCH=${{ inputs.issue-number }}-update-starter-version-${VERSION}-${{ github.run_id }}
sed -i "s/<starter.deploy.version>.*<\/starter.deploy.version>/<starter.deploy.version>${VERSION}<\/starter.deploy.version>/" pom.xml
POM=$(cat pom.xml)
echo "POM file: ${POM}"
echo auxiliary-branch=${AUXILIARY_BRANCH} >> $GITHUB_OUTPUT
echo starter-version=${VERSION} >> $GITHUB_OUTPUT
echo "::notice::Auxiliary Branch: ${AUXILIARY_BRANCH}"
echo "::endgroup::"
echo "::endgroup::"
- name: 'Create Pull Request'
if: ${{ steps.update-pom.outcome == 'success' }}
id: create-pull-request
uses: peter-evans/create-pull-request@v6
with:
Expand All @@ -202,8 +193,8 @@ jobs:
This PR was created automatically to update the **starter.deploy.version** in pom.xml to [**${{ steps.update-pom.outputs.starter-version }}**].
labels: |
empty-starter
automated pr
automated pr
send-notification:
needs: [ deploy-artifacts ]
runs-on: ubuntu-20.04
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@let loading = $loading();
@let data = $data();
@let rowsPerPage = $rowsPerPage();

@let errorMessage = $errorMessage();
<p-table
#datatable
[value]="data"
Expand All @@ -17,7 +17,11 @@
<ng-template pTemplate="emptymessage">
<tr>
<td colspan="4">
{{ 'dot.file.field.dialog.select.existing.file.table.emptymessage' | dm }}
@if (errorMessage) {
{{ errorMessage | dm }}
} @else {
{{ 'dot.file.field.dialog.select.existing.file.table.emptymessage' | dm }}
}
</td>
</tr>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export class DotDataViewComponent {
* @required
*/
$data = input.required<DotCMSContentlet[]>({ alias: 'data' });

/**
* Error message to display in the table.
*
* @type {string}
*/
$errorMessage = input<string>('', { alias: 'error' });

/**
* A boolean observable that indicates the loading state.
* This is typically used to show or hide a loading indicator in the UI.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@let folders = store.folders();
@let content = store.content();

<div class="file-selector flex flex-column gap-3">
<div class="file-selector__main grid grid-nogutter flex-nowrap flex-grow-1 overflow-hidden">
<div class="file-selector__sidebar h-full">
<div class="file-selector__sidebar h-full overflow-auto">
<dot-sidebar
[folders]="folders.data"
[loading]="store.foldersIsLoading()"
Expand All @@ -11,8 +12,9 @@
</div>
<div class="col h-full">
<dot-dataview
[data]="store.content().data"
[data]="content.data"
[loading]="store.contentIsLoading()"
[error]="content.error"
(onRowSelect)="store.setSelectedContent($event)" />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { pipe } from 'rxjs';

import { computed, inject } from '@angular/core';

import { exhaustMap, switchMap, tap } from 'rxjs/operators';
import { exhaustMap, switchMap, tap, filter, map } from 'rxjs/operators';

import { ComponentStatus, DotCMSContentlet } from '@dotcms/dotcms-models';
import {
Expand Down Expand Up @@ -35,6 +35,7 @@ export interface SelectExisingFileState {
content: {
data: DotCMSContentlet[];
status: ComponentStatus;
error: string | null;
};
currentSite: TreeNodeItem | null;
selectedContent: DotCMSContentlet | null;
Expand All @@ -50,7 +51,8 @@ const initialState: SelectExisingFileState = {
},
content: {
data: [],
status: ComponentStatus.INIT
status: ComponentStatus.INIT,
error: null
},
currentSite: null,
selectedContent: null,
Expand Down Expand Up @@ -80,25 +82,41 @@ export const SelectExisingFileStore = signalStore(
content: { ...store.content(), status: ComponentStatus.LOADING }
})
),
switchMap((event) => {
const content = store.content();

let identifier = SYSTEM_HOST_ID;

if (event) {
identifier = event.node.data.identifier;
map((event) => (event ? event?.node?.data?.identifier : SYSTEM_HOST_ID)),
filter((identifier) => {
const hasIdentifier = !!identifier;

if (!hasIdentifier) {
patchState(store, {
content: {
data: [],
status: ComponentStatus.ERROR,
error: 'dot.file.field.dialog.select.existing.file.table.error.id'
}
});
}

return hasIdentifier;
}),
switchMap((identifier) => {
return dotEditContentService.getContentByFolder(identifier).pipe(
tapResponse({
next: (data) => {
patchState(store, {
content: { data, status: ComponentStatus.LOADED }
content: {
data,
status: ComponentStatus.LOADED,
error: null
}
});
},
error: () =>
patchState(store, {
content: { ...content, status: ComponentStatus.ERROR }
content: {
data: [],
status: ComponentStatus.ERROR,
error: 'dot.file.field.dialog.select.existing.file.table.error.content'
}
})
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,37 @@ describe('DotEmaShellComponent', () => {
expect(reloadSpy).toHaveBeenCalled();
expect(router.navigate).not.toHaveBeenCalled();
});

it('should trigger a navigate when url path property is changed', () => {
const navigate = jest.spyOn(router, 'navigate');

spectator.detectChanges();

spectator.triggerEventHandler(DotEmaDialogComponent, 'action', {
event: new CustomEvent('ng-event', {
detail: {
name: NG_CUSTOM_EVENTS.URL_IS_CHANGED,
payload: {
htmlPageReferer: '/a-new-url'
}
}
}),
actionPayload: PAYLOAD_MOCK,
form: {
status: FormStatus.SAVED,
isTranslation: false
},
clientAction: CLIENT_ACTIONS.NOOP
});
spectator.detectChanges();

expect(navigate).toHaveBeenCalledWith([], {
queryParams: {
url: '/a-new-url'
},
queryParamsHandling: 'merge'
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { SiteService } from '@dotcms/dotcms-js';
import { DotLanguage } from '@dotcms/dotcms-models';
import { DotPageToolsSeoComponent } from '@dotcms/portlets/dot-ema/ui';
import { DotInfoPageComponent, DotNotLicenseComponent, SafeUrlPipe } from '@dotcms/ui';
import { DotInfoPageComponent, DotNotLicenseComponent } from '@dotcms/ui';
import { isEqual } from '@dotcms/utils/lib/shared/lodash/functions';

import { EditEmaNavigationBarComponent } from './components/edit-ema-navigation-bar/edit-ema-navigation-bar.component';
Expand Down Expand Up @@ -72,7 +72,6 @@ import { compareUrlPaths } from '../utils';
RouterModule,
DotPageToolsSeoComponent,
DotEmaDialogComponent,
SafeUrlPipe,
DotInfoPageComponent,
DotNotLicenseComponent
]
Expand Down Expand Up @@ -166,6 +165,11 @@ export class DotEmaShellComponent implements OnInit, OnDestroy {
break;
}

case NG_CUSTOM_EVENTS.URL_IS_CHANGED: {
this.handleSavePageEvent(event);
break;
}

case NG_CUSTOM_EVENTS.SAVE_PAGE: {
this.handleSavePageEvent(event);
break;
Expand All @@ -180,12 +184,12 @@ export class DotEmaShellComponent implements OnInit, OnDestroy {
* @return {void}
*/
private handleSavePageEvent(event: CustomEvent): void {
const url = this.extractPageRefererUrl(event);
const targetUrl = this.getTargetUrl(url);
const htmlPageReferer = event.detail.payload?.htmlPageReferer;
const url = new URL(htmlPageReferer, window.location.origin); // Add base for relative URLs

if (this.shouldNavigate(targetUrl)) {
if (this.shouldNavigate(url.pathname)) {
// Navigate to the new URL if it's different from the current one
this.navigate({ url: targetUrl });
this.navigate({ url: url.pathname });

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ describe('EditEmaLayoutComponent', () => {
expect(dotRouter.allowRouteDeactivation).toHaveBeenCalled();
}));

it('should set isClientReady false after saving', fakeAsync(() => {
templateBuilder.templateChange.emit();
tick(6000);

expect(store.isClientReady()).toBe(false);
}));

it('should save right away if we request page leave before the 5 secs', () => {
const saveTemplate = jest.spyOn(component, 'saveTemplate');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class EditEmaLayoutComponent implements OnInit, OnDestroy {
summary: 'Success',
detail: this.dotMessageService.get('dot.common.message.saved')
});
this.uveStore.reload();
this.uveStore.reload({ isClientReady: false });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export enum NG_CUSTOM_EVENTS {
CANCEL_SAVING_MENU_ORDER = 'cancel-save-menu-order',
OPEN_WIZARD = 'workflow-wizard',
DIALOG_CLOSED = 'dialog-closed',
EDIT_CONTENTLET_UPDATED = 'edit-contentlet-data-updated'
EDIT_CONTENTLET_UPDATED = 'edit-contentlet-data-updated',
URL_IS_CHANGED = 'url-is-changed'
}

// Status of the whole UVE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const initialState: UVEState = {
status: UVE_STATUS.LOADING,
isTraditionalPage: true,
canEditPage: false,
pageIsLocked: true
pageIsLocked: true,
isClientReady: false
};

export const UVEStore = signalStore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const initialState: UVEState = {
status: UVE_STATUS.LOADING,
isTraditionalPage: true,
canEditPage: false,
pageIsLocked: true
pageIsLocked: true,
isClientReady: false
};

export const uveStoreMock = signalStore(withState<UVEState>(initialState), withClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const initialState: UVEState = {
status: UVE_STATUS.LOADED,
isTraditionalPage: false,
canEditPage: true,
pageIsLocked: true
pageIsLocked: true,
isClientReady: false
};

export const uveStoreMock = signalStore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const initialState: UVEState = {
status: UVE_STATUS.LOADING,
isTraditionalPage: true,
canEditPage: false,
pageIsLocked: true
pageIsLocked: true,
isClientReady: false
};

export const uveStoreMock = signalStore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const initialState: UVEState = {
status: UVE_STATUS.LOADING,
isTraditionalPage: true,
canEditPage: false,
pageIsLocked: true
pageIsLocked: true,
isClientReady: false
};

export const uveStoreMock = signalStore(withState<UVEState>(initialState), withLayout());
Expand Down
Loading

0 comments on commit aeb5c8e

Please sign in to comment.