1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: extract to @k8slens/routing

Signed-off-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
Gabriel 2023-04-24 14:38:09 +02:00
parent 9af5159706
commit 15965b71f6
14 changed files with 262 additions and 1 deletions

76
package-lock.json generated
View File

@ -3991,6 +3991,10 @@
"resolved": "packages/resource-templates",
"link": true
},
"node_modules/@k8slens/routing": {
"resolved": "packages/routing",
"link": true
},
"node_modules/@k8slens/run-many": {
"resolved": "packages/utility-features/run-many",
"link": true
@ -36955,6 +36959,76 @@
"version": "1.0.0-alpha.0",
"license": "MIT"
},
"packages/routing": {
"name": "@k8slens/routing",
"version": "1.0.0-alpha.0",
"license": "MIT",
"dependencies": {
"@ogre-tools/injectable": "^15.3.1",
"@ogre-tools/injectable-react": "^15.3.0",
"history": "^4.10.1",
"mobx-observable-history": "^2.0.3"
},
"devDependencies": {
"@async-fn/jest": "^1.6.4",
"@k8slens/eslint-config": "6.5.0-alpha.1",
"@k8slens/react-testing-library-discovery": "^1.0.0-alpha.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^12.8.3"
},
"peerDependencies": {
"auto-bind": "^4.0.0",
"lodash": "^4.17.21",
"mobx": "^6.8.0",
"mobx-react": "^7.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
},
"packages/routing/node_modules/@k8slens/eslint-config": {
"version": "6.5.0-alpha.1",
"resolved": "https://registry.npmjs.org/@k8slens/eslint-config/-/eslint-config-6.5.0-alpha.1.tgz",
"integrity": "sha512-6DdfKe/iafX85GBK/UlKgz29FOIOp/UVS03bFGLyw7Vmm7pauB0FEHTAdbr3g1qG/Zcn6nxhOM3uqQyRY/uEyA==",
"dev": true,
"bin": {
"lens-lint": "bin/lint"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">= 5",
"@typescript-eslint/parser": ">= 5",
"eslint": ">= 7",
"eslint-config-airbnb-typescript": ">= 17",
"eslint-config-prettier": ">= 8",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-import": ">= 2",
"eslint-plugin-jest": ">= 27",
"eslint-plugin-jsx-a11y": ">= 6",
"eslint-plugin-no-unsanitized": ">= 4.0.2",
"eslint-plugin-prettier": ">= 4",
"eslint-plugin-react-hooks": ">= 4",
"eslint-plugin-security": ">= 1.6.0",
"eslint-plugin-simple-import-sort": ">= 7",
"eslint-plugin-unused-imports": ">= 2",
"eslint-plugin-xss": ">= 0.1.12",
"prettier": ">= 2"
}
},
"packages/routing/node_modules/@testing-library/user-event": {
"version": "12.8.3",
"resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.8.3.tgz",
"integrity": "sha512-IR0iWbFkgd56Bu5ZI/ej8yQwrkCv8Qydx6RzwbKz9faXazR/+5tvYKsZQgyXJiwgpcva127YO6JcWy7YlCfofQ==",
"dev": true,
"dependencies": {
"@babel/runtime": "^7.12.5"
},
"engines": {
"node": ">=10",
"npm": ">=6"
},
"peerDependencies": {
"@testing-library/dom": ">=7.21.4"
}
},
"packages/semver": {
"name": "@k8slens/semver",
"version": "6.5.0-alpha.4",
@ -37234,6 +37308,7 @@
},
"peerDependencies": {
"@k8slens/button": "^1.0.0-alpha.1",
"@k8slens/routing": "^1.0.0-alpha.0",
"@k8slens/utilities": "^1.0.0-alpha.1",
"auto-bind": "^4.0.0",
"lodash": "^4.17.21",
@ -37284,7 +37359,6 @@
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/@ogre-tools/injectable/-/injectable-12.0.1.tgz",
"integrity": "sha512-uOx8STN2wSc9hknDSTGqViyR89Vwg7rGacwrVNchgyo48/QJsmZZz6cd1Aw3nT4vr7ekjTc2lh0Rz6zGIv47hg==",
"peer": true,
"peerDependencies": {
"@ogre-tools/fp": "^12.0.0",
"lodash": "^4.17.21"

View File

@ -0,0 +1,6 @@
{
"extends": "@k8slens/eslint-config/eslint",
"parserOptions": {
"project": "./tsconfig.json"
}
}

19
packages/routing/.swcrc Normal file
View File

@ -0,0 +1,19 @@
{
"module": {
"type": "commonjs"
},
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": false
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"target": "es2019"
}
}

View File

@ -0,0 +1,20 @@
# @k8slens/error-boundary
This package contains stuff related to creating Lens-applications.
# Usage
```bash
$ npm install @k8slens/error-boundary
```
```typescript
import { Tooltip, TooltipPosition } from "@k8slens/error-boundary";
import { withTooltip } from "@k8slens/error-boundary";
import type { TooltipProps } from "@k8slens/error-boundary";
import type { TooltipDecoratorProps } from "@k8slens/error-boundary";
```
## Extendability

View File

@ -0,0 +1,2 @@
export * from "./src/observable-history.injectable";

View File

@ -0,0 +1,3 @@
const { configForReact } = require("@k8slens/jest").monorepoPackageConfig(__dirname);
module.exports = configForReact;

View File

@ -0,0 +1,52 @@
{
"name": "@k8slens/routing",
"private": false,
"version": "1.0.0-alpha.0",
"description": "Highly extendable error-boundary in the Lens.",
"type": "commonjs",
"files": [
"dist"
],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/lens.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": {
"name": "OpenLens Authors",
"email": "info@k8slens.dev"
},
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
"scripts": {
"build": "webpack",
"lint": "lens-lint",
"lint:fix": "lens-lint --fix"
},
"dependencies": {
"@ogre-tools/injectable": "^15.3.1",
"@ogre-tools/injectable-react": "^15.3.0",
"history": "^4.10.1",
"mobx-observable-history": "^2.0.3"
},
"peerDependencies": {
"auto-bind": "^4.0.0",
"lodash": "^4.17.21",
"mobx": "^6.8.0",
"mobx-react": "^7.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@async-fn/jest": "^1.6.4",
"@k8slens/eslint-config": "6.5.0-alpha.1",
"@k8slens/react-testing-library-discovery": "^1.0.0-alpha.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^12.8.3"
}
}

View File

@ -0,0 +1,14 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { createBrowserHistory } from "history";
import type { History } from "history";
const historyInjectable = getInjectable({
id: "history",
instantiate: (): History => createBrowserHistory(),
});
export default historyInjectable;

View File

@ -0,0 +1,23 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { createObservableHistory } from "mobx-observable-history";
import { searchParamsOptions } from "./search-params";
import historyInjectable from "./history.injectable";
const observableHistoryInjectable = getInjectable({
id: "observable-history",
instantiate: (di) => {
const history = di.inject(historyInjectable);
const navigation = createObservableHistory(history, {
searchParams: searchParamsOptions,
});
return navigation;
},
});
export default observableHistoryInjectable;

View File

@ -0,0 +1,12 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { ObservableSearchParamsOptions } from "mobx-observable-history";
export const searchParamsOptions: ObservableSearchParamsOptions = {
skipEmpty: true, // skip empty params, e.g. "?x=&y2=" will be "?y=2"
joinArrays: false, // join multiple params with same name, e.g. "?x=1&x=2" => "?x=1,2"
joinArraysWith: ",", // param values splitter, applicable only with {joinArrays:true}
};

View File

@ -0,0 +1,30 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
const path = require('path');
module.exports = {
content: [
path.join(__dirname, "src/**/*.tsx")
],
darkMode: "class",
theme: {
fontFamily: {
sans: ["Roboto", "Helvetica", "Arial", "sans-serif"],
},
extend: {
colors: {
textAccent: "var(--textColorAccent)",
textPrimary: "var(--textColorPrimary)",
textTertiary: "var(--textColorTertiary)",
textDimmed: "var(--textColorDimmed)",
},
},
},
variants: {
extend: {},
},
plugins: [],
};

View File

@ -0,0 +1,4 @@
{
"extends": "@k8slens/typescript/config/base.json",
"include": ["**/*.ts", "**/*.tsx"],
}

View File

@ -0,0 +1 @@
module.exports = require("@k8slens/webpack").configForReact;

View File

@ -37,6 +37,7 @@
"peerDependencies": {
"@k8slens/button": "^1.0.0-alpha.1",
"@k8slens/utilities": "^1.0.0-alpha.1",
"@k8slens/routing": "^1.0.0-alpha.0",
"auto-bind": "^4.0.0",
"lodash": "^4.17.21",
"mobx": "^6.8.0",