Skip to content

Commit

Permalink
Merge branch 'master' into snyk-upgrade-5efe5ab918e6d61413bd1d1193add540
Browse files Browse the repository at this point in the history
  • Loading branch information
satr authored Feb 27, 2024
2 parents 03c32e2 + d51f3d3 commit 0e777d1
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 77 deletions.
3 changes: 2 additions & 1 deletion docker-compose-host-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ services:
- "8080:8080"

auth:
image: quay.io/oauth2-proxy/oauth2-proxy:v7.2.1
image: quay.io/oauth2-proxy/oauth2-proxy:v7.6.0
container_name: radix-auth_container
environment:
# See the `radixconfig.yaml` file for a description of these settings
Expand All @@ -67,6 +67,7 @@ services:
- OAUTH2_PROXY_EMAIL_DOMAINS=*
- OAUTH2_PROXY_HTTP_ADDRESS=http://:8000
- OAUTH2_PROXY_OIDC_ISSUER_URL=https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0/v2.0
- OAUTH2_PROXY_SKIP_CLAIMS_FROM_PROFILE_URL=true
- OAUTH2_PROXY_PASS_ACCESS_TOKEN=true
- OAUTH2_PROXY_PASS_BASIC_AUTH=false
- OAUTH2_PROXY_PASS_USER_HEADERS=false
Expand Down
3 changes: 2 additions & 1 deletion docker-compose-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
- "8080:8080"

auth:
image: quay.io/oauth2-proxy/oauth2-proxy:v7.2.1
image: quay.io/oauth2-proxy/oauth2-proxy:v7.6.0
container_name: radix-auth_container
environment:
# See the `radixconfig.yaml` file for a description of these settings
Expand All @@ -49,6 +49,7 @@ services:
- OAUTH2_PROXY_EMAIL_DOMAINS=*
- OAUTH2_PROXY_HTTP_ADDRESS=http://:8000
- OAUTH2_PROXY_OIDC_ISSUER_URL=https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0/v2.0
- OAUTH2_PROXY_SKIP_CLAIMS_FROM_PROFILE_URL=true
- OAUTH2_PROXY_PASS_ACCESS_TOKEN=true
- OAUTH2_PROXY_PASS_BASIC_AUTH=false
- OAUTH2_PROXY_PASS_USER_HEADERS=false
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
- "8080:8080"

auth:
image: quay.io/oauth2-proxy/oauth2-proxy:v7.2.1
image: quay.io/oauth2-proxy/oauth2-proxy:v7.6.0
container_name: radix-auth_container
environment:
# See the `radixconfig.yaml` file for a description of these settings
Expand All @@ -53,6 +53,7 @@ services:
- OAUTH2_PROXY_EMAIL_DOMAINS=*
- OAUTH2_PROXY_HTTP_ADDRESS=http://:8000
- OAUTH2_PROXY_OIDC_ISSUER_URL=https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0/v2.0
- OAUTH2_PROXY_SKIP_CLAIMS_FROM_PROFILE_URL=true
- OAUTH2_PROXY_PASS_ACCESS_TOKEN=true
- OAUTH2_PROXY_PASS_BASIC_AUTH=false
- OAUTH2_PROXY_PASS_USER_HEADERS=false
Expand Down
3 changes: 2 additions & 1 deletion radixconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spec:
- DYNATRACE_API_TOKEN # Token to use for display of availability metrics
- OAUTH2_CLIENT_ID # Azure Application ID
- name: auth
image: quay.io/oauth2-proxy/oauth2-proxy:v7.2.1 # see https://github.com/oauth2-proxy/oauth2-proxy/blob/master/docs/docs/configuration/overview.md
image: quay.io/oauth2-proxy/oauth2-proxy:v7.6.0 # see https://github.com/oauth2-proxy/oauth2-proxy/blob/master/docs/docs/configuration/overview.md
ports:
- name: http
port: 8000
Expand All @@ -63,6 +63,7 @@ spec:
OAUTH2_PROXY_EMAIL_DOMAINS: "*" # Any email address registered in AD should be accepted
OAUTH2_PROXY_HTTP_ADDRESS: "http://:8000" # The port oauth2_proxy listens on
OAUTH2_PROXY_OIDC_ISSUER_URL: "https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0/v2.0" # That's the Equinor tenant ID
OAUTH2_PROXY_SKIP_CLAIMS_FROM_PROFILE_URL: "true"
OAUTH2_PROXY_PASS_ACCESS_TOKEN: "true" # Pass the access token upstream (to the proxy component)
OAUTH2_PROXY_PASS_BASIC_AUTH: "false" # Disable unused default
OAUTH2_PROXY_PASS_USER_HEADERS: "false" # Disable unused default
Expand Down
39 changes: 17 additions & 22 deletions src/components/app-config-ci/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Typography } from '@equinor/eds-core-react';
import { debounce } from 'lodash';
import * as PropTypes from 'prop-types';
import { useRef, useState } from 'react';
import { MultiValue, SingleValue, StylesConfig } from 'react-select';
import { useEffect, useRef, useState } from 'react';
import { MultiValue, SingleValue } from 'react-select';

