-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Live Preview: Fix the Save button wasn't overriden correctly (#95639)
* Live Preview: Fix the Save button wasn't overriden correctly * Check whether the editor is ready only for the upgrade button
- Loading branch information
1 parent
e5efbf3
commit c25e4bf
Showing
56 changed files
with
210 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Button } from '@wordpress/components'; | ||
import clsx from 'clsx'; | ||
import { navigate } from 'calypso/lib/navigate'; | ||
|
||
import './style.scss'; | ||
|
||
interface PanelSidebarItem { | ||
key: string; | ||
label: string; | ||
} | ||
|
||
interface PanelSidebarProps { | ||
items: PanelSidebarItem[]; | ||
selectedItemKey: string; | ||
} | ||
|
||
function PanelSidebar( { items, selectedItemKey }: PanelSidebarProps ) { | ||
const switchItem = ( key: string ) => { | ||
navigate( window.location.pathname.replace( /\/[^/]+\/([^/]+)$/, `/${ key }/$1` ) ); | ||
}; | ||
|
||
return ( | ||
<div className="panel-sidebar"> | ||
{ items.map( ( item ) => { | ||
return ( | ||
<Button | ||
key={ item.key } | ||
className={ clsx( 'panel-sidebar-tab', { | ||
'panel-sidebar-tab--active': item.key === selectedItemKey, | ||
} ) } | ||
onClick={ () => switchItem( item.key ) } | ||
> | ||
{ item.label } | ||
</Button> | ||
); | ||
} ) } | ||
</div> | ||
); | ||
} | ||
|
||
export function PanelWithSidebar( { children }: { children: React.ReactNode } ) { | ||
return <div className="panel-with-sidebar">{ children }</div>; | ||
} | ||
|
||
export default function makeSidebar( { items }: { items: PanelSidebarItem[] } ) { | ||
const props = { items }; | ||
return ( { selectedItemKey }: { selectedItemKey: string } ) => ( | ||
<PanelSidebar { ...props } selectedItemKey={ selectedItemKey } /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
@import "~@automattic/color-studio/dist/color-variables"; | ||
|
||
.panel-with-sidebar { | ||
display: flex; | ||
gap: 20px; | ||
} | ||
|
||
.panel-sidebar { | ||
width: 160px; | ||
} | ||
|
||
.panel-sidebar-tab { | ||
width: 100%; | ||
color: var(--studio-gray-100); | ||
|
||
&--active { | ||
background-color: #f0f0f0; | ||
font-weight: 600; | ||
border-radius: 4px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function BusinessTools() { | ||
return <div>This is Business Tools page</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import makeSidebar, { PanelWithSidebar } from '../components/panel-sidebar'; | ||
import BusinessTools from './business-tools'; | ||
import MarketingTools from './tools'; | ||
import type { Context as PageJSContext } from '@automattic/calypso-router'; | ||
|
||
const MarketingSidebar = makeSidebar( { | ||
items: [ | ||
{ | ||
key: 'tools', | ||
get label() { | ||
return __( 'Marketing Tools' ); | ||
}, | ||
}, | ||
{ | ||
key: 'business-tools', | ||
get label() { | ||
return __( 'Business Tools' ); | ||
}, | ||
}, | ||
], | ||
} ); | ||
|
||
export function marketingTools( context: PageJSContext, next: () => void ) { | ||
context.primary = ( | ||
<PanelWithSidebar> | ||
<MarketingSidebar selectedItemKey="tools" /> | ||
<MarketingTools /> | ||
</PanelWithSidebar> | ||
); | ||
next(); | ||
} | ||
|
||
export function businessTools( context: PageJSContext, next: () => void ) { | ||
context.primary = ( | ||
<PanelWithSidebar> | ||
<MarketingSidebar selectedItemKey="business-tools" /> | ||
<BusinessTools /> | ||
</PanelWithSidebar> | ||
); | ||
next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import page, { type Callback } from '@automattic/calypso-router'; | ||
import { makeLayout, render as clientRender } from 'calypso/controller'; | ||
import { siteSelection, sites, navigation } from 'calypso/my-sites/controller'; | ||
import { | ||
DOTCOM_MARKETING_BUSINESS_TOOLS, | ||
DOTCOM_MARKETING_TOOLS, | ||
} from 'calypso/sites/components/site-preview-pane/constants'; | ||
import { siteDashboard } from 'calypso/sites/controller'; | ||
import { marketingTools, businessTools } from './controller'; | ||
|
||
export default function () { | ||
page( '/sites/marketing', siteSelection, sites, makeLayout, clientRender ); | ||
|
||
const redirectWoy: Callback = ( context ) => { | ||
context.page.replace( `/sites/marketing/tools/${ context.params.site }` ); | ||
}; | ||
page( '/sites/marketing/:site', redirectWoy ); | ||
|
||
page( | ||
'/sites/marketing/tools/:site', | ||
siteSelection, | ||
navigation, | ||
marketingTools, | ||
siteDashboard( DOTCOM_MARKETING_TOOLS ), | ||
makeLayout, | ||
clientRender | ||
); | ||
|
||
page( | ||
'/sites/marketing/business-tools/:site', | ||
siteSelection, | ||
navigation, | ||
businessTools, | ||
siteDashboard( DOTCOM_MARKETING_BUSINESS_TOOLS ), | ||
makeLayout, | ||
clientRender | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function MarketingTools() { | ||
return <div>This is Marketing Tools page</div>; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters