Skip to content

Commit

Permalink
Refactor Welcome Page Button
Browse files Browse the repository at this point in the history
  • Loading branch information
karesti committed Nov 15, 2023
1 parent 1fcf45c commit d3926af
Showing 1 changed file with 27 additions and 38 deletions.
65 changes: 27 additions & 38 deletions src/app/Welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '@patternfly/react-core';
import icon from '!!url-loader!@app/assets/images/infinispan_logo_rgb_darkbluewhite_darkblue.svg';
import { CatalogIcon, DownloadIcon, GithubIcon, UnknownIcon } from '@patternfly/react-icons';
import { chart_color_blue_500 } from '@patternfly/react-tokens';
import { chart_color_blue_500, chart_global_Fill_Color_white } from '@patternfly/react-tokens';
import { ConsoleBackground } from '@app/Common/ConsoleBackground/ConsoleBackground';
import { Support } from '@app/Support/Support';
import { KeycloakService } from '@services/keycloakService';
Expand Down Expand Up @@ -68,47 +68,36 @@ const Welcome = (props) => {
return <Alert variant="danger" title="Server error. Check navigator logs" />;
}

let onClickGoToConsole;
if (authState == 'HTTP_LOGIN') {
return (
<Button
onClick={() => {
ConsoleServices.authentication()
.loginLink()
.then((r) => {
if (r.success) {
logUser();
navigate('/' + location.search);
// history.push('/' + history.location.search);
} else {
// Do nothing
}
});
}}
variant={'control'}
>
<Text>{goToTheConsole}</Text>
</Button>
);
}

if (authState == 'NOT_READY') {
return (
<Button size="lg" onClick={() => setSupportOpen(true)} variant={'control'}>
{goToTheConsole}
</Button>
);
}

if (authState == 'READY') {
return (
<Button size="lg" onClick={() => notSecuredModeOn()} variant={'control'}>
{goToTheConsole}
</Button>
);
onClickGoToConsole = () => {
ConsoleServices.authentication()
.loginLink()
.then((r) => {
if (r.success) {
logUser();
navigate('/' + location.search);
// history.push('/' + history.location.search);
} else {
// Do nothing
}
});
};
} else if (authState == 'NOT_READY') {
onClickGoToConsole = () => setSupportOpen(true);
} else if (authState == 'READY') {
onClickGoToConsole = () => notSecuredModeOn();
} else {
onClickGoToConsole = () => login();
}

return (
<Button size="lg" onClick={() => login()} variant={'control'}>
<Button size="lg"
onClick={onClickGoToConsole}
style={{ backgroundColor: chart_color_blue_500.value,
color: chart_global_Fill_Color_white.value }}

>
{goToTheConsole}
</Button>
);
Expand Down

0 comments on commit d3926af

Please sign in to comment.