-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Feature: Homepage overhaul with widgets #6551
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
Open
lkostrowski
wants to merge
21
commits into
main
Choose a base branch
from
lkostrowski/home-app-extensions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f354bd9
POC - homepage widgets
lkostrowski dbbac1e
ui improvements
lkostrowski 0a0f1d9
app logo
lkostrowski b94b345
story, official logo
lkostrowski 187a573
fix tabs
lkostrowski 8705b66
grid
lkostrowski d0f77eb
fix ui
lkostrowski b386bd0
restore onboarding
lkostrowski 61a669c
restore onboarding
lkostrowski 853fa26
fix validation
lkostrowski 92c61de
locales
lkostrowski 2b16d28
fix route
lkostrowski a7ceda4
remove comment
lkostrowski a9b5f25
Merge branch 'main' into lkostrowski/home-app-extensions
lkostrowski 4d538e8
handle non widget target
lkostrowski 1b69060
Merge branch 'lkostrowski/home-app-extensions' of github.com:saleor/s…
lkostrowski 4f57baf
change name
lkostrowski ed9911c
Merge branch 'main' into lkostrowski/home-app-extensions
lkostrowski b97921c
missing route
lkostrowski 212eb5e
Merge branch 'lkostrowski/home-app-extensions' of github.com:saleor/s…
lkostrowski dcb331c
add env
lkostrowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,97 @@ | ||
| import { SaleorThrobber } from "@dashboard/components/Throbber"; | ||
| import { getAbsoluteApiUrl } from "@dashboard/config"; | ||
| import { type AppDetailsUrlMountQueryParams } from "@dashboard/extensions/urls"; | ||
| import { Box, Skeleton } from "@saleor/macaw-ui-next"; | ||
| import { type CSSProperties, useEffect, useRef } from "react"; | ||
|
|
||
| const hiddenStyle: CSSProperties = { visibility: "hidden" }; | ||
|
|
||
| interface IframePostProps { | ||
| extensionId: string; | ||
| extensionUrl: string; | ||
| appId: string; | ||
| accessToken: string; | ||
| params?: AppDetailsUrlMountQueryParams; | ||
| height?: number | string; | ||
| loaderType?: "skeleton" | "throbber"; | ||
| } | ||
|
|
||
| /** | ||
| * Renders a hidden form which auto-submits on mount with POST so the iframe | ||
| * receives credentials in the body instead of the URL. | ||
| */ | ||
| export const IframePost = ({ | ||
| extensionId, | ||
| extensionUrl, | ||
| appId, | ||
| accessToken, | ||
| params, | ||
| height = 200, | ||
| loaderType = "skeleton", | ||
| }: IframePostProps) => { | ||
| const formRef = useRef<HTMLFormElement | null>(null); | ||
| const iframeRef = useRef<HTMLIFrameElement | null>(null); | ||
| const loadingRef = useRef<HTMLDivElement | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (formRef.current) { | ||
| formRef.current.submit(); | ||
| } | ||
|
|
||
| const iframe = iframeRef.current; | ||
| const loading = loadingRef.current; | ||
|
|
||
| if (!iframe || !loading) { | ||
| return; | ||
| } | ||
|
|
||
| const onload = () => { | ||
| loading.style.display = "none"; | ||
| iframe.style.visibility = "visible"; | ||
| }; | ||
|
|
||
| iframe.addEventListener("load", onload); | ||
|
|
||
| return () => { | ||
| iframe.removeEventListener("load", onload); | ||
| }; | ||
| }, []); | ||
|
lkostrowski marked this conversation as resolved.
lkostrowski marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <Box width="100%" __height={height as number | string}> | ||
| <form ref={formRef} action={extensionUrl} method="POST" target={`ext-frame-${extensionId}`}> | ||
| <input type="hidden" name="saleorApiUrl" value={getAbsoluteApiUrl()} /> | ||
| <input type="hidden" name="accessToken" value={accessToken} /> | ||
| <input type="hidden" name="appId" value={appId} /> | ||
| {params && | ||
|
lkostrowski marked this conversation as resolved.
|
||
| Object.entries(params).map(([key, value]) => ( | ||
| <input type="hidden" key={key} name={key} value={value} /> | ||
| ))} | ||
| </form> | ||
| <Box | ||
| ref={loadingRef} | ||
| width="100%" | ||
| __height={height as number | string} | ||
| display={loaderType === "throbber" ? "flex" : "block"} | ||
| alignItems={loaderType === "throbber" ? "center" : undefined} | ||
| justifyContent={loaderType === "throbber" ? "center" : undefined} | ||
| > | ||
| {loaderType === "throbber" ? ( | ||
| <SaleorThrobber /> | ||
| ) : ( | ||
| <Skeleton __height={height as number | string} /> | ||
| )} | ||
| </Box> | ||
| <Box | ||
| style={hiddenStyle} | ||
| ref={iframeRef} | ||
| as="iframe" | ||
| borderWidth={0} | ||
| __height={height as number | string} | ||
| sandbox="allow-same-origin allow-forms allow-scripts allow-downloads" | ||
|
|
||
| name={`ext-frame-${extensionId}`} | ||
| width="100%" | ||
| /> | ||
|
lkostrowski marked this conversation as resolved.
lkostrowski marked this conversation as resolved.
|
||
| </Box> | ||
| ); | ||
| }; | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.