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 a better admin bar #1664

Merged
merged 1 commit into from
May 28, 2020
Merged

Conversation

bookernath
Copy link
Contributor

@bookernath bookernath commented Apr 28, 2020

What?

Adds a persistent admin bar for store control panel users to make it easier to launch actions from the storefront.

Handles 3 different states:

  1. Store live
  2. Store in prelaunch mode
  3. Store in maintenance mode

...with appropriate contextual actions for each.

Can be hidden (per-user), and can also be disabled via a theme setting.

Gracefully degrades at various responsive breakpoints.

Tickets / Documentation

Screenshots (if appropriate)

small breakpoint (completely hidden)

image

medium breakpoint (condensed)

image

large breakpoint (everything)

image

A page that doesn't support a contextual action, only opening in Page Builder:

image

Maintenance mode w/ mouseover tooltip:

image

Live mode:

image

ping @bigcommerce/merc-team @bigcommerce/storefront-team

@bigbot
Copy link

bigbot commented Apr 28, 2020

Autotagging @bigcommerce/storefront-team @davidchin

}

// Set admin cookie if appropriate
if (window.URLSearchParams && window.URL && (new URL(document.location)).searchParams.get('ctk')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm simply matching on the query param used when we launch the storefront from the CP. While this would be easy to forge, it doesn't really reveal anything particularly sensitive - every button you can click loads the CP, which is behind the merchant login.

@@ -1 +1 @@
<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><title>Logo B</title><path d="M17.647 12.125h-3.323c-.11 0-.197.087-.197.194v2.327c0 .107.087.193.197.193h3.323c.95 0 1.542-.524 1.542-1.357 0-.795-.594-1.358-1.543-1.358zm-2.62-2.423h3.233c2.51 0 3.988 1.57 3.988 3.296 0 1.35-.915 2.345-1.885 2.78-.155.07-.15.283.01.346 1.128.443 1.94 1.623 1.94 3 0 1.96-1.305 3.512-3.837 3.512h-6.96c-.11 0-.197-.087-.197-.194v-9.03L.237 24.49c-.51.508-.148 1.378.57 1.378h24.254c.446 0 .808-.362.808-.808V.81c0-.72-.87-1.08-1.38-.572L15.03 9.702zm-.703 7.562c-.11 0-.197.087-.197.194v2.56c0 .106.087.193.197.193h3.44c1.05 0 1.682-.542 1.682-1.472 0-.815-.593-1.474-1.68-1.474h-3.442z" fill="#FFF" fill-rule="evenodd"/></svg>
<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><title>Logo B</title><path d="M17.647 12.125h-3.323c-.11 0-.197.087-.197.194v2.327c0 .107.087.193.197.193h3.323c.95 0 1.542-.524 1.542-1.357 0-.795-.594-1.358-1.543-1.358zm-2.62-2.423h3.233c2.51 0 3.988 1.57 3.988 3.296 0 1.35-.915 2.345-1.885 2.78-.155.07-.15.283.01.346 1.128.443 1.94 1.623 1.94 3 0 1.96-1.305 3.512-3.837 3.512h-6.96c-.11 0-.197-.087-.197-.194v-9.03L.237 24.49c-.51.508-.148 1.378.57 1.378h24.254c.446 0 .808-.362.808-.808V.81c0-.72-.87-1.08-1.38-.572L15.03 9.702zm-.703 7.562c-.11 0-.197.087-.197.194v2.56c0 .106.087.193.197.193h3.44c1.05 0 1.682-.542 1.682-1.472 0-.815-.593-1.474-1.68-1.474h-3.442z" fill="#000" fill-rule="evenodd"/></svg>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just changing the fill color to match new design.

class: 'adminBar',
});

$element.html(`<div class="adminBar-logo">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can move the markup into a separate file 🍹

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably easier to remove later like this?

@@ -26,7 +29,9 @@ export default class Global extends PageManager {
menu();
mobileMenuToggle();
privacyCookieNotification();
maintenanceMode(this.context.maintenanceMode);
if (themeSettings['show-admin-bar']) {
adminBar(storeHash, maintenanceModeSettings, JSON.parse(adminBarLanguage), productId, categoryId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of defining all these params would it make sense to pass the entire context along with the page type so we can build contextual links for entities based on page type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but I didn't want to inject too much as whatever is injected will show up in HTML; IDs seem non-sensitive. And I'm trying to make this easy to remove before too long so we can remove admin bar from the theme entirely.

junedkazi
junedkazi previously approved these changes Apr 28, 2020
junedkazi
junedkazi previously approved these changes May 28, 2020
junedkazi
junedkazi previously approved these changes May 28, 2020
@bookernath bookernath merged commit fd15fb6 into bigcommerce:master May 28, 2020
@bookernath bookernath deleted the better-admin-bar branch May 28, 2020 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants