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

Hide query strings from the site editor top bar #368

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- Hides query strings from the site editor top bar.

## [4.37.0] - 2021-02-09
- Adds support for multi binding for redirect CSV managment

Expand Down Expand Up @@ -39,11 +43,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Site editor flag in the iframe URL.

## [4.32.0] - 2021-01-21

### Added
- Adds binding selector for CMS Pages

- Adds binding selector for CMS Pages

## [4.31.1] - 2021-01-20

### Fixed

- Sending blockId in `Form index` component even when is not changed to prevent unexpected behaviors

## [4.31.0] - 2021-01-13
Expand Down
4 changes: 3 additions & 1 deletion react/components/EditorContainer/StoreIframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const StoreIframe: React.FunctionComponent<Props> = ({ path }) => {
src += `${getJoiner(src)}__bindingAddress=${binding.canonicalBaseAddress}`
}

src += `${getJoiner(src)}__siteEditor`
if (!src.includes('__siteEditor')) {
src += `${getJoiner(src)}__siteEditor=true`
}

return (
<iframe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const ContextSelectors: React.FC<WithApolloClient<Props>> = ({
if (newBinding && editor.iframeWindow) {
setBinding(newBinding)

editor.iframeWindow.location.search = `__bindingAddress=${newBinding.canonicalBaseAddress}&__siteEditor`
editor.iframeWindow.location.search = `__bindingAddress=${newBinding.canonicalBaseAddress}&__siteEditor=true`
}
}
},
Expand Down
21 changes: 19 additions & 2 deletions react/components/EditorContainer/Topbar/UrlInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,26 @@ const UrlInput = () => {

const editor = useEditorContext()

const resolveUrlPath = (pathname: string, searchQueries: string) => {
const searchParams = new URLSearchParams(searchQueries)
const SEARCH_QUERIES_TO_HIDE = ['__siteEditor', '__bindingAddress']

SEARCH_QUERIES_TO_HIDE.forEach(query => {
searchParams.delete(query)
})

if (searchParams.toString().length) {
return pathname + `?${searchParams.toString()}`
}

return pathname
}

const urlPath = editor.iframeWindow
? editor.iframeWindow.location.pathname +
editor.iframeWindow.location.search
? resolveUrlPath(
editor.iframeWindow.location.pathname,
editor.iframeWindow.location.search
)
: ''

const [url, setUrl] = React.useState(urlPath)
Expand Down