mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-11 11:22:53 +02:00
#225 - removed slug validation in button for dependent placeholders
This commit is contained in:
@@ -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} /> }
|
||||
|
||||
|
||||
@@ -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`} />
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user