Skip to content

Commit

Permalink
ZKUI-389: Access Veeam configuration UI from the Veeam welcome modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengYanJin committed Nov 6, 2023
1 parent 246396b commit cb9e5e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/react/next-architecture/ui/ConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ export function useConfig(): AppConfig {
}).spec.selfConfiguration;
}

export function useLinkOpener() {
return configGlobal.hooks.useLinkOpener();
}

export function useDiscoveredViews() {
return configGlobal.hooks.useDiscoveredViews();
}

export function useDeployedApps() {
return deployedInstancesGlobal.hooks.useDeployedApps();
}

export function useDeployedMetalk8sInstances(): SolutionUI[] {
return deployedInstancesGlobal.hooks.useDeployedApps({
kind: 'metalk8s-ui',
Expand Down
27 changes: 22 additions & 5 deletions src/react/ui-elements/Veeam/VeeamWelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,42 @@ import { Button } from '@scality/core-ui/dist/next';
import {
ConfigProvider,
useConfig,
useDeployedApps,
useLinkOpener,
} from '../../next-architecture/ui/ConfigProvider';
import { VeeamLogo } from './VeeamLogo';
import { ArtescaLogo } from './ArtescaLogo';
import styled from 'styled-components';
import { useHistory } from 'react-router-dom';

const CustomModal = styled(Modal)`
background-color: ${(props) => props.theme.backgroundLevel1};
`;

export const VeeamWelcomeModalInternal = () => {
const [isOpen, setIsOpen] = useState<boolean>(true);
const { features, basePath } = useConfig();
const history = useHistory();

const { features } = useConfig();
if (!features.includes('Veeam')) {
return <></>;
}

const { openLink } = useLinkOpener();
const deployedApps = useDeployedApps();
const zenkoUI = deployedApps.find((app) => app.kind === 'zenko-ui');
const zenkoUIVeeamConfigurationView = {
path: '/veeam/configuration',
label: {
en: 'Veeam Configuration',
fr: 'Configuration Veeam',
},
module: './FederableApp',
scope: 'zenko',
};
const veeamConfigurationView = {
view: zenkoUIVeeamConfigurationView,
app: zenkoUI,
isFederated: true,
};

return (
<CustomModal
isOpen={isOpen}
Expand All @@ -48,7 +65,7 @@ export const VeeamWelcomeModalInternal = () => {
label={'Continue'}
onClick={() => {
setIsOpen(false);
history.push(`${basePath}/veeam/configuration`);
openLink(veeamConfigurationView);
}}
/>
</Stack>
Expand Down

0 comments on commit cb9e5e3

Please sign in to comment.