mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
|
|
import * as React from 'react';
|
||
|
|
import I18n from 'i18n-js';
|
||
|
|
|
||
|
|
import Box from '../../common/Box';
|
||
|
|
import { MutedText } from '../../common/CustomTexts';
|
||
|
|
import CopyToClipboardButton from '../../common/CopyToClipboardButton';
|
||
|
|
import Switch from '../../common/Switch';
|
||
|
|
|
||
|
|
interface Props {
|
||
|
|
embeddedRoadmapUrl: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
const RoadmapEmbedding: React.FC<Props> = ({ embeddedRoadmapUrl }) => {
|
||
|
|
const [showBoardFilter, setShowBoardFilter] = React.useState(true);
|
||
|
|
const [showPostStatusFilter, setShowPostStatusFilter] = React.useState(false);
|
||
|
|
const [embedCode, setEmbedCode] = React.useState('');
|
||
|
|
|
||
|
|
React.useEffect(() => {
|
||
|
|
const code = `
|
||
|
|
<iframe
|
||
|
|
src="${embeddedRoadmapUrl}?show_board_filter=${showBoardFilter}&show_status_filter=${showPostStatusFilter}"
|
||
|
|
width="860"
|
||
|
|
height="600"
|
||
|
|
seamless
|
||
|
|
frameborder="0"></iframe>
|
||
|
|
`;
|
||
|
|
setEmbedCode(code.replace(/\s+/g, ' ').trim());
|
||
|
|
}, [embeddedRoadmapUrl, showBoardFilter, showPostStatusFilter]);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Box>
|
||
|
|
<h2>{I18n.t('site_settings.roadmap.title_embed')}</h2>
|
||
|
|
|
||
|
|
<Switch
|
||
|
|
label={I18n.t('site_settings.roadmap.show_board_filter')}
|
||
|
|
onClick={() => setShowBoardFilter(!showBoardFilter)}
|
||
|
|
checked={showBoardFilter}
|
||
|
|
htmlId="showBoardFilterCheckbox"
|
||
|
|
/>
|
||
|
|
|
||
|
|
<Switch
|
||
|
|
label={I18n.t('site_settings.roadmap.show_post_status_filter')}
|
||
|
|
onClick={() => setShowPostStatusFilter(!showPostStatusFilter)}
|
||
|
|
checked={showPostStatusFilter}
|
||
|
|
htmlId="showPostStatusFilterCheckbox"
|
||
|
|
/>
|
||
|
|
|
||
|
|
<textarea
|
||
|
|
value={embedCode}
|
||
|
|
onChange={event => setEmbedCode(event.target.value)}
|
||
|
|
rows={5}
|
||
|
|
id="roadmapEmbedCode"
|
||
|
|
>
|
||
|
|
</textarea>
|
||
|
|
|
||
|
|
<MutedText>{I18n.t('site_settings.roadmap.embed_help')}</MutedText>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<CopyToClipboardButton
|
||
|
|
label={I18n.t('common.buttons.copy_to_clipboard')}
|
||
|
|
textToCopy={embedCode}
|
||
|
|
copiedLabel={I18n.t('common.copied')}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</Box>
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
export default RoadmapEmbedding;
|