Skip to content

Commit 1540140

Browse files
authored
Fixes Copy page functionality and Custom HTML editor styles (#2783)
1 parent a74f7db commit 1540140

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/admin/pages/pageDetailsModal.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class PageDetailsModal extends React.Component<PageDetailsModalProps, Pag
106106
}, 300);
107107

108108
validatePermalink = async (permalink: string): Promise<string> => {
109-
if (!this.state.copyPage && permalink === this.props.page?.permalink) return '';
109+
if (permalink === this.props.page?.permalink || (this.state.copyPage && permalink === this.props.page?.permalink + '-copy')) return '';
110110

111111
const isPermalinkNotDefined = await this.permalinkService.isPermalinkDefined(permalink) && !reservedPermalinks.includes(permalink);
112112
const errorMessage = validateField(UNIQUE_REQUIRED, permalink, isPermalinkNotDefined);
@@ -126,11 +126,11 @@ export class PageDetailsModal extends React.Component<PageDetailsModalProps, Pag
126126
}
127127

128128
copyPage = async (): Promise<void> => {
129-
this.setState({ copyPage: true, page: {
130-
...this.state.page,
131-
permalink: this.state.page.permalink + '-copy',
132-
title: this.state.page.title + ' (copy)'
133-
}});
129+
const copiedPage: PageContract = await this.pageService.copyPage(this.state.page.key);
130+
131+
if (copiedPage?.key) {
132+
this.setState({ copyPage: true, page: copiedPage });
133+
}
134134
}
135135

136136
savePage = async (): Promise<void> => {
@@ -147,7 +147,7 @@ export class PageDetailsModal extends React.Component<PageDetailsModalProps, Pag
147147
return;
148148
}
149149

150-
if (this.props.page && !this.state.copyPage) {
150+
if (this.props.page || this.state.copyPage) {
151151
await this.pageService.updatePage(this.state.page);
152152
} else {
153153
const newPage = this.state.page;

src/themes/designer/styles/codeEditor.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
code-editor {
2+
position: relative;
23
min-height: 200px;
34

45
/* fix for positioning of the IntelliSense window of Monaco Editor */

0 commit comments

Comments
 (0)