Skip to content

Commit

Permalink
[AXON-45] First approximation of API token auth for JIRA
Browse files Browse the repository at this point in the history
  • Loading branch information
sdzh-atlassian committed Jan 16, 2025
1 parent c1998d4 commit ddb7197
Show file tree
Hide file tree
Showing 9 changed files with 779 additions and 551 deletions.
2 changes: 1 addition & 1 deletion src/react/atlascode/config/ConfigPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ConfigControllerContext, useConfigController } from './configController
import { ConfigSection, ConfigSubSection, ConfigTarget } from '../../../lib/ipc/models/config';
import React, { useCallback, useEffect, useState } from 'react';

import { AuthDialog } from './auth/AuthDialog';
import { AuthDialog } from './auth/dialog/AuthDialog';
import { BitbucketPanel } from './bitbucket/BitbucketPanel';
import { ErrorDisplay } from '../common/ErrorDisplay';
import { ExplorePanel } from './explore/ExplorePanel';
Expand Down
510 changes: 0 additions & 510 deletions src/react/atlascode/config/auth/AuthDialog.tsx

This file was deleted.

145 changes: 106 additions & 39 deletions src/react/atlascode/config/auth/SiteAuthenticator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { memo, useCallback, useContext } from 'react';
import { AuthDialogControllerContext } from './useAuthDialog';
import { CloudAuthButton } from './CloudAuthButton';
import DomainIcon from '@material-ui/icons/Domain';
import { Product } from '../../../../atlclients/authInfo';
import { Product, ProductJira } from '../../../../atlclients/authInfo';
import { SiteList } from './SiteList';
import { SiteWithAuthInfo } from '../../../../lib/ipc/toUI/config';
import { Features } from 'src/util/featureFlags';
Expand Down Expand Up @@ -47,46 +47,113 @@ export const SiteAuthenticator: React.FunctionComponent<SiteAuthenticatorProps>
return (
<Box flexGrow={1}>
<Grid container direction="column" spacing={2}>
<Grid item hidden={isRemote === false || useNewAuth}>
<Typography>
<Box component="span" fontWeight="fontWeightBold">
⚠️ Authentication cannot be done while running remotely
</Box>
</Typography>
<Typography>
To authenticate with a new site open this (or another) workspace locally. Accounts added
when running locally <em>will</em> be accessible during remote development.
</Typography>
</Grid>
<Grid item style={{ cursor: isRemote && !useNewAuth ? 'not-allowed' : 'default' }}>
<Grid
container
direction="column"
spacing={2}
style={{
pointerEvents: isRemote && !useNewAuth ? 'none' : 'inherit',
opacity: isRemote && !useNewAuth ? 0.6 : 'inherit',
}}
>
<Grid item>
<Grid container spacing={2}>
<Grid item>
<CloudAuthButton product={product} />
</Grid>
<Grid item>
<Button color="primary" startIcon={<DomainIcon />} onClick={openProductAuth}>
{`Add Custom ${product.name} Site`}
</Button>
</Grid>
</Grid>
</Grid>
<Grid item>
<SiteList product={product} sites={sites} editServer={handleEdit} />
</Grid>
</Grid>
</Grid>
{useNewAuth && product.key === ProductJira.key ? (
<AuthContainer
isRemote={isRemote}
product={product}
openProductAuth={openProductAuth}
sites={sites}
handleEdit={handleEdit}
/>
) : (
<LegacyAuthContainer
isRemote={isRemote}
product={product}
openProductAuth={openProductAuth}
sites={sites}
handleEdit={handleEdit}
/>
)}
</Grid>
</Box>
);
},
);

interface AuthContainerProps {
isRemote: boolean;
product: Product;
openProductAuth: () => void;
sites: SiteWithAuthInfo[];
handleEdit: (swa: SiteWithAuthInfo) => void;
}

const LegacyAuthContainer = ({ isRemote, product, openProductAuth, sites, handleEdit }: AuthContainerProps) => (
<React.Fragment>
<Grid item hidden={isRemote === false}>
<Typography>
<Box component="span" fontWeight="fontWeightBold">
⚠️ Authentication cannot be done while running remotely
</Box>
</Typography>
<Typography>
To authenticate with a new site open this (or another) workspace locally. Accounts added when running
locally <em>will</em> be accessible during remote development.
</Typography>
</Grid>
<Grid item style={{ cursor: isRemote ? 'not-allowed' : 'default' }}>
<Grid
container
direction="column"
spacing={2}
style={{
pointerEvents: isRemote ? 'none' : 'inherit',
opacity: isRemote ? 0.6 : 'inherit',
}}
>
<Grid item>
<Grid container spacing={2}>
<Grid item>
<CloudAuthButton product={product} />
</Grid>
<Grid item>
<Button color="primary" startIcon={<DomainIcon />} onClick={openProductAuth}>
{`Add Custom ${product.name} Site`}
</Button>
</Grid>
</Grid>
</Grid>
<Grid item>
<SiteList product={product} sites={sites} editServer={handleEdit} />
</Grid>
</Grid>
</Grid>
</React.Fragment>
);

const AuthContainer = ({ isRemote, product, openProductAuth, sites, handleEdit }: AuthContainerProps) => (
<React.Fragment>
<Grid item>
<Grid container direction="column" spacing={2}>
<Grid item>
<Grid container spacing={2}>
{!isRemote && (
<React.Fragment>
<Grid item>
<CloudAuthButton product={product} />
</Grid>
<Grid item>
<Button color="primary" onClick={openProductAuth}>
{`Other options...`}
</Button>
</Grid>
</React.Fragment>
)}
{isRemote && (
<React.Fragment>
<Grid item>
<Button color="primary" variant="contained" onClick={openProductAuth}>
{`Login to ${product.name}`}
</Button>
</Grid>
</React.Fragment>
)}
</Grid>
</Grid>
<Grid item>
<SiteList product={product} sites={sites} editServer={handleEdit} />
</Grid>
</Grid>
</Grid>
</React.Fragment>
);
Loading

0 comments on commit ddb7197

Please sign in to comment.