Skip to content

Commit

Permalink
feat: Toggle Upgrade btn based on Enterprise license (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 authored Jan 15, 2025
1 parent 689593d commit 6591381
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/@types/parseable/api/about.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export type QueryEngineType = 'Trino' | 'Parseable' | undefined;

export type LicenseType = 'AGPL-3.0-only' | undefined;

export type AboutData = {
commit: string;
deploymentId: string;
latestVersion: string;
license: string;
license: LicenseType;
mode: string;
staging: string;
store: { type: string; path: string };
Expand Down
21 changes: 13 additions & 8 deletions src/components/Header/PrimaryHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { Button, Divider, Image, Stack } from '@mantine/core';
import { FC, useCallback } from 'react';
import styles from './styles/Header.module.css';
import HelpModal from './HelpModal';
import _ from 'lodash';
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { OSS_LICENSE_TYPE } from '@/constants';

const PrimaryHeader: FC = () => {
const classes = styles;
const { logoContainer, imageSty } = classes;
const [maximized, setAppStore] = useAppStore((store) => store.maximized);
const [instanceConfig] = useAppStore((store) => store.instanceConfig);
const toggleHelpModal = useCallback(() => setAppStore(appStoreReducers.toggleHelpModal), []);
if (maximized) return null;

Expand All @@ -31,14 +34,16 @@ const PrimaryHeader: FC = () => {
className={classes.rightSection}
style={{ flexDirection: 'row', height: '100%', justifyContent: 'flex-end' }}
gap={8}>
<Button
variant="outline"
style={{ border: 'none' }}
component={'a'}
href="mailto:[email protected]?subject=Production%20Support%20Query"
target="_blank">
Upgrade
</Button>
{instanceConfig?.license && _.isEqual(instanceConfig?.license, OSS_LICENSE_TYPE) && (
<Button
variant="outline"
style={{ border: 'none' }}
component={'a'}
href="mailto:[email protected]?subject=Production%20Support%20Query"
target="_blank">
Upgrade
</Button>
)}
<Divider orientation="vertical" />
<Button onClick={toggleHelpModal} style={{ border: 'none' }} variant="outline">
Help
Expand Down
20 changes: 12 additions & 8 deletions src/components/Navbar/infoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useAbout } from '@/hooks/useGetAbout';
import { IconInfoCircle } from '@tabler/icons-react';
import styles from './styles/InfoModal.module.css';
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { OSS_LICENSE_TYPE } from '@/constants';
import _ from 'lodash';

const { setInstanceConfig } = appStoreReducers;

Expand Down Expand Up @@ -60,14 +62,16 @@ const InfoModal: FC<InfoModalProps> = (props) => {
<Box className={aboutTextInnerBox}>
<Text className={aboutTextKey}> License: </Text>
<Text className={aboutTextValue}> {getAboutData?.data.license} </Text>
<Button
variant="outline"
component={'a'}
href="mailto:[email protected]?subject=Production%20Support%20Query"
target="_blank"
className={actionBtn}>
Upgrade to production support
</Button>
{_.isEqual(getAboutData?.data.license, OSS_LICENSE_TYPE) && (
<Button
variant="outline"
component={'a'}
href="mailto:[email protected]?subject=Production%20Support%20Query"
target="_blank"
className={actionBtn}>
Upgrade to production support
</Button>
)}
</Box>
</Box>
<Box className={aboutTextBox}>
Expand Down
3 changes: 3 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const OSS_LICENSE_TYPE = 'AGPL-3.0-only';

export { OSS_LICENSE_TYPE };

0 comments on commit 6591381

Please sign in to comment.