import { ConfigurationItemPopover } from './ci-popover';
import { ConfigurationItemSelect } from './ci-select';
Expand All @@ -16,7 +16,7 @@ import {
GetApplicationsApiResponse,
Application,
} from '../../store/service-now-api';
import { getFetchErrorCode, getFetchErrorMessage } from '../../store/utils';
import { getFetchErrorMessage } from '../../store/utils';

export type OnConfigurationItemChangeCallback = (ci?: Application) => void;
type GetApplicationsFunction = ReturnType<
Expand Down Expand Up @@ -49,34 +49,30 @@ export function AppConfigConfigurationItem({
configurationItemChangeCallback,
disabled,
}: Props) {
const [currentCI, setCurrentCI] = useState<Application | null>(null);
const [selectedCI, setSelectedCI] = useState<Application | null>(null);
const [popoverCI, setPopoverCI] = useState<Application>();
const [popoverOpen, setPopoverOpen] = useState(false);
const [getApplications] =
serviceNowApi.endpoints.getApplications.useLazyQuery();

const { data, ...state } = useGetApplicationQuery({
appId: configurationItem,
});
const { data: currentCI, ...currentCIState } = useGetApplicationQuery(
{
appId: configurationItem,
},
{ skip: !configurationItem }
);

useEffect(() => {
setSelectedCI(currentCI);
}, [currentCI]);
const containerRef = useRef<HTMLDivElement>(null);

function onChange(newValue?: Application): void {
configurationItemChangeCallback(newValue);
setCurrentCI(newValue);
setSelectedCI(newValue);
setPopoverOpen(false);
}

const selectStyle: StylesConfig = {
singleValue: (styles) => {
if (state.error && getFetchErrorCode(state.error) === 404) {
styles.backgroundColor = 'var(--eds_interactive_danger__highlight)';
styles.color = 'var(--eds_interactive_danger__text)';
}
return styles;
},
};

return (
<div className="configuration-item-select">
<Typography className="label" group="input" variant="text">
Expand All @@ -93,7 +89,6 @@ export function AppConfigConfigurationItem({
setPopoverOpen(!popoverOpen);
}}
containerRef={containerRef}
styles={selectStyle}
name="ConfigurationItem"
menuPosition="fixed"
closeMenuOnScroll={({ target }: Event) =>
Expand All @@ -110,18 +105,18 @@ export function AppConfigConfigurationItem({
getOptionValue={({ id }) => id}
isClearable
closeMenuOnSelect={false}
value={currentCI || data}
value={selectedCI}
isDisabled={disabled}
/>
<Typography className="helpertext" group="input" variant="text">
Application from IT Software Inventory (type 3 characters to search)
</Typography>

{state.isError && (
{currentCIState.isError && (
<div>
<Alert type="danger">
<Typography>
Failed to load. {getFetchErrorMessage(state.error)}
Failed to load. {getFetchErrorMessage(currentCIState.error)}
</Typography>
</Alert>
</div>
Expand Down
11 changes: 5 additions & 6 deletions src/components/app-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ export default function AppList() {
[]
);

const {
data: appsData,
refetch,
...appsState
} = useShowApplicationsQuery({}, { pollingInterval });
const { data: appsData, ...appsState } = useShowApplicationsQuery(
{},
{ pollingInterval }
);
const { data: favsData, ...favsState } = useGetSearchApplicationsQuery(
{
apps: favourites?.join(','),
Expand Down Expand Up @@ -78,7 +77,7 @@ export default function AppList() {
<div className="app-list__header">
<Typography variant="body_short_bold">Favourites</Typography>
<div className="create-app">
<PageCreateApplication refetch={refetch} />
<PageCreateApplication />
</div>
</div>
<div className="app-list">
Expand Down
8 changes: 4 additions & 4 deletions src/components/component/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Props = {
component?: Component;
startEnabled?: boolean;
stopEnabled?: boolean;
refetch: Function;
refetch?: Function;
};
export function Toolbar({
appName,
Expand Down Expand Up @@ -55,7 +55,7 @@ export function Toolbar({
envName,
componentName: component.name,
}).unwrap();
await refetch();
await refetch?.();
} catch (error) {
errorToast(`Failed to start component. ${getFetchErrorMessage(error)}`);
}
Expand All @@ -67,7 +67,7 @@ export function Toolbar({
envName,
componentName: component.name,
}).unwrap();
await refetch();
await refetch?.();
} catch (error) {
errorToast(`Failed to stop component. ${getFetchErrorMessage(error)}`);
}
Expand All @@ -79,7 +79,7 @@ export function Toolbar({
envName,
componentName: component.name,
}).unwrap();
await refetch();
await refetch?.();
} catch (error) {
errorToast(`Failed to restart component. ${getFetchErrorMessage(error)}`);
}
Expand Down
48 changes: 41 additions & 7 deletions src/components/configure-application-github/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import {
import { pollingInterval } from '../../store/defaults';
import { handlePromiseWithToast } from '../global-top-nav/styled-toaster';
import { getFetchErrorMessage } from '../../store/utils';
import { ScrimPopup } from '../scrim-popup';

const radixZoneDNS = configVariables.RADIX_CLUSTER_BASE;

interface Props {
app: ApplicationRegistration;
refetch: Function;
refetch?: Function;
onDeployKeyChange: (appName: string) => void;
startVisible?: boolean;
useOtherCiToolOptionVisible?: boolean;
Expand All @@ -53,7 +54,8 @@ export const ConfigureApplicationGithub = ({
const isExpanded = !!startVisible;
const webhookURL = `https://webhook.${radixZoneDNS}/events/github?appName=${app.name}`;
const [useOtherCiTool, setUseOtherCiTool] = useState(false);

const [visibleRegenerateScrim, setVisibleRegenerateScrim] =
useState<boolean>(false);
const [regenerateSecrets, { isLoading, error }] =
useRegenerateDeployKeyMutation();
const { data: secrets, refetch: refetchSecrets } =
Expand All @@ -63,13 +65,14 @@ export const ConfigureApplicationGithub = ({
);

const onRegenerate = handlePromiseWithToast(async () => {
setVisibleRegenerateScrim(false);
await regenerateSecrets({
appName: app.name,
regenerateDeployKeyAndSecretData: { sharedSecret: nanoid() },
}).unwrap();
await refetchSecrets();
await refetch();
});
await refetch?.();
}, 'Successfully re-generated deploy key and webhook secret');

return (
<div className="configure-application-github grid grid--gap-medium">
Expand Down Expand Up @@ -130,9 +133,40 @@ export const ConfigureApplicationGithub = ({
<Progress.Circular size={16} /> Regenerating…
</>
) : (
<Button onClick={onRegenerate}>
Regenerate deploy key and webhook secret
</Button>
<>
<ScrimPopup
title={`Warning`}
open={!!visibleRegenerateScrim}
onClose={() => setVisibleRegenerateScrim(false)}
isDismissable
>
<div className="grid grid--gap-medium grid--auto-columns regenerate-content">
<div className="regenerate-options">
<Typography>
Do you want to <strong>re-generate</strong>{' '}
deploy key and webhook secret?
</Typography>
<Typography>
New deploy key and webhook secret need to be put
to the GitHub repository settings
</Typography>
</div>

<Button.Group>
<Button onClick={onRegenerate}>Rerun</Button>
<Button
variant="outlined"
onClick={() => setVisibleRegenerateScrim(false)}
>
Cancel
</Button>
</Button.Group>
</div>
</ScrimPopup>
<Button onClick={() => setVisibleRegenerateScrim(true)}>
Re-generate deploy key and webhook secret
</Button>
</>
)}
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/components/configure-application-github/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@
filter: invert(0);
}
}

.regenerate-content {
padding: var(--eds_spacing_medium);
padding-top: 0;
overflow: auto;
}
@media (min-width: 150rem) {
.regenerate-content {
margin: auto;
}
}

.regenerate-options {
margin-top: auto;
margin-bottom: auto;
}
6 changes: 3 additions & 3 deletions src/components/create-application-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function sanitizeName(name: string): string {
}

type Props = {
onCreated: (application: ApplicationRegistration) => Promise<void>;
onCreated: (application: ApplicationRegistration) => void;
};
export default function CreateApplicationForm({ onCreated }: Props) {
const [acknowledgeWarnings, setAcknowledgeWarnings] = useState(false);
Expand Down Expand Up @@ -92,8 +92,8 @@ export default function CreateApplicationForm({ onCreated }: Props) {
}).unwrap();

//Only call onCreated when created without warnings, or created with ack warnings
if (response.warnings?.length === 0 || acknowledgeWarnings) {
await onCreated(response.applicationRegistration);
if (!response.warnings?.length || acknowledgeWarnings) {
onCreated(response.applicationRegistration);
successToast('Saved');
} else {
warningToast('Registration had warnings');
Expand Down
Loading

0 comments on commit 0e777d1

Please sign in to comment.