#225 - removed slug validation in button for dependent placeholders

This commit is contained in:
Elio Struyf
2022-01-20 17:02:32 +01:00
parent 469a1aaaf8
commit 1c74df0266
2 changed files with 4 additions and 14 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ const Actions: React.FunctionComponent<IActionsProps> = ({ metadata, settings }:
<Collapsible id={`actions`} title="Actions">
<div className={`article__actions`}>
{ metadata && metadata.title && <SlugAction value={metadata.title} crntValue={metadata.slug} slugOpts={settings.slug} /> }
{ metadata && metadata.title && <SlugAction /> }
{ settings?.preview?.host && <Preview slug={metadata.slug} /> }
+3 -13
View File
@@ -1,28 +1,18 @@
import * as React from 'react';
import { MessageHelper } from '../../helpers/MessageHelper';
import { SlugHelper } from '../../helpers/SlugHelper';
import { Slug } from '../../models/PanelSettings';
import { CommandToCode } from '../CommandToCode';
import { ActionButton } from './ActionButton';
export interface ISlugActionProps {
value: string;
crntValue: string;
slugOpts: Slug;
}
export interface ISlugActionProps {}
const SlugAction: React.FunctionComponent<ISlugActionProps> = (props: React.PropsWithChildren<ISlugActionProps>) => {
const { value, crntValue, slugOpts } = props;
let slug = SlugHelper.createSlug(value);
slug = `${slugOpts.prefix}${slug}${slugOpts.suffix}`;
const SlugAction: React.FunctionComponent<ISlugActionProps> = ({}: React.PropsWithChildren<ISlugActionProps>) => {
const optimize = () => {
MessageHelper.sendMessage(CommandToCode.updateSlug);
};
return (
<ActionButton onClick={optimize} disabled={crntValue === slug} title={`Optimize slug`} />
<ActionButton onClick={optimize} title={`Optimize slug`} />
);
};