feat: add DISABLE_NOTIFICATIONS_PAGE feature flag

This commit is contained in:
Ali BARIN
2024-02-07 11:47:44 +00:00
parent a26cf932a1
commit 6ec5872391
4 changed files with 42 additions and 35 deletions

View File

@@ -88,6 +88,7 @@ const appConfig = {
licenseKey: process.env.LICENSE_KEY, licenseKey: process.env.LICENSE_KEY,
sentryDsn: process.env.SENTRY_DSN, sentryDsn: process.env.SENTRY_DSN,
CI: process.env.CI === 'true', CI: process.env.CI === 'true',
disableNotificationsPage: process.env.DISABLE_NOTIFICATIONS_PAGE === 'true',
}; };
if (!appConfig.encryptionKey) { if (!appConfig.encryptionKey) {

View File

@@ -1,6 +1,11 @@
import appConfig from '../../config/app.js';
import { hasValidLicense } from '../../helpers/license.ee.js'; import { hasValidLicense } from '../../helpers/license.ee.js';
import Config from '../../models/config.js'; import Config from '../../models/config.js';
const defaultConfig = {
disableNotificationsPage: appConfig.disableNotificationsPage,
};
const getConfig = async (_parent, params) => { const getConfig = async (_parent, params) => {
if (!(await hasValidLicense())) return {}; if (!(await hasValidLicense())) return {};
@@ -18,7 +23,7 @@ const getConfig = async (_parent, params) => {
computedConfig[key] = value?.data; computedConfig[key] = value?.data;
return computedConfig; return computedConfig;
}, {}); }, defaultConfig);
}; };
export default getConfig; export default getConfig;

View File

@@ -14,31 +14,32 @@ The default values for some environment variables might be different in our deve
Please be careful with the `ENCRYPTION_KEY` and `WEBHOOK_SECRET_KEY` environment variables. They are used to encrypt your credentials from third-party services and verify webhook requests. If you change them, your existing connections and flows will not continue to work. Please be careful with the `ENCRYPTION_KEY` and `WEBHOOK_SECRET_KEY` environment variables. They are used to encrypt your credentials from third-party services and verify webhook requests. If you change them, your existing connections and flows will not continue to work.
::: :::
| Variable Name | Type | Default Value | Description | | Variable Name | Type | Default Value | Description |
| --------------------------- | ------- | ------------------ | ---------------------------------------------------------------------------------------------------- | | ---------------------------- | ------- | ------------------ | ----------------------------------------------------------------------------------- |
| `HOST` | string | `localhost` | HTTP Host | | `HOST` | string | `localhost` | HTTP Host |
| `PROTOCOL` | string | `http` | HTTP Protocol | | `PROTOCOL` | string | `http` | HTTP Protocol |
| `PORT` | string | `3000` | HTTP Port | | `PORT` | string | `3000` | HTTP Port |
| `APP_ENV` | string | `production` | Automatisch Environment | | `APP_ENV` | string | `production` | Automatisch Environment |
| `WEB_APP_URL` | string | | Can be used to override connection URLs and CORS URL | | `WEB_APP_URL` | string | | Can be used to override connection URLs and CORS URL |
| `WEBHOOK_URL` | string | | Can be used to override webhook URL | | `WEBHOOK_URL` | string | | Can be used to override webhook URL |
| `LOG_LEVEL` | string | `info` | Can be used to configure log level such as `error`, `warn`, `info`, `http`, `debug` | | `LOG_LEVEL` | string | `info` | Can be used to configure log level such as `error`, `warn`, `info`, `http`, `debug` |
| `POSTGRES_DATABASE` | string | `automatisch` | Database Name | | `POSTGRES_DATABASE` | string | `automatisch` | Database Name |
| `POSTGRES_SCHEMA` | string | `public` | Database Schema | | `POSTGRES_SCHEMA` | string | `public` | Database Schema |
| `POSTGRES_PORT` | number | `5432` | Database Port | | `POSTGRES_PORT` | number | `5432` | Database Port |
| `POSTGRES_ENABLE_SSL` | boolean | `false` | Enable/Disable SSL for the database | | `POSTGRES_ENABLE_SSL` | boolean | `false` | Enable/Disable SSL for the database |
| `POSTGRES_HOST` | string | `postgres` | Database Host | | `POSTGRES_HOST` | string | `postgres` | Database Host |
| `POSTGRES_USERNAME` | string | `automatisch_user` | Database User | | `POSTGRES_USERNAME` | string | `automatisch_user` | Database User |
| `POSTGRES_PASSWORD` | string | | Password of Database User | | `POSTGRES_PASSWORD` | string | | Password of Database User |
| `ENCRYPTION_KEY` | string | | Encryption Key to store credentials | | `ENCRYPTION_KEY` | string | | Encryption Key to store credentials |
| `WEBHOOK_SECRET_KEY` | string | | Webhook Secret Key to verify webhook requests | | `WEBHOOK_SECRET_KEY` | string | | Webhook Secret Key to verify webhook requests |
| `APP_SECRET_KEY` | string | | Secret Key to authenticate the user | | `APP_SECRET_KEY` | string | | Secret Key to authenticate the user |
| `REDIS_HOST` | string | `redis` | Redis Host | | `REDIS_HOST` | string | `redis` | Redis Host |
| `REDIS_PORT` | number | `6379` | Redis Port | | `REDIS_PORT` | number | `6379` | Redis Port |
| `REDIS_USERNAME` | string | | Redis Username | | `REDIS_USERNAME` | string | | Redis Username |
| `REDIS_PASSWORD` | string | | Redis Password | | `REDIS_PASSWORD` | string | | Redis Password |
| `REDIS_TLS` | boolean | `false` | Redis TLS | | `REDIS_TLS` | boolean | `false` | Redis TLS |
| `TELEMETRY_ENABLED` | boolean | `true` | Enable/Disable Telemetry | | `TELEMETRY_ENABLED` | boolean | `true` | Enable/Disable Telemetry |
| `ENABLE_BULLMQ_DASHBOARD` | boolean | `false` | Enable BullMQ Dashboard | | `ENABLE_BULLMQ_DASHBOARD` | boolean | `false` | Enable BullMQ Dashboard |
| `BULLMQ_DASHBOARD_USERNAME` | string | | Username to login BullMQ Dashboard | | `BULLMQ_DASHBOARD_USERNAME` | string | | Username to login BullMQ Dashboard |
| `BULLMQ_DASHBOARD_PASSWORD` | string | | Password to login BullMQ Dashboard | | `BULLMQ_DASHBOARD_PASSWORD` | string | | Password to login BullMQ Dashboard |
| `DISABLE_NOTIFICATIONS_PAGE` | boolean | `false` | Enable/Disable notifications page |

