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

Frontend permissions #2218

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c452068
rewrite account urls when guestOnlyMode is active
Jessevdpoel Feb 23, 2024
abe58fb
Added guestOnlyMode config
Jessevdpoel Feb 23, 2024
3e30026
Hide account buttons when guestOnlyMode is active
Jessevdpoel Feb 23, 2024
5a53ec8
fixed eslint error
Jessevdpoel Feb 23, 2024
a958a9f
updated rewrites
Jessevdpoel Feb 23, 2024
e7c4198
updated withGraphcommerce config
Jessevdpoel Feb 23, 2024
cd1440a
return null if guestOnlyMode instead of wrapping
Jessevdpoel Feb 23, 2024
c3add67
rewrite account urls when guestOnlyMode is active
Jessevdpoel Feb 23, 2024
e09f42b
Added guestOnlyMode config
Jessevdpoel Feb 23, 2024
b6ec2d6
Hide account buttons when guestOnlyMode is active
Jessevdpoel Feb 23, 2024
818b03b
fixed eslint error
Jessevdpoel Feb 23, 2024
abd37f7
updated rewrites
Jessevdpoel Feb 23, 2024
12c6224
updated withGraphcommerce config
Jessevdpoel Feb 23, 2024
b5f9f69
return null if guestOnlyMode instead of wrapping
Jessevdpoel Feb 23, 2024
53fdf45
Merge branch 'feature/guest-only-mode' of https://github.com/graphcom…
Jessevdpoel Mar 12, 2024
2bc6517
Added description to config
Jessevdpoel Mar 12, 2024
3612c99
Added changeset
Jessevdpoel Mar 12, 2024
78ed1aa
Fix guestOnlyOnly for EmailForm
paales Mar 12, 2024
239f53d
Changes guestOnlyMode to an signInMode with enums
Jessevdpoel Apr 17, 2024
0c7cae8
updated generated file
Jessevdpoel Apr 17, 2024
7e1d502
Changed check to signInMode enum
Jessevdpoel Apr 17, 2024
e242e7f
updated docs
Jessevdpoel Apr 17, 2024
67ca9d6
Created UnauthenticatedFullPageMessage
Jessevdpoel Apr 17, 2024
0ccd9cb
Added translations
Jessevdpoel Apr 17, 2024
48d1c4e
Disabled checkout if user is not loggedIn and DISABLE_GUEST_CHECKOUT …
Jessevdpoel Apr 17, 2024
bd14600
StartcheckoutButton links to accoun/signin if guest checkout is disab…
Jessevdpoel Apr 19, 2024
f16f13d
Added extra sign in mode
Jessevdpoel May 10, 2024
5642072
Added DISABLE_GUES_ADD_TO_CART config
Jessevdpoel May 10, 2024
5be4c00
Updated fullPageMessage
Jessevdpoel May 10, 2024
aa3505a
Added sign in button to AddProductsToCartButton
Jessevdpoel May 10, 2024
a6c5802
Added different fab which navigates to signin
Jessevdpoel May 10, 2024
fbf823c
Updated pages which need to show a button to the signinPage when gues…
Jessevdpoel May 10, 2024
ab0c264
Merge branch 'canary' into feature/guest-only-mode
Jessevdpoel May 10, 2024
8f5a3b9
Fixed build errors
Jessevdpoel May 10, 2024
5b36d28
fixed more rrors
Jessevdpoel May 10, 2024
bcddfea
Merge remote-tracking branch 'origin/canary' into feature/guest-only-…
Giovanni-Schroevers Jul 30, 2024
7a9b28c
feat(GCOM-1446): replace signInMode with permissions
Giovanni-Schroevers Jul 31, 2024
3c8d412
feat(GCOM-1446): add permissions description
Giovanni-Schroevers Jul 31, 2024
76ac7ac
Merge remote-tracking branch 'origin/canary' into feature/guest-only-…
Giovanni-Schroevers Jul 31, 2024
a4a46ca
feat(GCOM-1446): update translations
Giovanni-Schroevers Jul 31, 2024
4903ae9
feat(GCOM-1446): update snapshots
Giovanni-Schroevers Jul 31, 2024
ce2f672
Wip
paales Aug 2, 2024
fdda565
Ook nog ff mee
paales Aug 2, 2024
1a7734d
Move presmissions to relevant packages
Giovanni-Schroevers Aug 22, 2024
cb99999
Merge remote-tracking branch 'origin/canary' into feature/guest-only-…
Giovanni-Schroevers Aug 22, 2024
a946a0b
Spul
Giovanni-Schroevers Aug 22, 2024
b6b7e7f
feat(GCOM-1446): cleanup, replace FullPageMessage with ApolloCartErro…
Giovanni-Schroevers Aug 23, 2024
76333ed
feat(GCOM-1446): add back locale to router type
Giovanni-Schroevers Aug 23, 2024
e2a8d78
Add translations
Giovanni-Schroevers Aug 27, 2024
74b062e
Merge remote-tracking branch 'origin/canary' into feature/guest-only-…
Giovanni-Schroevers Aug 28, 2024
1a42647
Set error to onBeforeSubmitError or onCompleteError when present
Giovanni-Schroevers Aug 28, 2024
718a195
When a useFormGql throws an error in the onBeforeSubmit method or onC…
Giovanni-Schroevers Sep 3, 2024
7307fe8
Remove links from cart error alert
Giovanni-Schroevers Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/green-flowers-double.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@graphcommerce/react-hook-form': patch
---

