feat: add showSettingsPage api for proper routing

This commit is contained in:
lonyele 2019-07-01 23:42:34 +09:00
parent 1131f5d978
commit 1c2ff95046

View File

@ -8,7 +8,7 @@ type Direction = -1 | 1;
type StoryId = string; type StoryId = string;
type ParameterName = string; type ParameterName = string;
type ViewMode = 'story' | 'info' | undefined; type ViewMode = 'story' | 'info' | 'settings' | undefined;
export interface SubState { export interface SubState {
storiesHash: StoriesHash; storiesHash: StoriesHash;
@ -306,6 +306,19 @@ Did you create a path that uses the separator char accidentally, such as 'Vue <d
} }
}; };
// Navigate to settings page by changing the viewMode state and route
// to the specific settings page.
const showSettingsPage = (storyId: string) => {
store.setState(
{
viewMode: 'settings',
},
() => {
navigate(`/settings/${storyId}`);
}
);
};
return { return {
api: { api: {
storyId: toId, storyId: toId,
@ -317,6 +330,7 @@ Did you create a path that uses the separator char accidentally, such as 'Vue <d
getData, getData,
getParameters, getParameters,
getCurrentParameter, getCurrentParameter,
showSettingsPage,
}, },
state: { state: {
storiesHash: {}, storiesHash: {},