From 3cd9123a32ebc051574911fc626cf6d4f5473426 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 25 Jan 2022 09:11:48 +0100 Subject: [PATCH] chore: format with prettier Signed-off-by: Johan Haals --- .../src/providers/bitbucket/provider.ts | 62 ++++++++++--------- .../src/providers/github/provider.ts | 25 ++++---- .../src/providers/microsoft/provider.ts | 31 +++++----- .../src/providers/oidc/provider.ts | 25 ++++---- .../components/CostInsightsPage/selector.tsx | 31 +++++----- .../components/CostInsightsTabs/selector.ts | 34 +++++----- 6 files changed, 108 insertions(+), 100 deletions(-) diff --git a/plugins/auth-backend/src/providers/bitbucket/provider.ts b/plugins/auth-backend/src/providers/bitbucket/provider.ts index c83a195db5..ff203e0a9d 100644 --- a/plugins/auth-backend/src/providers/bitbucket/provider.ts +++ b/plugins/auth-backend/src/providers/bitbucket/provider.ts @@ -205,45 +205,47 @@ export class BitbucketAuthProvider implements OAuthHandlers { } } -export const bitbucketUsernameSignInResolver: SignInResolver = - async (info, ctx) => { - const { result } = info; +export const bitbucketUsernameSignInResolver: SignInResolver< + BitbucketOAuthResult +> = async (info, ctx) => { + const { result } = info; - if (!result.fullProfile.username) { - throw new Error('Bitbucket profile contained no Username'); - } + if (!result.fullProfile.username) { + throw new Error('Bitbucket profile contained no Username'); + } - const entity = await ctx.catalogIdentityClient.findUser({ - annotations: { - 'bitbucket.org/username': result.fullProfile.username, - }, - }); + const entity = await ctx.catalogIdentityClient.findUser({ + annotations: { + 'bitbucket.org/username': result.fullProfile.username, + }, + }); - const claims = getEntityClaims(entity); - const token = await ctx.tokenIssuer.issueToken({ claims }); + const claims = getEntityClaims(entity); + const token = await ctx.tokenIssuer.issueToken({ claims }); - return { id: entity.metadata.name, entity, token }; - }; + return { id: entity.metadata.name, entity, token }; +}; -export const bitbucketUserIdSignInResolver: SignInResolver = - async (info, ctx) => { - const { result } = info; +export const bitbucketUserIdSignInResolver: SignInResolver< + BitbucketOAuthResult +> = async (info, ctx) => { + const { result } = info; - if (!result.fullProfile.id) { - throw new Error('Bitbucket profile contained no User ID'); - } + if (!result.fullProfile.id) { + throw new Error('Bitbucket profile contained no User ID'); + } - const entity = await ctx.catalogIdentityClient.findUser({ - annotations: { - 'bitbucket.org/user-id': result.fullProfile.id, - }, - }); + const entity = await ctx.catalogIdentityClient.findUser({ + annotations: { + 'bitbucket.org/user-id': result.fullProfile.id, + }, + }); - const claims = getEntityClaims(entity); - const token = await ctx.tokenIssuer.issueToken({ claims }); + const claims = getEntityClaims(entity); + const token = await ctx.tokenIssuer.issueToken({ claims }); - return { id: entity.metadata.name, entity, token }; - }; + return { id: entity.metadata.name, entity, token }; +}; export type BitbucketProviderOptions = { /** diff --git a/plugins/auth-backend/src/providers/github/provider.ts b/plugins/auth-backend/src/providers/github/provider.ts index 220ec4fcce..7a96b039f4 100644 --- a/plugins/auth-backend/src/providers/github/provider.ts +++ b/plugins/auth-backend/src/providers/github/provider.ts @@ -184,21 +184,22 @@ export class GithubAuthProvider implements OAuthHandlers { } } -export const githubDefaultSignInResolver: SignInResolver = - async (info, ctx) => { - const { fullProfile } = info.result; +export const githubDefaultSignInResolver: SignInResolver< + GithubOAuthResult +> = async (info, ctx) => { + const { fullProfile } = info.result; - const userId = fullProfile.username || fullProfile.id; + const userId = fullProfile.username || fullProfile.id; - const token = await ctx.tokenIssuer.issueToken({ - claims: { - sub: `user:default/${userId}`, - ent: [`user:default/${userId}`], - }, - }); + const token = await ctx.tokenIssuer.issueToken({ + claims: { + sub: `user:default/${userId}`, + ent: [`user:default/${userId}`], + }, + }); - return { id: userId, token }; - }; + return { id: userId, token }; +}; export type GithubProviderOptions = { /** diff --git a/plugins/auth-backend/src/providers/microsoft/provider.ts b/plugins/auth-backend/src/providers/microsoft/provider.ts index 2d4a53b076..b4ef30f491 100644 --- a/plugins/auth-backend/src/providers/microsoft/provider.ts +++ b/plugins/auth-backend/src/providers/microsoft/provider.ts @@ -220,25 +220,26 @@ export const microsoftEmailSignInResolver: SignInResolver = async ( return { id: entity.metadata.name, entity, token }; }; -export const microsoftDefaultSignInResolver: SignInResolver = - async (info, ctx) => { - const { profile } = info; +export const microsoftDefaultSignInResolver: SignInResolver< + OAuthResult +> = async (info, ctx) => { + const { profile } = info; - if (!profile.email) { - throw new Error('Profile contained no email'); - } + if (!profile.email) { + throw new Error('Profile contained no email'); + } - const userId = profile.email.split('@')[0]; + const userId = profile.email.split('@')[0]; - const token = await ctx.tokenIssuer.issueToken({ - claims: { - sub: `user:default/${userId}`, - ent: [`user:default/${userId}`], - }, - }); + const token = await ctx.tokenIssuer.issueToken({ + claims: { + sub: `user:default/${userId}`, + ent: [`user:default/${userId}`], + }, + }); - return { id: userId, token }; - }; + return { id: userId, token }; +}; export type MicrosoftProviderOptions = { /** diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index ab95495619..5ffbf070bd 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -211,19 +211,20 @@ export class OidcAuthProvider implements OAuthHandlers { } } -export const oAuth2DefaultSignInResolver: SignInResolver = - async (info, ctx) => { - const { profile } = info; +export const oAuth2DefaultSignInResolver: SignInResolver< + OidcAuthResult +> = async (info, ctx) => { + const { profile } = info; - if (!profile.email) { - throw new Error('Profile contained no email'); - } - const userId = profile.email.split('@')[0]; - const token = await ctx.tokenIssuer.issueToken({ - claims: { sub: userId, ent: [`user:default/${userId}`] }, - }); - return { id: userId, token }; - }; + if (!profile.email) { + throw new Error('Profile contained no email'); + } + const userId = profile.email.split('@')[0]; + const token = await ctx.tokenIssuer.issueToken({ + claims: { sub: userId, ent: [`user:default/${userId}`] }, + }); + return { id: userId, token }; +}; /** * OIDC provider callback options. An auth handler and a sign in resolver diff --git a/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx b/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx index d9591dbdd6..e90dba4ed7 100644 --- a/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx +++ b/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx @@ -31,18 +31,19 @@ type CostInsightsPageLoadingProps = { dispatchReset: (loadingActions: string[]) => void; }; -export const mapLoadingToProps: MapLoadingToProps = - ({ state, actions, dispatch }) => ({ - loadingActions: actions, - loadingGroups: state[DefaultLoadingAction.UserGroups], - loadingBillingDate: state[DefaultLoadingAction.LastCompleteBillingDate], - loadingInitial: state[DefaultLoadingAction.CostInsightsInitial], - dispatchInitial: (isLoading: boolean) => - dispatch({ [DefaultLoadingAction.CostInsightsInitial]: isLoading }), - dispatchInsights: (isLoading: boolean) => - dispatch({ [DefaultLoadingAction.CostInsightsPage]: isLoading }), - dispatchNone: (loadingActions: string[]) => - dispatch(getResetState(loadingActions)), - dispatchReset: (loadingActions: string[]) => - dispatch(getResetStateWithoutInitial(loadingActions)), - }); +export const mapLoadingToProps: MapLoadingToProps< + CostInsightsPageLoadingProps +> = ({ state, actions, dispatch }) => ({ + loadingActions: actions, + loadingGroups: state[DefaultLoadingAction.UserGroups], + loadingBillingDate: state[DefaultLoadingAction.LastCompleteBillingDate], + loadingInitial: state[DefaultLoadingAction.CostInsightsInitial], + dispatchInitial: (isLoading: boolean) => + dispatch({ [DefaultLoadingAction.CostInsightsInitial]: isLoading }), + dispatchInsights: (isLoading: boolean) => + dispatch({ [DefaultLoadingAction.CostInsightsPage]: isLoading }), + dispatchNone: (loadingActions: string[]) => + dispatch(getResetState(loadingActions)), + dispatchReset: (loadingActions: string[]) => + dispatch(getResetStateWithoutInitial(loadingActions)), +}); diff --git a/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts b/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts index 59b1c9549c..6309016c85 100644 --- a/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts +++ b/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts @@ -28,20 +28,22 @@ type CostInsightsTabsLoadingProps = { dispatchReset: (loadingActions: string[]) => void; }; -export const mapFiltersToProps: MapFiltersToProps = - ({ pageFilters, setPageFilters }) => ({ - ...pageFilters, - setGroup: (group: Group) => - setPageFilters({ - ...pageFilters, - group: group.id, - project: null, - }), - }); +export const mapFiltersToProps: MapFiltersToProps< + CostInsightsTabsFilterProps +> = ({ pageFilters, setPageFilters }) => ({ + ...pageFilters, + setGroup: (group: Group) => + setPageFilters({ + ...pageFilters, + group: group.id, + project: null, + }), +}); -export const mapLoadingToProps: MapLoadingToProps = - ({ actions, dispatch }) => ({ - loadingActions: actions, - dispatchReset: (loadingActions: string[]) => - dispatch(getResetStateWithoutInitial(loadingActions)), - }); +export const mapLoadingToProps: MapLoadingToProps< + CostInsightsTabsLoadingProps +> = ({ actions, dispatch }) => ({ + loadingActions: actions, + dispatchReset: (loadingActions: string[]) => + dispatch(getResetStateWithoutInitial(loadingActions)), +});