Fixing up integration-react as well

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-10-27 11:51:43 +02:00
parent 52ebd2d3a0
commit 36e2b548cb
7 changed files with 66 additions and 21 deletions
@@ -254,6 +254,9 @@ export class ScmAuth implements ScmAuthApi {
return url.host === this.#host;
}
/**
* Fetches credentials for the given resource.
*/
async getCredentials(
options: ScmAuthTokenOptions,
): Promise<ScmAuthTokenResponse> {
@@ -20,7 +20,11 @@ import {
AuthRequestOptions,
} from '@backstage/core-plugin-api';
/** @public */
/**
* The options that control a {@link ScmAuthApi.getCredentials} call.
*
* @public
*/
export interface ScmAuthTokenOptions extends AuthRequestOptions {
/**
* The URL of the SCM resource to be accessed.
@@ -43,7 +47,11 @@ export interface ScmAuthTokenOptions extends AuthRequestOptions {
};
}
/** @public */
/**
* The response from a {@link ScmAuthApi.getCredentials} call.
*
* @public
*/
export interface ScmAuthTokenResponse {
/**
* An authorization token that can be used to authenticate requests.
@@ -21,12 +21,27 @@ import {
} from '@backstage/integration';
import { ApiRef, createApiRef } from '@backstage/core-plugin-api';
/**
* Factory class for creating {@link @backstage/integration#ScmIntegrationRegistry} instances.
*
* @public
*/
export class ScmIntegrationsApi {
/**
* Instantiates an {@link @backstage/integration#ScmIntegrationRegistry}.
*
* @param config - The root of the config hierarchy.
*/
static fromConfig(config: Config): ScmIntegrationRegistry {
return ScmIntegrations.fromConfig(config);
}
}
/**
* The API that holds all configured SCM integrations.
*
* @public
*/
export const scmIntegrationsApiRef: ApiRef<ScmIntegrationRegistry> =
createApiRef({
id: 'integration.scmintegrations',
@@ -17,7 +17,25 @@ import CodeIcon from '@material-ui/icons/Code';
import React from 'react';
import { useApp } from '@backstage/core-plugin-api';
export const ScmIntegrationIcon = ({ type }: { type?: string }) => {
/**
* Props for {@link ScmIntegrationIcon}.
*
* @public
*/
export type ScmIntegrationIconProps = {
/**
* The integration type, e.g. "github".
*/
type?: string;
};
/**
* An icon that represents a certain SCM integration.
*
* @public
*/
export const ScmIntegrationIcon = (props: ScmIntegrationIconProps) => {
const { type } = props;
const app = useApp();
const DefaultIcon = CodeIcon;
const Icon = type ? app.getSystemIcon(type) ?? DefaultIcon : DefaultIcon;
@@ -15,3 +15,4 @@
*/
export { ScmIntegrationIcon } from './ScmIntegrationIcon';
export type { ScmIntegrationIconProps } from './ScmIntegrationIcon';