-
Notifications
You must be signed in to change notification settings - Fork 8
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
MWPW-165152: Splash screen / content nav URL handling #129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,16 @@ import { reactiveStore } from './reactivity/reactive-store.js'; | |
const initialSearch = MasSearch.fromHash(); | ||
const initialFilters = MasFilters.fromHash(); | ||
|
||
const url = new URL(window.location.href); | ||
const pageParam = url.searchParams.get('page'); | ||
|
||
const initialPage = | ||
pageParam === 'welcome' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the absence of search query in the URL, the pageParam should be set to welcome so that the welcome page has always the same url. |
||
? 'splash' | ||
: initialSearch.path | ||
? 'content' | ||
: 'splash'; | ||
|
||
const Store = { | ||
fragments: { | ||
list: { | ||
|
@@ -31,7 +41,7 @@ const Store = { | |
), // 'render' | 'table' | ||
selecting: reactiveStore(false), | ||
selection: reactiveStore([]), | ||
currentPage: reactiveStore(initialSearch.query ? 'content' : 'splash'), // 'splash' | 'content' | ||
currentPage: reactiveStore(initialPage), // 'splash' | 'content' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think since we already have a store for the current page, we can just link it to the hash, just as Right now we have the This will also remove the need to handle history manually. @yesil mentioned history can be managed in |
||
}; | ||
|
||
export default Store; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import './mas-toast.js'; | |
import './mas-hash-manager.js'; | ||
import './mas-splash-screen.js'; | ||
import StoreController from './reactivity/store-controller.js'; | ||
import Store from './store.js'; | ||
import Store, { navigateToPage } from './store.js'; | ||
|
||
const BUCKET_TO_ENV = { | ||
e155390: 'qa', | ||
|
@@ -56,6 +56,25 @@ class MasStudio extends LitElement { | |
></mas-splash-screen>`; | ||
} | ||
|
||
connectedCallback() { | ||
super.connectedCallback(); | ||
} | ||
|
||
handleInitialPageLoad() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const url = new URL(window.location.href); | ||
const pageParam = url.searchParams.get('page'); | ||
|
||
if (pageParam === 'welcome') { | ||
navigateToPage('splash')(); | ||
history.pushState({}, '', url.toString()); | ||
return; | ||
} else { | ||
url.searchParams.delete('page'); | ||
history.replaceState({}, '', url.toString()); | ||
navigateToPage('content')(); | ||
} | ||
} | ||
|
||
render() { | ||
return html` | ||
<mas-top-nav env="${this.env}"></mas-top-nav> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the state manager, the history/url management should be consolidated into a single location as a side-effect or reaction to state update.
I think it should be in
navigateToPage
.