mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Extract sidebar item injection token into separate package
- Add unit tests to cover custom resources sidebar items Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
d28da8e7ac
commit
500ac15703
113 files changed
+5643
-1679
No files matched your search
@@ -5,7 +5,7 @@ export * from "./src/base64";
|
||||
export * from "./src/buildUrl";
|
||||
export * from "./src/camelCase";
|
||||
export * from "./src/collection-functions";
|
||||
export * from "./src/computed-or";
|
||||
export * from "./src/computed-helpers";
|
||||
export * from "./src/convertCpu";
|
||||
export * from "./src/convertMemory";
|
||||
export * from "./src/cssNames";
|
||||
@@ -28,6 +28,7 @@ export * from "./src/noop";
|
||||
export * from "./src/object";
|
||||
export * from "./src/observable-crate";
|
||||
export * from "./src/on-keyboard-shortcut";
|
||||
export * from "./src/orderable";
|
||||
export * from "./src/prevDefault";
|
||||
export * from "./src/readableStream";
|
||||
export * from "./src/readonly";
|
||||
|
||||
+4
@@ -9,3 +9,7 @@ import { computed } from "mobx";
|
||||
export const computedOr = (...values: IComputedValue<boolean>[]) => computed((
|
||||
() => values.some(value => value.get())
|
||||
));
|
||||
|
||||
export const computedAnd = (...values: IComputedValue<boolean>[]) => computed((
|
||||
() => values.every(value => value.get())
|
||||
));
|
||||
@@ -11,7 +11,7 @@ interface Iterator<T> extends Iterable<T> {
|
||||
find(fn: (val: T) => unknown): T | undefined;
|
||||
collect<U>(fn: (values: Iterable<T>) => U): U;
|
||||
toArray(): T[];
|
||||
toMap(): T extends [infer K, infer V] ? Map<K, V> : never;
|
||||
toMap(): T extends readonly [infer K, infer V] ? Map<K, V[]> : never;
|
||||
toSet(): Set<T>;
|
||||
map<U>(fn: (val: T) => U): Iterator<U>;
|
||||
flatMap<U>(fn: (val: T) => U[]): Iterator<U>;
|
||||
@@ -30,7 +30,22 @@ function chain<T>(src: IterableIterator<T>): Iterator<T> {
|
||||
join: (sep) => join(src, sep),
|
||||
collect: (fn) => fn(src),
|
||||
toArray: () => [...src],
|
||||
toMap: () => new Map(src as IterableIterator<[any, any]>) as any,
|
||||
toMap: () => {
|
||||
const res = new Map();
|
||||
|
||||
for (const item of src[Symbol.iterator]()) {
|
||||
const [key, val] = item as [unknown, unknown];
|
||||
const existing = res.get(key);
|
||||
|
||||
if (existing) {
|
||||
existing.push(val);
|
||||
} else {
|
||||
res.set(key, [val]);
|
||||
}
|
||||
}
|
||||
|
||||
return res as T extends readonly [infer K, infer V] ? Map<K, V[]> : never;
|
||||
},
|
||||
toSet: () => new Set(src),
|
||||
concat: (src2) => chain(concat(src, src2)),
|
||||
take: (count) => chain(take(src, count)),
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* The Orderable interface is used to define an object that has an order number.
|
||||
*/
|
||||
export interface Orderable {
|
||||
readonly orderNumber: number;
|
||||
}
|
||||
|
||||
export interface MaybeOrderable {
|
||||
readonly orderNumber?: number;
|
||||
}
|
||||
|
||||
export const byOrderNumber = <T extends MaybeOrderable>(left: T, right: T) => (
|
||||
(left.orderNumber ?? Number.MAX_SAFE_INTEGER) - (right.orderNumber ?? Number.MAX_SAFE_INTEGER)
|
||||
);
|
||||
Reference in new issue
Block a user