Skip to content

Commit

Permalink
Merge pull request #2631 from headlamp-k8s/back-home-authchooser
Browse files Browse the repository at this point in the history
frontend: AuthChooser: Add home navigation on auth fail
  • Loading branch information
joaquimrocha authored Dec 4, 2024
2 parents 6f2b61d + 56d4947 commit a0d4185
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 23 deletions.
2 changes: 0 additions & 2 deletions frontend/src/components/authchooser/AuthChooser.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const argFixture = {
error: null,
oauthUrl: 'http://example.com/',
clusterAuthType: '',
haveClusters: false,
};

export const BasicAuthChooser = Template.bind({});
Expand All @@ -49,7 +48,6 @@ Testing.args = {
export const HaveClusters = Template.bind({});
HaveClusters.args = {
...argFixture,
haveClusters: true,
};

export const AuthTypeoidc = Template.bind({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@
</button>
</div>
</main>
<div
class="MuiBox-root css-dvxtzn"
>
<div
class="MuiBox-root css-oo0cqs"
role="button"
style="cursor: pointer;"
>
<div
class="MuiBox-root css-37urdo"
/>
<div
class="MuiBox-root css-1kuy7z7"
style="text-transform: uppercase;"
>
Back
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@
</div>
</div>
</main>
<div
class="MuiBox-root css-dvxtzn"
>
<div
class="MuiBox-root css-oo0cqs"
role="button"
style="cursor: pointer;"
>
<div
class="MuiBox-root css-37urdo"
/>
<div
class="MuiBox-root css-1kuy7z7"
style="text-transform: uppercase;"
>
Back
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@
</div>
</div>
</main>
<div
class="MuiBox-root css-dvxtzn"
>
<div
class="MuiBox-root css-oo0cqs"
role="button"
style="cursor: pointer;"
>
<div
class="MuiBox-root css-37urdo"
/>
<div
class="MuiBox-root css-1kuy7z7"
style="text-transform: uppercase;"
>
Back
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,25 @@
</span>
</div>
</main>
<div
class="MuiBox-root css-dvxtzn"
>
<div
class="MuiBox-root css-oo0cqs"
role="button"
style="cursor: pointer;"
>
<div
class="MuiBox-root css-37urdo"
/>
<div
class="MuiBox-root css-1kuy7z7"
style="text-transform: uppercase;"
>
Back
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
37 changes: 16 additions & 21 deletions frontend/src/components/authchooser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ function AuthChooser({ children }: AuthChooserProps) {
? t('Authentication: {{ clusterName }}', { clusterName })
: t('Authentication')
}
haveClusters={!!clusters && Object.keys(clusters).length > 1}
error={error}
oauthUrl={`${helpers.getAppUrl()}oidc?dt=${Date()}&cluster=${getCluster()}`}
clusterAuthType={clusterAuthType}
Expand All @@ -199,7 +198,7 @@ function AuthChooser({ children }: AuthChooserProps) {
});
}}
handleBackButtonPress={() => {
history.goBack();
numClusters > 1 ? history.goBack() : history.push('/');
}}
handleTokenAuth={() => {
history.push({
Expand All @@ -221,7 +220,6 @@ export interface PureAuthChooserProps {
error: Error | null;
oauthUrl: string;
clusterAuthType: string;
haveClusters: boolean;
handleOidcAuth: () => void;
handleTokenAuth: () => void;
handleTryAgain: () => void;
Expand All @@ -237,7 +235,6 @@ export function PureAuthChooser({
error,
oauthUrl,
clusterAuthType,
haveClusters,
handleOidcAuth,
handleTokenAuth,
handleTryAgain,
Expand Down Expand Up @@ -310,25 +307,23 @@ export function PureAuthChooser({
)}
</Box>
)}
{haveClusters && (
<Box display="flex" flexDirection="column" alignItems="center">
<Box
m={2}
display="flex"
alignItems="center"
style={{ cursor: 'pointer' }}
onClick={handleBackButtonPress}
role="button"
>
<Box pt={0.5}>
<InlineIcon icon="mdi:chevron-left" height={20} width={20} />
</Box>
<Box fontSize={14} style={{ textTransform: 'uppercase' }}>
{t('translation|Back')}
</Box>
<Box display="flex" flexDirection="column" alignItems="center">
<Box
m={2}
display="flex"
alignItems="center"
style={{ cursor: 'pointer' }}
onClick={handleBackButtonPress}
role="button"
>
<Box pt={0.5}>
<InlineIcon icon="mdi:chevron-left" height={20} width={20} />
</Box>
<Box fontSize={14} style={{ textTransform: 'uppercase' }}>
{t('translation|Back')}
</Box>
</Box>
)}
</Box>
{children}
</ClusterDialog>
);
Expand Down

0 comments on commit a0d4185

Please sign in to comment.