Make the Preview button dynamic (#3317)

This commit is contained in:
Sushant Bajracharya 2019-07-11 04:59:14 +05:45 committed by Mac Siri
parent 699d8703c9
commit 01d1d1bcea
2 changed files with 18 additions and 7 deletions

View file

@ -16,7 +16,7 @@ const PublishToggle = ({
<div className="articleform__buttons">
<button
onClick={onHelp}
type='button'
type="button"
className={
helpShowing
? 'articleform__buttons--small active'
@ -27,22 +27,32 @@ const PublishToggle = ({
</button>
<button
onClick={onPreview}
type='button'
type="button"
className={previewShowing ? 'active' : 'inactive'}
>
PREVIEW
{previewShowing ? 'EDIT' : 'PREVIEW'}
</button>
{(published || version === 'v1') ? '' : <button onClick={onSaveDraft} type='button'>SAVE DRAFT</button>}
{published || version === 'v1' ? (
''
) : (
<button onClick={onSaveDraft} type="button">
SAVE DRAFT
</button>
)}
<span>
<p style={!edited && { visibility: 'hidden' }}>
New Changes (
<button onClick={onClearChanges} className="clear-button" type='button'>
<button onClick={onClearChanges} className="clear-button" type="button">
clear
</button>
)
</p>
<button onClick={onPublish} className="articleform__buttons--publish" type='button'>
{(published || version === 'v1') ? 'SAVE CHANGES' : 'PUBLISH'}
<button
onClick={onPublish}
className="articleform__buttons--publish"
type="button"
>
{published || version === 'v1' ? 'SAVE CHANGES' : 'PUBLISH'}
</button>
</span>
</div>

View file

@ -21,6 +21,7 @@ RSpec.describe "Editing with an editor", type: :system, js: true do
fill_in "article_body_markdown", with: template.gsub("Suspendisse", "Yooo")
click_button("PREVIEW")
expect(page).to have_text("Yooo")
expect(find(".active").text).to have_text("EDIT")
end
it "user updates their post" do