When a useFormGql throws an error in the onBeforeSubmit method or onComplete method it will setError('root.thrown') with the message, allowing it to be displayed somewhere. PaymentMethodButton will now render this as an ErrorSnackbar.
When a useFormGql throws an error in the onBeforeSubmit method or onComplete method it will be set as an ApolloError with the message, allowing it to be displayed somewhere. PaymentMethodButton will now render this as an ErrorSnackbar.
9 changes: 9 additions & 0 deletions .changeset/popular-rules-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@graphcommerce/ecommerce-ui': minor
'@graphcommerce/magento-cart-email': minor
'@graphcommerce/magento-customer': minor
'@graphcommerce/magento-cart': minor
'@graphcommerce/magento-graphcms': minor
---

Add `permissions` config so the website or store can be configurated to run in different modes.
24 changes: 24 additions & 0 deletions docs/framework/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ Limit the static generation of SSG when building.

By default GraphCommerce will statically generate all product and category pages during build. This can take quite a long time, to skip this step set this value to true.

#### permissions: [GraphCommercePermissions](#GraphCommercePermissions)

Allows the option to require login or completely disable certain sections of the site, can be overriden per storeview with the storefrontConfig

#### previewSecret: string

To enable next.js' preview mode, configure the secret you'd like to use.
Expand Down Expand Up @@ -366,6 +370,22 @@ Issues that this can cause are:
- The same package is included multiple times in the bundle, increasing the bundle size.
- The Typescript types of the package are not compatible with each other, causing Typescript errors.

### GraphCommercePermissions

#### cart: CUSTOMER_ONLY | DISABLED | ENABLED

Changes the availability of the add to cart buttons and the cart page to either customer only or completely disables it.

#### checkout: CUSTOMER_ONLY | DISABLED | ENABLED

Changes the availability of the checkout to either customer only or completely disables it.

#### customerAccount: DISABLED | DISABLE_REGISTRATION | ENABLED

Enables / disabled the account section of the website. DISABLE_REGISTRATION will only disable the registration page.

#### website: ENABLED

### GraphCommerceStorefrontConfig

All storefront configuration for the project
Expand Down Expand Up @@ -438,6 +458,10 @@ Add a gcms-locales header to make sure queries return in a certain language, can

Custom locale used to load the .po files. Must be a valid locale, also used for Intl functions.

#### permissions: [GraphCommercePermissions](#GraphCommercePermissions)

Allows the option to require login or completely disable certain sections of the site on a per store basis

#### robotsAllow: boolean

