mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fixes, tweak example-extension for demo
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
b7be386e6b
commit
cd7f906afc
9 files changed
+70
-47
No files matched your search
@@ -54,7 +54,7 @@ export class UrlParam<V = any | any[]> {
|
||||
|
||||
get(): V {
|
||||
const { history, urlName } = this;
|
||||
const { multiValueSep, multiValues, defaultValue, skipEmpty } = this.init;
|
||||
const { multiValueSep, defaultValue, skipEmpty } = this.init;
|
||||
const value = this.parse(history.searchParams.getAsArray(urlName, multiValueSep));
|
||||
|
||||
if (skipEmpty && this.isEmpty(value)) {
|
||||
@@ -64,19 +64,23 @@ export class UrlParam<V = any | any[]> {
|
||||
}
|
||||
|
||||
set(value: V, { mergeGlobals = true, replaceHistory = false } = {}) {
|
||||
const search = this.toSearchString(value, { mergeGlobals });
|
||||
const search = this.toSearchString({ mergeGlobals, value });
|
||||
this.history.merge({ search }, replaceHistory);
|
||||
}
|
||||
|
||||
getDefaultValue(){
|
||||
return this.init.defaultValue;
|
||||
}
|
||||
|
||||
isDefault() {
|
||||
return this.get() === this.init.defaultValue;
|
||||
return this.get() === this.getDefaultValue();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.history.searchParams.delete(this.urlName);
|
||||
}
|
||||
|
||||
toSearchString(value = this.get(), { withPrefix = true, mergeGlobals = true } = {}): string {
|
||||
toSearchString({ withPrefix = true, mergeGlobals = true, value = this.get() } = {}): string {
|
||||
const { history, urlName, init: { skipEmpty } } = this;
|
||||
const searchParams = new URLSearchParams(mergeGlobals ? history.location.search : "");
|
||||
|
||||
|
||||
Reference in new issue
Block a user