Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WP Admin link to Global Site Sidebar #87584

Merged
merged 13 commits into from
Feb 20, 2024
19 changes: 19 additions & 0 deletions client/layout/global-sidebar/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Icon, wordpress } from '@wordpress/icons';
import { LocalizeProps } from 'i18n-calypso';
import { FC } from 'react';
import AsyncLoad from 'calypso/components/async-load';
Expand Down Expand Up @@ -60,3 +61,21 @@ export const GlobalSidebarFooter: FC< {
</SidebarFooter>
);
};

export const GlobalSiteSidebarFooter: FC< {
selectedSiteSlug: string;
translate: LocalizeProps[ 'translate' ];
} > = ( { selectedSiteSlug, translate } ) => {
return (
<SidebarFooter>
<a
href={ `https://${ selectedSiteSlug }/wp-admin` }
className="sidebar__footer-wpadmin"
title={ translate( 'WP Admin' ) }
>
<Icon icon={ wordpress } className="wpicon" />
{ translate( 'WP Admin' ) }
</a>
</SidebarFooter>
);
};
17 changes: 15 additions & 2 deletions client/layout/global-sidebar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { Spinner, Gridicon } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import { useSelector } from 'react-redux';
import { useCurrentRoute } from 'calypso/components/route';
import GlobalSidebarHeader from 'calypso/layout/global-sidebar/header';
import useSiteMenuItems from 'calypso/my-sites/sidebar/use-site-menu-items';
import { getIsRequestingAdminMenu } from 'calypso/state/admin-menu/selectors';
import { getCurrentUser } from 'calypso/state/current-user/selectors';
import { getShouldShowGlobalSiteSidebar } from 'calypso/state/global-sidebar/selectors';
import { getSelectedSiteId, getSelectedSiteSlug } from 'calypso/state/ui/selectors';
import Sidebar from '../sidebar';
import { GlobalSidebarFooter } from './footer';
import { GlobalSidebarFooter, GlobalSiteSidebarFooter } from './footer';
import './style.scss';

const GlobalSidebar = ( { children, onClick = undefined, className = '', ...props } ) => {
const menuItems = useSiteMenuItems();
const isRequestingMenu = useSelector( getIsRequestingAdminMenu );
const translate = useTranslate();
const currentUser = useSelector( getCurrentUser );
const selectedSiteSlug = useSelector( ( state ) => getSelectedSiteSlug( state ) );
const selectedSiteId = useSelector( getSelectedSiteId );
const { currentSection } = useCurrentRoute();
const shouldShowGlobalSiteSidebar = useSelector( ( state ) => {
return getShouldShowGlobalSiteSidebar( state, selectedSiteId, currentSection?.group );
} );

/**
* If there are no menu items and we are currently requesting some,
Expand Down Expand Up @@ -43,7 +52,11 @@ const GlobalSidebar = ( { children, onClick = undefined, className = '', ...prop
{ children }
</Sidebar>
</div>
<GlobalSidebarFooter user={ currentUser } translate={ translate } />
{ shouldShowGlobalSiteSidebar ? (
<GlobalSiteSidebarFooter selectedSiteSlug={ selectedSiteSlug } translate={ translate } />
) : (
<GlobalSidebarFooter user={ currentUser } translate={ translate } />
) }
</div>
);
};
Expand Down
16 changes: 16 additions & 0 deletions client/layout/global-sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@
fill: var(--studio-white);
}
}
.sidebar__footer-wpadmin {
display: flex;
flex-grow: 1;
align-items: center;
color: var(--color-sidebar-text);
&:hover {
color: var(--color-sidebar-menu-hover-text);
text-decoration: underline;
}
svg {
fill: var(--studio-white);
&.wpicon {
margin-right: 10px;
}
}
}
}

.sidebar-notifications {
Expand Down
1 change: 0 additions & 1 deletion client/my-sites/site-settings/settings-security/main.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isEnabled } from '@automattic/calypso-config';
import { FEATURE_SECURITY_SETTINGS, WPCOM_FEATURES_SCAN } from '@automattic/calypso-products';
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
Expand Down
Loading