Skip to content

Commit 3e2f2a5

Browse files
committed
upload error subscruption + spinnner in the uploading wall
1 parent 8e33ebf commit 3e2f2a5

5 files changed

Lines changed: 48 additions & 2 deletions

File tree

core-web/libs/portlets/dot-plugins/src/lib/dot-plugins-list/dot-plugins-list.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ <h3 class="m-0 text-lg font-medium text-gray-800">
9090
<div
9191
class="flex-1 flex flex-col items-center justify-center gap-4"
9292
data-testid="plugins-uploading-state">
93-
<i class="pi pi-cloud-upload text-primary text-6xl!" aria-hidden="true"></i>
93+
<p-progressSpinner
94+
styleClass="w-16! h-16! [&_svg_circle]:stroke-[var(--p-primary-color)]!"
95+
strokeWidth="4"
96+
ariaLabel="uploading" />
9497
<div class="flex flex-col text-center">
9598
<h3 class="m-0 text-lg font-medium text-gray-800">
9699
{{ 'plugins.uploading.title' | dm }}

core-web/libs/portlets/dot-plugins/src/lib/dot-plugins-list/dot-plugins-list.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { IconFieldModule } from 'primeng/iconfield';
1818
import { InputIconModule } from 'primeng/inputicon';
1919
import { InputTextModule } from 'primeng/inputtext';
2020
import { Menu, MenuModule } from 'primeng/menu';
21+
import { ProgressSpinnerModule } from 'primeng/progressspinner';
2122
import { SkeletonModule } from 'primeng/skeleton';
2223
import { Table, TableModule } from 'primeng/table';
2324
import { ToggleSwitchModule } from 'primeng/toggleswitch';
@@ -49,6 +50,7 @@ import { DotPluginsUploadComponent } from '../dot-plugins-upload/dot-plugins-upl
4950
FormsModule,
5051
MenuModule,
5152
TableModule,
53+
ProgressSpinnerModule,
5254
SkeletonModule,
5355
ButtonModule,
5456
ChipModule,

core-web/libs/portlets/dot-plugins/src/lib/dot-plugins-list/store/dot-plugins-list.store.spec.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
DotOsgiService
1212
} from '@dotcms/data-access';
1313
import { DotcmsEventsService } from '@dotcms/dotcms-js';
14-
import { DotCMSAPIResponse } from '@dotcms/dotcms-models';
14+
import { DotCMSAPIResponse, DotMessageSeverity } from '@dotcms/dotcms-models';
1515

1616
import { DotPluginsListStore } from './dot-plugins-list.store';
1717

@@ -75,6 +75,7 @@ describe('DotPluginsListStore', () => {
7575

7676
const osgiFrameworkRestartSubject = new Subject<void>();
7777
const osgiBundlesLoadedSubject = new Subject<void>();
78+
const osgiUploadFailedSubject = new Subject<void>();
7879

7980
const createService = createServiceFactory({
8081
service: DotPluginsListStore,
@@ -101,6 +102,8 @@ describe('DotPluginsListStore', () => {
101102
return osgiFrameworkRestartSubject.asObservable();
102103
if (event === 'OSGI_BUNDLES_LOADED')
103104
return osgiBundlesLoadedSubject.asObservable();
105+
if (event === 'OSGI_BUNDLES_UPLOAD_FAILED')
106+
return osgiUploadFailedSubject.asObservable();
104107
return of();
105108
})
106109
})
@@ -367,6 +370,25 @@ describe('DotPluginsListStore', () => {
367370
);
368371
});
369372

373+
it('should reset status to loaded on OSGI_BUNDLES_UPLOAD_FAILED', () => {
374+
store.uploadBundles([new File(['content'], 'plugin.jar')]);
375+
expect(store.status()).toBe('uploading');
376+
377+
osgiUploadFailedSubject.next();
378+
379+
expect(store.status()).toBe('loaded');
380+
});
381+
382+
it('should show an error message on OSGI_BUNDLES_UPLOAD_FAILED', () => {
383+
const messageDisplayService = spectator.inject(DotMessageDisplayService);
384+
385+
osgiUploadFailedSubject.next();
386+
387+
expect(messageDisplayService.push).toHaveBeenCalledWith(
388+
expect.objectContaining({ severity: DotMessageSeverity.ERROR })
389+
);
390+
});
391+
370392
it('should preserve uploading status through the websocket-triggered reload and resolve to loaded', () => {
371393
jest.spyOn(osgiService, 'getInstalledBundles').mockReturnValue(
372394
of(mockDotCMSResponse([] as BundleMap[]))

core-web/libs/portlets/dot-plugins/src/lib/dot-plugins-list/store/dot-plugins-list.store.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import { catchError, debounceTime, delay, take } from 'rxjs/operators';
1616
import {
1717
BundleMap,
1818
DotHttpErrorManagerService,
19+
DotMessageDisplayService,
20+
DotMessageService,
1921
DotOsgiService,
2022
PluginRow
2123
} from '@dotcms/data-access';
2224
import { DotcmsEventsService } from '@dotcms/dotcms-js';
25+
import { DotMessageSeverity, DotMessageType } from '@dotcms/dotcms-models';
2326

2427
/** Delay after OSGi mutating calls before reload; matches backend / websocket timing for bundle state to settle. */
2528
const OSGI_ACTION_DELAY_MS = 5000;
@@ -249,6 +252,8 @@ export const DotPluginsListStore = signalStore(
249252
/** Initial full load; listens for OSGi websocket events to update status and refresh data. */
250253
onInit() {
251254
const dotcmsEventsService = inject(DotcmsEventsService);
255+
const dotMessageDisplayService = inject(DotMessageDisplayService);
256+
const dotMessageService = inject(DotMessageService);
252257
const destroyRef = inject(DestroyRef);
253258

254259
store.loadAll(undefined, true);
@@ -268,6 +273,19 @@ export const DotPluginsListStore = signalStore(
268273
store.status() === 'uploading' ? 'uploading' : 'refreshing'
269274
)
270275
);
276+
277+
dotcmsEventsService
278+
.subscribeTo('OSGI_BUNDLES_UPLOAD_FAILED')
279+
.pipe(takeUntilDestroyed(destroyRef))
280+
.subscribe(() => {
281+
patchState(store, { status: 'loaded' });
282+
dotMessageDisplayService.push({
283+
life: 5000,
284+
message: dotMessageService.get('plugins.upload.failed'),
285+
severity: DotMessageSeverity.ERROR,
286+
type: DotMessageType.SIMPLE_MESSAGE
287+
});
288+
});
271289
}
272290
}))
273291
);

dotCMS/src/main/webapp/WEB-INF/messages/Language.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6613,6 +6613,7 @@ plugins.upload.dropzone.prefix=Drag & drop files or
66136613
plugins.upload.dropzone.suffix=to upload
66146614
plugins.upload.jar-support=We only support JAR files
66156615
plugins.upload.and-n-more=and {0} more
6616+
plugins.upload.failed=Plugin upload failed. Please try again.
66166617
plugins.extra-packages.title=Exported Packages
66176618
plugins.extra-packages.instructions=Paste the list of exported packages (one per line) to be made available to plugins.
66186619
plugins.extra-packages.search.placeholder=Find package\u2026

0 commit comments

Comments
 (0)