[Bugfix/v2-beta] Multipages: Page name should have at-least 1 character (#4983)

* fixes: Page handler is also accepting  only <space> : but the url should not include blank space

* page name and page handler cannot be named with white spaces
This commit is contained in:
Arpit 2022-12-19 18:27:18 +05:30 committed by GitHub
parent f32ce7d14a
commit 0221899bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -1390,6 +1390,11 @@ class EditorComponent extends React.Component {
return;
}
if (newHandle.trim().length === 0) {
toast.error('Page handle cannot be empty');
return;
}
this.setState(
{
isSaving: true,
@ -1452,6 +1457,11 @@ class EditorComponent extends React.Component {
};
renamePage = (pageId, newName) => {
if (newName.trim().length === 0) {
toast.error('Page name cannot be empty');
return;
}
const newAppDefinition = {
...this.state.appDefinition,
pages: {

View file

@ -5,6 +5,7 @@ import { EditModal } from './EditModal';
import { SettingsModal } from './SettingsModal';
import _ from 'lodash';
import SortableList from '@/_components/SortableList';
import toast from 'react-hot-toast';
export const PageHandler = ({
darkMode,
@ -194,7 +195,13 @@ export const PageHandler = ({
export const AddingPageHandler = ({ addNewPage, setNewPageBeingCreated }) => {
const handleAddingNewPage = (pageName) => {
if (pageName) {
if (pageName.trim().length === 0) {
toast('Page name should have atleast 1 character', {
icon: '⚠️',
});
}
if (pageName && pageName.trim().length > 0) {
addNewPage({ name: pageName, handle: _.kebabCase(pageName.toLowerCase()) });
}
setNewPageBeingCreated(false);