-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* wip * Storing last page for canvas in session storage * Fix bad path * Fix bad merge * Cleanup and adding some types * Fixing types * PR feedback and storage refactor Co-authored-by: Corey Robertson <corey.robertson@elastic.co> Co-authored-by: Corey Robertson <corey.robertson@elastic.co>
- Loading branch information
1 parent
7966756
commit 6115351
Showing
9 changed files
with
136 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Storage } from '../../../../../src/plugins/kibana_utils/public'; | ||
import { getWindow } from './get_window'; | ||
|
||
export enum StorageType { | ||
Local = 'localStorage', | ||
Session = 'sessionStorage', | ||
} | ||
|
||
const storages: { | ||
[x in StorageType]: Storage | null; | ||
} = { | ||
[StorageType.Local]: null, | ||
[StorageType.Session]: null, | ||
}; | ||
|
||
const getStorage = (type: StorageType): Storage => { | ||
const storage = storages[type] || new Storage(getWindow()[type]); | ||
storages[type] = storage; | ||
|
||
return storage; | ||
}; | ||
|
||
export const getLocalStorage = (): Storage => { | ||
return getStorage(StorageType.Local); | ||
}; | ||
|
||
export const getSessionStorage = (): Storage => { | ||
return getStorage(StorageType.Session); | ||
}; |
This file contains 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 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 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,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CanvasServiceFactory } from '.'; | ||
import { SESSIONSTORAGE_LASTPATH } from '../../common/lib/constants'; | ||
import { getSessionStorage } from '../lib/storage'; | ||
|
||
interface NavLinkService { | ||
updatePath: (path: string) => void; | ||
} | ||
|
||
export const navLinkServiceFactory: CanvasServiceFactory<NavLinkService> = ( | ||
coreSetup, | ||
coreStart, | ||
setupPlugins, | ||
startPlugins, | ||
appUpdater | ||
) => { | ||
return { | ||
updatePath: (path: string) => { | ||
appUpdater.next(() => ({ | ||
defaultPath: `#${path}`, | ||
})); | ||
|
||
getSessionStorage().set(SESSIONSTORAGE_LASTPATH, path); | ||
}, | ||
}; | ||
}; |