Fix variable names of conflicting types

This commit is contained in:
Debajyoti Halder
2021-02-02 16:42:37 +05:30
parent e0fb5dfccf
commit 7717c46517
9 changed files with 27 additions and 44 deletions
@@ -13,12 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
AuthProvider,
ProfileInfo,
BackstageIdentity,
DiscoveryApi,
} from '../../apis/definitions';
import { AuthProvider, DiscoveryApi } from '../../apis/definitions';
import { showLoginPopup } from '../loginPopup';
type Options = {
@@ -26,13 +21,6 @@ type Options = {
environment?: string;
provider: AuthProvider & { id: string };
};
// export type DirectAuthResponse = {
// userId: string;
// profile: ProfileInfo;
// backstageIdentity: BackstageIdentity;
// };
export class DirectAuthConnector<DirectAuthResponse> {
private readonly discoveryApi: DiscoveryApi;
private readonly environment: string | undefined;
@@ -18,7 +18,7 @@
// This is just a temporary solution to implementing tabs for now
import React, { useState, useEffect } from 'react';
import { makeStyles, Tabs, Tab } from '@material-ui/core';
import { makeStyles, Tabs, Tab as TabUI } from '@material-ui/core';
const useStyles = makeStyles(theme => ({
tabsWrapper: {
@@ -38,13 +38,13 @@ const useStyles = makeStyles(theme => ({
},
}));
export type objectTab = {
export type Tab = {
id: string;
label: string;
};
type HeaderTabsProps = {
tabs: objectTab[];
tabs: Tab[];
onChange?: (index: number) => void;
selectedIndex?: number;
};
@@ -81,7 +81,7 @@ export const HeaderTabs = ({
value={selectedTab}
>
{tabs.map((tab, index) => (
<Tab
<TabUI
label={tab.label}
key={tab.id}
value={index}
@@ -215,21 +215,21 @@ describe('GithubCredentialsProvider tests', () => {
});
it('should return the default token if no app is configured', async () => {
const githubID = GithubCredentialsProvider.create({
const githubProvider = GithubCredentialsProvider.create({
host: 'github.com',
apps: [],
token: 'fallback_token',
});
await expect(
githubID.getCredentials({
githubProvider.getCredentials({
url: 'https://github.com/404/foobar',
}),
).resolves.toEqual(expect.objectContaining({ token: 'fallback_token' }));
});
it('should return the configured token if listing installations throws', async () => {
const githubID = GithubCredentialsProvider.create({
const githubProvider = GithubCredentialsProvider.create({
host: 'github.com',
apps: [
{
@@ -245,19 +245,19 @@ describe('GithubCredentialsProvider tests', () => {
octokit.apps.listInstallations.mockRejectedValue({ status: 304 });
await expect(
githubID.getCredentials({
githubProvider.getCredentials({
url: 'https://github.com/backstage',
}),
).resolves.toEqual(expect.objectContaining({ token: 'hardcoded_token' }));
});
it('should return undefined if no token or apps are configured', async () => {
const githubID = GithubCredentialsProvider.create({
const githubProvider = GithubCredentialsProvider.create({
host: 'github.com',
});
await expect(
githubID.getCredentials({
githubProvider.getCredentials({
url: 'https://github.com/backstage',
}),
).resolves.toEqual({ headers: undefined, token: undefined });
@@ -18,7 +18,7 @@ import React, { PropsWithChildren } from 'react';
import { Box, Typography } from '@material-ui/core';
import { useBarChartLabelStyles } from '../../utils/styles';
type BarChartLabelType = {
type BarChartLabelObject = {
x: number;
y: number;
height: number;
@@ -33,7 +33,7 @@ export const BarChartLabel = ({
width,
details,
children,
}: PropsWithChildren<BarChartLabelType>) => {
}: PropsWithChildren<BarChartLabelObject>) => {
const classes = useBarChartLabelStyles();
const translateX = width * -0.5;
@@ -18,7 +18,7 @@ import React from 'react';
import { ButtonBase } from '@material-ui/core';
import { useBarChartStepperStyles as useStyles } from '../../utils/styles';
export type BarChartStepsType = {
export type BarChartStepsObject = {
steps: number;
activeStep: number;
onClick: (index: number) => void;
@@ -28,7 +28,7 @@ export const BarChartSteps = ({
steps,
activeStep,
onClick,
}: BarChartStepsType) => {
}: BarChartStepsObject) => {
const classes = useStyles();
const handleOnClick = (index: number) => (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
@@ -85,26 +85,26 @@ export const ProductInsights = ({
async function getAllProductInsights(
groupId: string,
projectId: Maybe<string>,
productsId: Product[],
lastCompleteBillingDateId: string,
productIds: Product[],
lastCompleteBillingDateString: string,
) {
try {
dispatchLoadingProducts(true);
const responses = await Promise.allSettled(
productsId.map(product =>
productIds.map(product =>
client.getProductInsights({
group: groupId,
project: projectId,
product: product.kind,
intervals: intervalsOf(
DEFAULT_DURATION,
lastCompleteBillingDateId,
lastCompleteBillingDateString,
),
}),
),
).then(settledResponseOf);
const initialStatesNow = initialStatesOf(productsId, responses).sort(
const initialStatesNow = initialStatesOf(productIds, responses).sort(
totalAggregationSort,
);
setStates(initialStatesNow);
@@ -19,7 +19,7 @@ import {
Box,
Button,
Paper,
Step,
Step as StepUI,
StepContent,
StepLabel,
Stepper,
@@ -30,7 +30,7 @@ import { Theme as MuiTheme } from '@rjsf/material-ui';
import React, { useState } from 'react';
const Form = withTheme(MuiTheme);
type StepType = {
type Step = {
schema: JSONSchema;
label: string;
} & Partial<Omit<FormProps<any>, 'schema'>>;
@@ -39,7 +39,7 @@ type Props = {
/**
* Steps for the form, each contains label and form schema
*/
steps: StepType[];
steps: Step[];
formData: Record<string, any>;
onChange: (e: IChangeEvent) => void;
onReset: () => void;
@@ -67,7 +67,7 @@ export const MultistepJsonForm = ({
<>
<Stepper activeStep={activeStep} orientation="vertical">
{steps.map(({ label, schema, ...formProps }) => (
<Step key={label}>
<StepUI key={label}>
<StepLabel>{label}</StepLabel>
<StepContent key={label}>
<Form
@@ -89,7 +89,7 @@ export const MultistepJsonForm = ({
</Button>
</Form>
</StepContent>
</Step>
</StepUI>
))}
</Stepper>
{activeStep === steps.length && (
@@ -124,8 +124,8 @@ export const TemplatePage = () => {
const handleCreate = async () => {
try {
const Id = await scaffolderApi.scaffold(templateName, formState);
setJobId(Id);
const id = await scaffolderApi.scaffold(templateName, formState);
setJobId(id);
setModalOpen(true);
} catch (e) {
errorApi.post(e);
@@ -59,11 +59,6 @@ type TableHeaderProps = {
handleToggleFilters: () => void;
};
// type Filters = {
// selected: string;
// checked: Array<string | null>;
// };
// TODO: move out column to make the search result component more generic
const columns: TableColumn[] = [
{