@elementor/editor-components 4.0.0-671 → 4.0.0-672

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-components",
3
3
  "description": "Elementor editor components",
4
- "version": "4.0.0-671",
4
+ "version": "4.0.0-672",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,31 +40,31 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor": "4.0.0-671",
44
- "@elementor/editor-canvas": "4.0.0-671",
45
- "@elementor/editor-controls": "4.0.0-671",
46
- "@elementor/editor-documents": "4.0.0-671",
47
- "@elementor/editor-editing-panel": "4.0.0-671",
48
- "@elementor/editor-elements": "4.0.0-671",
49
- "@elementor/editor-elements-panel": "4.0.0-671",
50
- "@elementor/editor-mcp": "4.0.0-671",
51
- "@elementor/editor-templates": "4.0.0-671",
52
- "@elementor/editor-panels": "4.0.0-671",
53
- "@elementor/editor-props": "4.0.0-671",
54
- "@elementor/editor-styles-repository": "4.0.0-671",
55
- "@elementor/editor-ui": "4.0.0-671",
56
- "@elementor/editor-v1-adapters": "4.0.0-671",
57
- "@elementor/http-client": "4.0.0-671",
43
+ "@elementor/editor": "4.0.0-672",
44
+ "@elementor/editor-canvas": "4.0.0-672",
45
+ "@elementor/editor-controls": "4.0.0-672",
46
+ "@elementor/editor-documents": "4.0.0-672",
47
+ "@elementor/editor-editing-panel": "4.0.0-672",
48
+ "@elementor/editor-elements": "4.0.0-672",
49
+ "@elementor/editor-elements-panel": "4.0.0-672",
50
+ "@elementor/editor-mcp": "4.0.0-672",
51
+ "@elementor/editor-templates": "4.0.0-672",
52
+ "@elementor/editor-panels": "4.0.0-672",
53
+ "@elementor/editor-props": "4.0.0-672",
54
+ "@elementor/editor-styles-repository": "4.0.0-672",
55
+ "@elementor/editor-ui": "4.0.0-672",
56
+ "@elementor/editor-v1-adapters": "4.0.0-672",
57
+ "@elementor/http-client": "4.0.0-672",
58
58
  "@elementor/icons": "^1.68.0",
59
- "@elementor/events": "4.0.0-671",
60
- "@elementor/query": "4.0.0-671",
61
- "@elementor/schema": "4.0.0-671",
62
- "@elementor/store": "4.0.0-671",
59
+ "@elementor/events": "4.0.0-672",
60
+ "@elementor/query": "4.0.0-672",
61
+ "@elementor/schema": "4.0.0-672",
62
+ "@elementor/store": "4.0.0-672",
63
63
  "@elementor/ui": "1.36.17",
64
- "@elementor/utils": "4.0.0-671",
64
+ "@elementor/utils": "4.0.0-672",
65
65
  "@wordpress/i18n": "^5.13.0",
66
- "@elementor/editor-notifications": "4.0.0-671",
67
- "@elementor/editor-current-user": "4.0.0-671"
66
+ "@elementor/editor-notifications": "4.0.0-672",
67
+ "@elementor/editor-current-user": "4.0.0-672"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.3.1",
@@ -1,10 +1,17 @@
1
1
  import { invalidateDocumentData, isDocumentDirty } from '@elementor/editor-documents';
2
2
  import { type V1ElementData } from '@elementor/editor-elements';
3
+ import { notify } from '@elementor/editor-notifications';
4
+ import { AxiosError } from '@elementor/http-client';
5
+ import { __ } from '@wordpress/i18n';
3
6
 
4
7
  import { apiClient } from '../api';
5
8
  import { type DocumentSaveStatus } from '../types';
6
9
  import { getComponentDocuments } from '../utils/get-component-documents';
7
10
 
11
+ const INSUFFICIENT_PERMISSIONS_ERROR_CODE = 'insufficient_permissions';
12
+ const PUBLISH_UPGRADE_URL = 'https://go.elementor.com/go-pro-components-edit/';
13
+ const PUBLISH_UPGRADE_NOTIFICATION_ID = 'component-publish-upgrade';
14
+
8
15
  type Options = {
9
16
  status: DocumentSaveStatus;
10
17
  elements: V1ElementData[];
@@ -23,7 +30,41 @@ export async function publishDraftComponentsInPageBeforeSave( { status, elements
23
30
  return;
24
31
  }
25
32
 
26
- await apiClient.updateStatuses( draftIds, 'publish' );
33
+ try {
34
+ await apiClient.updateStatuses( draftIds, 'publish' );
35
+ } catch ( error ) {
36
+ if ( isInsufficientPermissionsError( error ) ) {
37
+ notifyPublishUpgrade();
38
+ return;
39
+ }
40
+
41
+ throw error;
42
+ }
27
43
 
28
44
  draftIds.forEach( ( id ) => invalidateDocumentData( id ) );
29
45
  }
46
+
47
+ function isInsufficientPermissionsError( error: unknown ): boolean {
48
+ return error instanceof AxiosError && error.response?.data?.code === INSUFFICIENT_PERMISSIONS_ERROR_CODE;
49
+ }
50
+
51
+ function notifyPublishUpgrade() {
52
+ notify( {
53
+ type: 'promotion',
54
+ id: PUBLISH_UPGRADE_NOTIFICATION_ID,
55
+ message: __(
56
+ 'You have unpublished component on this page. You need a pro version to publish it.',
57
+ 'elementor'
58
+ ),
59
+ additionalActionProps: [
60
+ {
61
+ size: 'small',
62
+ variant: 'contained',
63
+ color: 'promotion',
64
+ href: PUBLISH_UPGRADE_URL,
65
+ target: '_blank',
66
+ children: __( 'Upgrade Now', 'elementor' ),
67
+ },
68
+ ],
69
+ } );
70
+ }