Allow the site to be indexed by search engines.
Expand Down
4 changes: 3 additions & 1 deletion examples/magento-graphcms/components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Image } from '@graphcommerce/image'
import { useCheckoutGuestEnabled } from '@graphcommerce/magento-cart'
import { StoreSwitcherButton } from '@graphcommerce/magento-store'
import { Footer as FooterBase } from '@graphcommerce/next-ui'
import { Trans } from '@lingui/macro'
Expand All @@ -9,6 +10,7 @@ export type FooterProps = FooterQueryFragment

export function Footer(props: FooterProps) {
const { footer } = props
const cartEnabled = useCheckoutGuestEnabled()

return (
<FooterBase
Expand Down Expand Up @@ -46,7 +48,7 @@ export function Footer(props: FooterProps) {
{link.title}
</Link>
))}
{import.meta.graphCommerce.magentoVersion >= 247 && (
{import.meta.graphCommerce.magentoVersion >= 247 && cartEnabled && (
<Link href='/guest/orderstatus' color='textPrimary' underline='always'>
<Trans>Order status</Trans>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CartFab } from '@graphcommerce/magento-cart'
import { CartFab, useCartEnabled } from '@graphcommerce/magento-cart'
import { magentoMenuToNavigation } from '@graphcommerce/magento-category'
import { CustomerFab, CustomerMenuFabItem } from '@graphcommerce/magento-customer'
import { ProductFiltersProSearchField, SearchLink } from '@graphcommerce/magento-search'
Expand Down Expand Up @@ -39,6 +39,8 @@ export function LayoutNavigation(props: LayoutNavigationProps) {
const selection = useNavigationSelection()
const router = useRouter()

const cartEnabled = useCartEnabled()

return (
<>
<NavigationProvider
Expand Down Expand Up @@ -157,7 +159,7 @@ export function LayoutNavigation(props: LayoutNavigationProps) {
<WishlistFab icon={<IconSvg src={iconHeart} size='large' />} />
<CustomerFab guestHref='/account/signin' authHref='/account' />
{/* The placeholder exists because the CartFab is sticky but we want to reserve the space for the <CartFab /> */}
<PlaceholderFab />
{cartEnabled && <PlaceholderFab />}
</DesktopNavActions>
</>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCartEnabled } from '@graphcommerce/magento-cart'
import {
AddProductsToCartError,
AddProductsToCartQuantity,
Expand All @@ -21,6 +22,7 @@ export type AddProductsToCartViewProps = {

export function AddProductsToCartView(props: AddProductsToCartViewProps) {
const { product } = props
const cartEnabled = useCartEnabled()

return (
<>
Expand All @@ -39,20 +41,17 @@ export function AddProductsToCartView(props: AddProductsToCartViewProps) {
<>
<ProductCustomizable product={product} />
<Divider />

<ProductPageAddToCartQuantityRow product={product}>
<AddProductsToCartQuantity sx={{ flexShrink: '0' }} />
{cartEnabled && <AddProductsToCartQuantity sx={{ flexShrink: '0' }} />}

<AddProductsToCartError>
<Typography component='div' variant='h3' lineHeight='1'>
<ProductPagePrice product={product} />
</Typography>
</AddProductsToCartError>
</ProductPageAddToCartQuantityRow>

<ProductPagePriceTiers product={product} />

<ProductSidebarDelivery product={product} />
{cartEnabled && <ProductSidebarDelivery product={product} />}
</>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions examples/magento-graphcms/graphcommerce.config.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
const config = {
hygraphEndpoint: 'https://eu-central-1.cdn.hygraph.com/content/ckhx7xadya6xs01yxdujt8i80/master',
magentoEndpoint: 'https://backend.reachdigital.dev/graphql',
magentoVersion: 246,
magentoEndpoint: 'https://configurator.reachdigital.dev/graphql',
magentoVersion: 247,
canonicalBaseUrl: 'https://graphcommerce.vercel.app',
storefront: [
{ locale: 'en', magentoStoreCode: 'en_US', defaultLocale: true },
Expand Down
28 changes: 22 additions & 6 deletions examples/magento-graphcms/locales/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ msgstr "Kategorien"
msgid "Order #{orderNumber}"
msgstr "Bestellung #{orderNumber}"

#. js-lingui-generated-id
msgid "You must first login before you can continue"
msgstr "Sie müssen sich zuerst anmelden, bevor Sie fortfahren können"

msgid "Change"
msgstr "Ändern"

Expand Down Expand Up @@ -619,6 +623,10 @@ msgstr "Ergebnisse für ‘{search}’"
msgid "Telephone"
msgstr "Telefon"

#. js-lingui-generated-id
msgid "Please login to add products to your cart"
msgstr "Bitte loggen Sie sich ein, um Produkte zu Ihrem Warenkorb hinzuzufügen"

msgid "Recently viewed products"
msgstr "Kürzlich angesehene Produkte"

Expand Down Expand Up @@ -715,12 +723,12 @@ msgstr "Abmelden"
msgid "Sign up for our newsletter and stay updated"
msgstr "Abonnieren Sie unseren Newsletter und bleiben Sie auf dem Laufenden"

msgid "Sign up is disabled, please contact us for more information."
msgstr "Die Anmeldung ist deaktiviert, bitte kontaktieren Sie uns für weitere Informationen."

msgid "Skip to main content"
msgstr "Zum Hauptinhalt springen"

msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Einige Artikel im Warenkorb enthalten Fehler, bitte aktualisieren oder entfernen Sie diese, und versuchen Sie es erneut."

msgid "Something went wrong"
msgstr "Etwas ist schief gelaufen"

Expand All @@ -733,9 +741,6 @@ msgstr "Sortieren"
msgid "Sort By"
msgstr "Sortieren nach"

msgid "Start Checkout"
msgstr "Zur Kasse gehen"

msgid "Store home"
msgstr "Shop-Startseite"

Expand Down Expand Up @@ -922,6 +927,9 @@ msgstr "Sie müssen zustimmen, um fortfahren zu können"
msgid "You haven't placed any reviews yet"
msgstr "Sie haben noch keine Bewertungen abgegeben"

msgid "You must be signed in to continue"
msgstr "Sie müssen sich anmelden, um fortzufahren"

msgid "You must sign in to continue"
msgstr "Sie müssen sich anmelden, um fortzufahren"

Expand Down Expand Up @@ -1025,6 +1033,10 @@ msgstr "Auftrag erhalten"
msgid "one product"
msgstr "ein Produkt"

#. js-lingui-generated-id
msgid "Start Checkout"
msgstr "Zur Kasse gehen"

#. js-lingui-generated-id
msgid "Order not found"
msgstr "Bestellung nicht gefunden"
Expand All @@ -1049,6 +1061,10 @@ msgstr "Die angegebene E-Mail-Adresse stimmt nicht mit der Kontoe-Mail-Adresse
msgid "Message"
msgstr "Nachricht"

#. js-lingui-generated-id
msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Einige Artikel im Warenkorb enthalten Fehler, bitte aktualisieren oder entfernen Sie diese, und versuchen Sie es erneut."

#. js-lingui-generated-id
msgid "Order details"
msgstr "Details zur Bestellung"
Expand Down
28 changes: 22 additions & 6 deletions examples/magento-graphcms/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ msgstr "Categories"
msgid "Order #{orderNumber}"
msgstr "Order #{orderNumber}"

#. js-lingui-generated-id
msgid "You must first login before you can continue"
msgstr "You must first login before you can continue"

msgid "Change"
msgstr "Change"

Expand Down Expand Up @@ -619,6 +623,10 @@ msgstr "Results for ‘{search}’"
msgid "Telephone"
msgstr "Telephone"

#. js-lingui-generated-id
msgid "Please login to add products to your cart"
msgstr "Please login to add products to your cart"

msgid "Recently viewed products"
msgstr "Recently viewed products"

Expand Down Expand Up @@ -715,12 +723,12 @@ msgstr "Sign out"
msgid "Sign up for our newsletter and stay updated"
msgstr "Sign up for our newsletter and stay updated"

msgid "Sign up is disabled, please contact us for more information."
msgstr "Sign up is disabled, please contact us for more information."

msgid "Skip to main content"
msgstr "Skip to main content"

msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Some items in your cart contain errors, please update or remove them, then try again."

msgid "Something went wrong"
msgstr "Something went wrong"

Expand All @@ -733,9 +741,6 @@ msgstr "Sort"
msgid "Sort By"
msgstr "Sort By"

msgid "Start Checkout"
msgstr "Start Checkout"

msgid "Store home"
msgstr "Store home"

Expand Down Expand Up @@ -922,6 +927,9 @@ msgstr "You have to agree in order to proceed"
msgid "You haven't placed any reviews yet"
msgstr "You haven't placed any reviews yet"

msgid "You must be signed in to continue"
msgstr "You must be signed in to continue"

msgid "You must sign in to continue"
msgstr "You must sign in to continue"

Expand Down Expand Up @@ -1025,6 +1033,10 @@ msgstr "Get order"
msgid "one product"
msgstr "one product"

#. js-lingui-generated-id
msgid "Start Checkout"
msgstr "Start Checkout"

#. js-lingui-generated-id
msgid "Order not found"
msgstr "Order not found"
Expand All @@ -1049,6 +1061,10 @@ msgstr "The given email does not match the account email"
msgid "Message"
msgstr "Message"

#. js-lingui-generated-id
msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Some items in your cart contain errors, please update or remove them, then try again."

#. js-lingui-generated-id
msgid "Order details"
msgstr "Order details"
Expand Down
28 changes: 22 additions & 6 deletions examples/magento-graphcms/locales/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ msgstr "Categorías"
msgid "Order #{orderNumber}"
msgstr "Pedido #{orderNumber}"

#. js-lingui-generated-id
msgid "You must first login before you can continue"
msgstr "Debe iniciar sesión antes de continuar"

msgid "Change"
msgstr "Cambiar"

Expand Down Expand Up @@ -619,6 +623,10 @@ msgstr "Resultados para ‘{search}’"
msgid "Telephone"
msgstr "Teléfono"

#. js-lingui-generated-id
msgid "Please login to add products to your cart"
msgstr "Inicie sesión para añadir productos a su cesta"

msgid "Recently viewed products"
msgstr "Productos vistos recientemente"

Expand Down Expand Up @@ -715,12 +723,12 @@ msgstr "Cerrar sesión"
msgid "Sign up for our newsletter and stay updated"
msgstr "Regístrese para nuestro boletín y manténgase actualizado"

msgid "Sign up is disabled, please contact us for more information."
msgstr "La inscripción está deshabilitada, póngase en contacto con nosotros para obtener más información."

msgid "Skip to main content"
msgstr "Saltar al contenido principal"

msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Algunos artículos de su carrito contienen errores, actualícelos o elimínelos y vuelva a intentarlo."

msgid "Something went wrong"
msgstr "Algo salió mal"

Expand All @@ -733,9 +741,6 @@ msgstr "Ordenar"
msgid "Sort By"
msgstr "Ordenar por"

msgid "Start Checkout"
msgstr "Iniciar compra"

msgid "Store home"
msgstr "Inicio de la tienda"

Expand Down Expand Up @@ -922,6 +927,9 @@ msgstr "Debe aceptar para proceder"
msgid "You haven't placed any reviews yet"
msgstr "Aún no ha escrito ningún comentario"

msgid "You must be signed in to continue"
msgstr "Debe iniciar sesión para continuar"

msgid "You must sign in to continue"
msgstr "Debe iniciar sesión para continuar"

Expand Down Expand Up @@ -1025,6 +1033,10 @@ msgstr "Obtener pedido"
msgid "one product"
msgstr "un producto"

#. js-lingui-generated-id
msgid "Start Checkout"
msgstr "Iniciar compra"

#. js-lingui-generated-id
msgid "Order not found"
msgstr "Pedido no encontrado"
Expand All @@ -1049,6 +1061,10 @@ msgstr "El correo electrónico proporcionado no coincide con el correo electrón
msgid "Message"
msgstr "Mensaje"

#. js-lingui-generated-id
msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Algunos artículos de su carrito contienen errores, actualícelos o elimínelos y vuelva a intentarlo."

#. js-lingui-generated-id
msgid "Order details"
msgstr "Detalles del pedido"
Expand Down
Loading
Loading