View File

@@ -12,7 +12,7 @@ import * as URLS from 'config/urls';
import useVersion from 'hooks/useVersion'; import useVersion from 'hooks/useVersion';
import AppBar from 'components/AppBar'; import AppBar from 'components/AppBar';
import Drawer from 'components/Drawer'; import Drawer from 'components/Drawer';
import useAutomatischInfo from 'hooks/useAutomatischInfo'; import useConfig from 'hooks/useConfig';
type PublicLayoutProps = { type PublicLayoutProps = {
children: React.ReactNode; children: React.ReactNode;
@@ -40,17 +40,17 @@ const drawerLinks = [
]; ];
type GenerateDrawerBottomLinksOptions = { type GenerateDrawerBottomLinksOptions = {
isMation: boolean; disableNotificationsPage: boolean;
loading: boolean; loading: boolean;
notificationBadgeContent: number; notificationBadgeContent: number;
}; };
const generateDrawerBottomLinks = ({ const generateDrawerBottomLinks = ({
isMation, disableNotificationsPage,
loading, loading,
notificationBadgeContent = 0, notificationBadgeContent = 0,
}: GenerateDrawerBottomLinksOptions) => { }: GenerateDrawerBottomLinksOptions) => {
if (loading || isMation) { if (loading || disableNotificationsPage) {
return []; return [];
} }
@@ -68,7 +68,7 @@ export default function PublicLayout({
children, children,
}: PublicLayoutProps): React.ReactElement { }: PublicLayoutProps): React.ReactElement {
const version = useVersion(); const version = useVersion();
const { isMation, loading } = useAutomatischInfo(); const { config, loading } = useConfig(['disableNotificationsPage']);
const theme = useTheme(); const theme = useTheme();
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('lg')); const matchSmallScreens = useMediaQuery(theme.breakpoints.down('lg'));
const [isDrawerOpen, setDrawerOpen] = React.useState(!matchSmallScreens); const [isDrawerOpen, setDrawerOpen] = React.useState(!matchSmallScreens);
@@ -79,7 +79,7 @@ export default function PublicLayout({
const drawerBottomLinks = generateDrawerBottomLinks({ const drawerBottomLinks = generateDrawerBottomLinks({
notificationBadgeContent: version.newVersionCount, notificationBadgeContent: version.newVersionCount,
loading, loading,
isMation, disableNotificationsPage: config?.disableNotificationsPage as boolean,
}); });
return ( return (