move the settings storage to the user settings frontend
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
---
|
||||
'@backstage/core-app-api': minor
|
||||
'@backstage/plugin-user-settings-backend': minor
|
||||
---
|
||||
|
||||
Add new plugin `@backstage/user-settings-backend` to store user related settings
|
||||
in the database. Additionally adding a `UserSettingsStorage` implementation of
|
||||
the `StorageApi` to easily use the new plugin as drop-in replacement for the
|
||||
`WebStorage`.
|
||||
Added new plugin `@backstage/plugin-user-settings-backend` to store user related
|
||||
settings in the database.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-user-settings': patch
|
||||
---
|
||||
|
||||
Added a `UserSettingsStorage` implementation of the `StorageApi` for use as
|
||||
drop-in replacement for the `WebStorage`, in conjunction with the newly created
|
||||
`@backstage/plugin-user-settings-backend`.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/core-app-api': patch
|
||||
---
|
||||
|
||||
Clarify that the `WebStorage` observable returns `JsonValue` items.
|
||||
@@ -543,30 +543,6 @@ export class UrlPatternDiscovery implements DiscoveryApi {
|
||||
getBaseUrl(pluginId: string): Promise<string>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class UserSettingsStorage implements StorageApi {
|
||||
// (undocumented)
|
||||
static create(options: {
|
||||
fetchApi: FetchApi;
|
||||
discoveryApi: DiscoveryApi;
|
||||
errorApi: ErrorApi;
|
||||
identityApi: IdentityApi;
|
||||
namespace?: string;
|
||||
}): UserSettingsStorage;
|
||||
// (undocumented)
|
||||
forBucket(name: string): StorageApi;
|
||||
// (undocumented)
|
||||
observe$<T extends JsonValue>(
|
||||
key: string,
|
||||
): Observable<StorageValueSnapshot<T>>;
|
||||
// (undocumented)
|
||||
remove(key: string): Promise<void>;
|
||||
// (undocumented)
|
||||
set<T extends JsonValue>(key: string, data: T): Promise<void>;
|
||||
// (undocumented)
|
||||
snapshot<T extends JsonValue>(key: string): StorageValueSnapshot<T>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class WebStorage implements StorageApi {
|
||||
constructor(namespace: string, errorApi: ErrorApi);
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"dependencies": {
|
||||
"@backstage/config": "^1.0.2-next.0",
|
||||
"@backstage/core-plugin-api": "^1.0.6-next.3",
|
||||
"@backstage/errors": "^1.1.1-next.0",
|
||||
"@backstage/types": "^1.0.0",
|
||||
"@backstage/version-bridge": "^1.0.1",
|
||||
"@types/prop-types": "^15.7.3",
|
||||
|
||||
@@ -15,4 +15,3 @@
|
||||
*/
|
||||
|
||||
export { WebStorage } from './WebStorage';
|
||||
export { UserSettingsStorage } from './UserSettingsStorage';
|
||||
|
||||
@@ -57,7 +57,7 @@ To make use of the user settings backend, replace the `WebStorage` with the
|
||||
+ identityApi,
|
||||
+ storageApiRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
+import { UserSettingsStorage } from '@backstage/core-app-api';
|
||||
+import { UserSettingsStorage } from '@backstage/plugin-user-settings';
|
||||
|
||||
export const apis: AnyApiFactory[] = [
|
||||
+ createApiFactory({
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
Welcome to the user-settings plugin!
|
||||
|
||||
_This plugin was created through the Backstage CLI_
|
||||
|
||||
## About the plugin
|
||||
|
||||
This plugin provides two components, `<UserSettings />` is intended to be used within the [`<Sidebar>`](https://backstage.io/storybook/?path=/story/sidebar--sample-sidebar) and displays the signed-in users profile picture and name.
|
||||
This plugin provides two components, `<UserSettings />` is intended to be used within the [`<Sidebar>`](https://backstage.io/storybook/?path=/story/sidebar--sample-sidebar) and displays the signed-in users profile picture and name. The second component is a settings page where the user can control different settings across the App.
|
||||
|
||||
The second component is a settings page where the user can control different settings across the App.
|
||||
It also provides a `UserSettingsStorage` implementation of the `StorageApi`, to
|
||||
be used in the frontend as a persistent alternative to the builtin `WebStorage`.
|
||||
Please see [the backend
|
||||
README](https://github.com/backstage/backstage/tree/master/plugins/user-settings-backend)
|
||||
for installation instructions.
|
||||
|
||||
## Usage
|
||||
## Components Usage
|
||||
|
||||
Add the item to the Sidebar:
|
||||
|
||||
|
||||
@@ -8,11 +8,19 @@
|
||||
import { ApiRef } from '@backstage/core-plugin-api';
|
||||
import { BackstagePlugin } from '@backstage/core-plugin-api';
|
||||
import { BackstageUserIdentity } from '@backstage/core-plugin-api';
|
||||
import { DiscoveryApi } from '@backstage/core-plugin-api';
|
||||
import { ErrorApi } from '@backstage/core-plugin-api';
|
||||
import { FetchApi } from '@backstage/core-plugin-api';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { IdentityApi } from '@backstage/core-plugin-api';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { Observable } from '@backstage/types';
|
||||
import { ProfileInfo } from '@backstage/core-plugin-api';
|
||||
import { PropsWithChildren } from 'react';
|
||||
import { RouteRef } from '@backstage/core-plugin-api';
|
||||
import { SessionApi } from '@backstage/core-plugin-api';
|
||||
import { StorageApi } from '@backstage/core-plugin-api';
|
||||
import { StorageValueSnapshot } from '@backstage/core-plugin-api';
|
||||
|
||||
// @public (undocumented)
|
||||
export const DefaultProviderSettings: (props: {
|
||||
@@ -83,6 +91,30 @@ export const UserSettingsSignInAvatar: (props: {
|
||||
size?: number;
|
||||
}) => JSX.Element;
|
||||
|
||||
// @public
|
||||
export class UserSettingsStorage implements StorageApi {
|
||||
// (undocumented)
|
||||
static create(options: {
|
||||
fetchApi: FetchApi;
|
||||
discoveryApi: DiscoveryApi;
|
||||
errorApi: ErrorApi;
|
||||
identityApi: IdentityApi;
|
||||
namespace?: string;
|
||||
}): UserSettingsStorage;
|
||||
// (undocumented)
|
||||
forBucket(name: string): StorageApi;
|
||||
// (undocumented)
|
||||
observe$<T extends JsonValue>(
|
||||
key: string,
|
||||
): Observable<StorageValueSnapshot<T>>;
|
||||
// (undocumented)
|
||||
remove(key: string): Promise<void>;
|
||||
// (undocumented)
|
||||
set<T extends JsonValue>(key: string, data: T): Promise<void>;
|
||||
// (undocumented)
|
||||
snapshot<T extends JsonValue>(key: string): StorageValueSnapshot<T>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const UserSettingsTab: (props: UserSettingsTabProps) => JSX.Element;
|
||||
|
||||
|
||||
@@ -32,14 +32,18 @@
|
||||
"clean": "backstage-cli package clean"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/core-app-api": "^1.1.0-next.3",
|
||||
"@backstage/core-components": "^0.11.1-next.3",
|
||||
"@backstage/core-plugin-api": "^1.0.6-next.3",
|
||||
"@backstage/errors": "^1.1.1-next.0",
|
||||
"@backstage/theme": "^0.2.16",
|
||||
"@backstage/types": "^1.0.0",
|
||||
"@material-ui/core": "^4.12.2",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
"@material-ui/lab": "4.0.0-alpha.57",
|
||||
"@types/react": "^16.13.1 || ^17.0.0",
|
||||
"react-use": "^17.2.4"
|
||||
"react-use": "^17.2.4",
|
||||
"zen-observable": "^0.8.15"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.13.1 || ^17.0.0",
|
||||
@@ -47,7 +51,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.19.0-next.3",
|
||||
"@backstage/core-app-api": "^1.1.0-next.3",
|
||||
"@backstage/dev-utils": "^1.0.6-next.2",
|
||||
"@backstage/test-utils": "^1.2.0-next.3",
|
||||
"@testing-library/jest-dom": "^5.10.1",
|
||||
|
||||
+1
-1
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WebStorage } from '@backstage/core-app-api';
|
||||
import {
|
||||
DiscoveryApi,
|
||||
ErrorApi,
|
||||
@@ -25,7 +26,6 @@ import {
|
||||
import { ResponseError } from '@backstage/errors';
|
||||
import { JsonValue, Observable } from '@backstage/types';
|
||||
import ObservableImpl from 'zen-observable';
|
||||
import { WebStorage } from './WebStorage';
|
||||
|
||||
const JSON_HEADERS = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2020 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { UserSettingsStorage } from './UserSettingsStorage';
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './StorageApi';
|
||||
@@ -15,11 +15,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Backstage plugin that provides a settings page
|
||||
* A Backstage plugin that provides various per-user settings functionality.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export {
|
||||
userSettingsPlugin,
|
||||
userSettingsPlugin as plugin,
|
||||
|
||||
@@ -3291,7 +3291,6 @@ __metadata:
|
||||
"@backstage/cli": ^0.19.0-next.3
|
||||
"@backstage/config": ^1.0.2-next.0
|
||||
"@backstage/core-plugin-api": ^1.0.6-next.3
|
||||
"@backstage/errors": ^1.1.1-next.0
|
||||
"@backstage/test-utils": ^1.2.0-next.3
|
||||
"@backstage/types": ^1.0.0
|
||||
"@backstage/version-bridge": ^1.0.1
|
||||
@@ -7342,8 +7341,10 @@ __metadata:
|
||||
"@backstage/core-components": ^0.11.1-next.3
|
||||
"@backstage/core-plugin-api": ^1.0.6-next.3
|
||||
"@backstage/dev-utils": ^1.0.6-next.2
|
||||
"@backstage/errors": ^1.1.1-next.0
|
||||
"@backstage/test-utils": ^1.2.0-next.3
|
||||
"@backstage/theme": ^0.2.16
|
||||
"@backstage/types": ^1.0.0
|
||||
"@material-ui/core": ^4.12.2
|
||||
"@material-ui/icons": ^4.9.1
|
||||
"@material-ui/lab": 4.0.0-alpha.57
|
||||
@@ -7355,6 +7356,7 @@ __metadata:
|
||||
cross-fetch: ^3.1.5
|
||||
msw: ^0.47.0
|
||||
react-use: ^17.2.4
|
||||
zen-observable: ^0.8.15
|
||||
peerDependencies:
|
||||
react: ^16.13.1 || ^17.0.0
|
||||
react-router: 6.0.0-beta.0 || ^6.3.0
|
||||
|
||||
Reference in New Issue
Block a user