mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
fix tool disabling for docs and others (#5722)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
This commit is contained in:
@@ -391,13 +391,24 @@ public class EndpointConfiguration {
|
|||||||
addEndpointToGroup("Advance", "extract-image-scans");
|
addEndpointToGroup("Advance", "extract-image-scans");
|
||||||
addEndpointToGroup("Advance", "repair");
|
addEndpointToGroup("Advance", "repair");
|
||||||
addEndpointToGroup("Advance", "auto-rename");
|
addEndpointToGroup("Advance", "auto-rename");
|
||||||
addEndpointToGroup("Advance", "handleData");
|
|
||||||
addEndpointToGroup("Advance", "scanner-effect");
|
addEndpointToGroup("Advance", "scanner-effect");
|
||||||
addEndpointToGroup("Advance", "show-javascript");
|
|
||||||
addEndpointToGroup("Advance", "overlay-pdf");
|
addEndpointToGroup("Advance", "overlay-pdf");
|
||||||
// Backend-only endpoints
|
// Backend-only endpoints
|
||||||
addEndpointToGroup("Advance", "adjust-contrast");
|
addEndpointToGroup("Advance", "adjust-contrast");
|
||||||
addEndpointToGroup("Advance", "pipeline");
|
|
||||||
|
// Adding endpoints to "Automation" group
|
||||||
|
addEndpointToGroup("Automation", "handleData");
|
||||||
|
addEndpointToGroup("Automation", "automate"); // Alias for handleData (user-friendly name)
|
||||||
|
addEndpointToGroup("Automation", "pipeline");
|
||||||
|
|
||||||
|
// Adding endpoints to "DeveloperTools" group
|
||||||
|
addEndpointToGroup("DeveloperTools", "show-javascript");
|
||||||
|
|
||||||
|
// Adding endpoints to "DeveloperDocs" group (fake endpoints for link-only tools)
|
||||||
|
addEndpointToGroup("DeveloperDocs", "dev-api-docs");
|
||||||
|
addEndpointToGroup("DeveloperDocs", "dev-folder-scanning-docs");
|
||||||
|
addEndpointToGroup("DeveloperDocs", "dev-sso-guide-docs");
|
||||||
|
addEndpointToGroup("DeveloperDocs", "dev-airgapped-docs");
|
||||||
|
|
||||||
// CLI
|
// CLI
|
||||||
addEndpointToGroup("CLI", "compress-pdf");
|
addEndpointToGroup("CLI", "compress-pdf");
|
||||||
|
|||||||
@@ -616,6 +616,8 @@ public class ApplicationProperties {
|
|||||||
private String appNameNavbar;
|
private String appNameNavbar;
|
||||||
private List<String> languages;
|
private List<String> languages;
|
||||||
private String logoStyle = "classic"; // Options: "classic" (default) or "modern"
|
private String logoStyle = "classic"; // Options: "classic" (default) or "modern"
|
||||||
|
private boolean defaultHideUnavailableTools = false;
|
||||||
|
private boolean defaultHideUnavailableConversions = false;
|
||||||
|
|
||||||
public String getAppNameNavbar() {
|
public String getAppNameNavbar() {
|
||||||
return appNameNavbar != null && !appNameNavbar.trim().isEmpty() ? appNameNavbar : null;
|
return appNameNavbar != null && !appNameNavbar.trim().isEmpty() ? appNameNavbar : null;
|
||||||
|
|||||||
+8
@@ -153,6 +153,14 @@ public class ConfigController {
|
|||||||
configData.put("logoStyle", applicationProperties.getUi().getLogoStyle());
|
configData.put("logoStyle", applicationProperties.getUi().getLogoStyle());
|
||||||
configData.put("defaultLocale", applicationProperties.getSystem().getDefaultLocale());
|
configData.put("defaultLocale", applicationProperties.getSystem().getDefaultLocale());
|
||||||
|
|
||||||
|
// User preference defaults
|
||||||
|
configData.put(
|
||||||
|
"defaultHideUnavailableTools",
|
||||||
|
applicationProperties.getUi().isDefaultHideUnavailableTools());
|
||||||
|
configData.put(
|
||||||
|
"defaultHideUnavailableConversions",
|
||||||
|
applicationProperties.getUi().isDefaultHideUnavailableConversions());
|
||||||
|
|
||||||
// Security settings
|
// Security settings
|
||||||
// enableLogin requires both the config flag AND proprietary features to be loaded
|
// enableLogin requires both the config flag AND proprietary features to be loaded
|
||||||
// If userService is null, proprietary module isn't loaded
|
// If userService is null, proprietary module isn't loaded
|
||||||
|
|||||||
@@ -230,10 +230,12 @@ ui:
|
|||||||
appNameNavbar: "" # name displayed on the navigation bar
|
appNameNavbar: "" # name displayed on the navigation bar
|
||||||
logoStyle: classic # Options: 'classic' (default - classic S icon) or 'modern' (minimalist logo)
|
logoStyle: classic # Options: 'classic' (default - classic S icon) or 'modern' (minimalist logo)
|
||||||
languages: [] # If empty, all languages are enabled. To display only German and Polish ["de_DE", "pl_PL"]. British English is always enabled.
|
languages: [] # If empty, all languages are enabled. To display only German and Polish ["de_DE", "pl_PL"]. British English is always enabled.
|
||||||
|
defaultHideUnavailableTools: false # Default user preference: hide disabled tools instead of greying them out
|
||||||
|
defaultHideUnavailableConversions: false # Default user preference: hide disabled conversion options instead of greying them out
|
||||||
|
|
||||||
endpoints:
|
endpoints:
|
||||||
toRemove: [] # list endpoints to disable (e.g. ['img-to-pdf', 'remove-pages'])
|
toRemove: [] # list endpoints to disable (e.g. ['img-to-pdf', 'remove-pages'])
|
||||||
groupsToRemove: [] # list groups to disable (e.g. ['LibreOffice'])
|
groupsToRemove: [] # list groups to disable (e.g. ['LibreOffice', 'DeveloperTools', 'DeveloperDocs', 'Automation'])
|
||||||
|
|
||||||
metrics:
|
metrics:
|
||||||
enabled: true # 'true' to enable Info APIs (`/api/*`) endpoints, 'false' to disable
|
enabled: true # 'true' to enable Info APIs (`/api/*`) endpoints, 'false' to disable
|
||||||
|
|||||||
@@ -829,8 +829,9 @@ label = "Username"
|
|||||||
[admin.settings.endpoints]
|
[admin.settings.endpoints]
|
||||||
description = "Control which API endpoints and endpoint groups are available."
|
description = "Control which API endpoints and endpoint groups are available."
|
||||||
management = "Endpoint Management"
|
management = "Endpoint Management"
|
||||||
note = "Note: Disabling endpoints restricts API access but does not remove UI components. Restart required for changes to take effect."
|
|
||||||
title = "API Endpoints"
|
title = "API Endpoints"
|
||||||
|
userDefaults = "User Preference Defaults"
|
||||||
|
userDefaultsDescription = "Set default values for user preferences. Users can override these in their personal settings."
|
||||||
|
|
||||||
[admin.settings.endpoints.groupsToRemove]
|
[admin.settings.endpoints.groupsToRemove]
|
||||||
description = "Select endpoint groups to disable"
|
description = "Select endpoint groups to disable"
|
||||||
@@ -840,6 +841,14 @@ label = "Disabled Endpoint Groups"
|
|||||||
description = "Select individual endpoints to disable"
|
description = "Select individual endpoints to disable"
|
||||||
label = "Disabled Endpoints"
|
label = "Disabled Endpoints"
|
||||||
|
|
||||||
|
[admin.settings.endpoints.defaultHideUnavailableTools]
|
||||||
|
description = "Remove disabled tools instead of showing them greyed out"
|
||||||
|
label = "Hide unavailable tools by default"
|
||||||
|
|
||||||
|
[admin.settings.endpoints.defaultHideUnavailableConversions]
|
||||||
|
description = "Remove disabled conversion options instead of showing them greyed out"
|
||||||
|
label = "Hide unavailable conversions by default"
|
||||||
|
|
||||||
[admin.settings.enterpriseRequired]
|
[admin.settings.enterpriseRequired]
|
||||||
message = "An Enterprise license is required to access {{featureName}}. You are viewing demo data for reference."
|
message = "An Enterprise license is required to access {{featureName}}. You are viewing demo data for reference."
|
||||||
title = "Enterprise License Required"
|
title = "Enterprise License Required"
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import { FilesModalProvider } from "@app/contexts/FilesModalContext";
|
|||||||
import { ToolWorkflowProvider } from "@app/contexts/ToolWorkflowContext";
|
import { ToolWorkflowProvider } from "@app/contexts/ToolWorkflowContext";
|
||||||
import { HotkeyProvider } from "@app/contexts/HotkeyContext";
|
import { HotkeyProvider } from "@app/contexts/HotkeyContext";
|
||||||
import { SidebarProvider } from "@app/contexts/SidebarContext";
|
import { SidebarProvider } from "@app/contexts/SidebarContext";
|
||||||
import { PreferencesProvider } from "@app/contexts/PreferencesContext";
|
import { PreferencesProvider, usePreferences } from "@app/contexts/PreferencesContext";
|
||||||
import { AppConfigProvider, AppConfigProviderProps, AppConfigRetryOptions } from "@app/contexts/AppConfigContext";
|
import { AppConfigProvider, AppConfigProviderProps, AppConfigRetryOptions, useAppConfig } from "@app/contexts/AppConfigContext";
|
||||||
import { RightRailProvider } from "@app/contexts/RightRailContext";
|
import { RightRailProvider } from "@app/contexts/RightRailContext";
|
||||||
import { ViewerProvider } from "@app/contexts/ViewerContext";
|
import { ViewerProvider } from "@app/contexts/ViewerContext";
|
||||||
import { SignatureProvider } from "@app/contexts/SignatureContext";
|
import { SignatureProvider } from "@app/contexts/SignatureContext";
|
||||||
@@ -70,6 +70,24 @@ export interface AppProvidersProps {
|
|||||||
appConfigProviderProps?: Partial<AppConfigProviderOverrides>;
|
appConfigProviderProps?: Partial<AppConfigProviderOverrides>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Component to sync server defaults to preferences when AppConfig loads
|
||||||
|
function ServerDefaultsSync() {
|
||||||
|
const { config } = useAppConfig();
|
||||||
|
const { updateServerDefaults } = usePreferences();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (config) {
|
||||||
|
const serverDefaults = {
|
||||||
|
hideUnavailableTools: config.defaultHideUnavailableTools ?? false,
|
||||||
|
hideUnavailableConversions: config.defaultHideUnavailableConversions ?? false,
|
||||||
|
};
|
||||||
|
updateServerDefaults(serverDefaults);
|
||||||
|
}
|
||||||
|
}, [config, updateServerDefaults]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core application providers
|
* Core application providers
|
||||||
* Contains all providers needed for the core
|
* Contains all providers needed for the core
|
||||||
@@ -86,6 +104,7 @@ export function AppProviders({ children, appConfigRetryOptions, appConfigProvide
|
|||||||
>
|
>
|
||||||
<ScarfTrackingInitializer />
|
<ScarfTrackingInitializer />
|
||||||
<AppConfigLoader />
|
<AppConfigLoader />
|
||||||
|
<ServerDefaultsSync />
|
||||||
<FileContextProvider enableUrlSync={true} enablePersistence={true}>
|
<FileContextProvider enableUrlSync={true} enablePersistence={true}>
|
||||||
<AppInitializer />
|
<AppInitializer />
|
||||||
<BrandingAssetManager />
|
<BrandingAssetManager />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useRef, forwardRef, useEffect } from "react";
|
import React, { useState, useRef, forwardRef, useEffect, useMemo } from "react";
|
||||||
import { Stack, Divider, Menu, Indicator } from "@mantine/core";
|
import { Stack, Divider, Menu, Indicator } from "@mantine/core";
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
@@ -34,7 +34,7 @@ const QuickAccessBar = forwardRef<HTMLDivElement>((_, ref) => {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { isRainbowMode } = useRainbowThemeContext();
|
const { isRainbowMode } = useRainbowThemeContext();
|
||||||
const { openFilesModal, isFilesModalOpen } = useFilesModalContext();
|
const { openFilesModal, isFilesModalOpen } = useFilesModalContext();
|
||||||
const { handleReaderToggle, handleToolSelect, selectedToolKey, leftPanelView, toolRegistry, readerMode, resetTool } = useToolWorkflow();
|
const { handleReaderToggle, handleToolSelect, selectedToolKey, leftPanelView, toolRegistry, readerMode, resetTool, toolAvailability } = useToolWorkflow();
|
||||||
const { hasUnsavedChanges } = useNavigationState();
|
const { hasUnsavedChanges } = useNavigationState();
|
||||||
const { actions: navigationActions } = useNavigationActions();
|
const { actions: navigationActions } = useNavigationActions();
|
||||||
const { getToolNavigation } = useSidebarNavigation();
|
const { getToolNavigation } = useSidebarNavigation();
|
||||||
@@ -119,14 +119,14 @@ const QuickAccessBar = forwardRef<HTMLDivElement>((_, ref) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const mainButtons: ButtonConfig[] = [
|
const mainButtons: ButtonConfig[] = useMemo(() => [
|
||||||
{
|
{
|
||||||
id: 'read',
|
id: 'read',
|
||||||
name: t("quickAccess.reader", "Reader"),
|
name: t("quickAccess.reader", "Reader"),
|
||||||
icon: <LocalIcon icon="menu-book-rounded" width="1.25rem" height="1.25rem" />,
|
icon: <LocalIcon icon="menu-book-rounded" width="1.25rem" height="1.25rem" />,
|
||||||
size: 'md',
|
size: 'md' as const,
|
||||||
isRound: false,
|
isRound: false,
|
||||||
type: 'navigation',
|
type: 'navigation' as const,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
setActiveButton('read');
|
setActiveButton('read');
|
||||||
handleReaderToggle();
|
handleReaderToggle();
|
||||||
@@ -136,9 +136,9 @@ const QuickAccessBar = forwardRef<HTMLDivElement>((_, ref) => {
|
|||||||
id: 'automate',
|
id: 'automate',
|
||||||
name: t("quickAccess.automate", "Automate"),
|
name: t("quickAccess.automate", "Automate"),
|
||||||
icon: <LocalIcon icon="automation-outline" width="1.25rem" height="1.25rem" />,
|
icon: <LocalIcon icon="automation-outline" width="1.25rem" height="1.25rem" />,
|
||||||
size: 'md',
|
size: 'md' as const,
|
||||||
isRound: false,
|
isRound: false,
|
||||||
type: 'navigation',
|
type: 'navigation' as const,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
setActiveButton('automate');
|
setActiveButton('automate');
|
||||||
// If already on automate tool, reset it directly
|
// If already on automate tool, reset it directly
|
||||||
@@ -149,7 +149,14 @@ const QuickAccessBar = forwardRef<HTMLDivElement>((_, ref) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
].filter(button => {
|
||||||
|
// Filter out buttons for disabled tools
|
||||||
|
// 'read' is always available (viewer mode)
|
||||||
|
if (button.id === 'read') return true;
|
||||||
|
// Check if tool is actually available (not just present in registry)
|
||||||
|
const availability = toolAvailability[button.id as keyof typeof toolAvailability];
|
||||||
|
return availability?.available !== false;
|
||||||
|
}), [t, setActiveButton, handleReaderToggle, selectedToolKey, resetTool, handleToolSelect, toolAvailability]);
|
||||||
|
|
||||||
const middleButtons: ButtonConfig[] = [
|
const middleButtons: ButtonConfig[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ export interface AppConfig {
|
|||||||
error?: string;
|
error?: string;
|
||||||
isNewServer?: boolean;
|
isNewServer?: boolean;
|
||||||
isNewUser?: boolean;
|
isNewUser?: boolean;
|
||||||
|
defaultHideUnavailableTools?: boolean;
|
||||||
|
defaultHideUnavailableConversions?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AppConfigBootstrapMode = 'blocking' | 'non-blocking';
|
export type AppConfigBootstrapMode = 'blocking' | 'non-blocking';
|
||||||
|
|||||||
@@ -8,13 +8,16 @@ interface PreferencesContextValue {
|
|||||||
value: UserPreferences[K]
|
value: UserPreferences[K]
|
||||||
) => void;
|
) => void;
|
||||||
resetPreferences: () => void;
|
resetPreferences: () => void;
|
||||||
|
updateServerDefaults: (defaults: Partial<UserPreferences>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PreferencesContext = createContext<PreferencesContextValue | undefined>(undefined);
|
const PreferencesContext = createContext<PreferencesContextValue | undefined>(undefined);
|
||||||
|
|
||||||
export const PreferencesProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
export const PreferencesProvider: React.FC<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}> = ({ children }) => {
|
||||||
const [preferences, setPreferences] = useState<UserPreferences>(() => {
|
const [preferences, setPreferences] = useState<UserPreferences>(() => {
|
||||||
// Load preferences synchronously on mount
|
// Load preferences synchronously on mount with hardcoded defaults
|
||||||
return preferencesService.getAllPreferences();
|
return preferencesService.getAllPreferences();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -34,12 +37,19 @@ export const PreferencesProvider: React.FC<{ children: React.ReactNode }> = ({ c
|
|||||||
setPreferences(preferencesService.getAllPreferences());
|
setPreferences(preferencesService.getAllPreferences());
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const updateServerDefaults = useCallback((defaults: Partial<UserPreferences>) => {
|
||||||
|
preferencesService.setServerDefaults(defaults);
|
||||||
|
// Reload preferences to apply server defaults
|
||||||
|
setPreferences(preferencesService.getAllPreferences());
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PreferencesContext.Provider
|
<PreferencesContext.Provider
|
||||||
value={{
|
value={{
|
||||||
preferences,
|
preferences,
|
||||||
updatePreference,
|
updatePreference,
|
||||||
resetPreferences,
|
resetPreferences,
|
||||||
|
updateServerDefaults,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ export function useTranslatedToolCatalog(): TranslatedToolCatalog {
|
|||||||
subcategoryId: SubcategoryId.AUTOMATION,
|
subcategoryId: SubcategoryId.AUTOMATION,
|
||||||
maxFiles: -1,
|
maxFiles: -1,
|
||||||
supportedFormats: CONVERT_SUPPORTED_FORMATS,
|
supportedFormats: CONVERT_SUPPORTED_FORMATS,
|
||||||
endpoints: ["handleData"],
|
endpoints: ["automate"],
|
||||||
synonyms: getSynonyms(t, "automate"),
|
synonyms: getSynonyms(t, "automate"),
|
||||||
automationSettings: null,
|
automationSettings: null,
|
||||||
},
|
},
|
||||||
@@ -808,6 +808,7 @@ export function useTranslatedToolCatalog(): TranslatedToolCatalog {
|
|||||||
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
||||||
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
||||||
link: devApiLink,
|
link: devApiLink,
|
||||||
|
endpoints: ["dev-api-docs"],
|
||||||
synonyms: getSynonyms(t, "devApi"),
|
synonyms: getSynonyms(t, "devApi"),
|
||||||
supportsAutomate: false,
|
supportsAutomate: false,
|
||||||
automationSettings: null
|
automationSettings: null
|
||||||
@@ -820,6 +821,7 @@ export function useTranslatedToolCatalog(): TranslatedToolCatalog {
|
|||||||
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
||||||
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
||||||
link: "https://docs.stirlingpdf.com/Configuration/Folder%20Scanning/",
|
link: "https://docs.stirlingpdf.com/Configuration/Folder%20Scanning/",
|
||||||
|
endpoints: ["dev-folder-scanning-docs"],
|
||||||
synonyms: getSynonyms(t, "devFolderScanning"),
|
synonyms: getSynonyms(t, "devFolderScanning"),
|
||||||
supportsAutomate: false,
|
supportsAutomate: false,
|
||||||
automationSettings: null
|
automationSettings: null
|
||||||
@@ -832,6 +834,7 @@ export function useTranslatedToolCatalog(): TranslatedToolCatalog {
|
|||||||
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
||||||
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
||||||
link: "https://docs.stirlingpdf.com/Configuration/Single%20Sign-On%20Configuration/",
|
link: "https://docs.stirlingpdf.com/Configuration/Single%20Sign-On%20Configuration/",
|
||||||
|
endpoints: ["dev-sso-guide-docs"],
|
||||||
synonyms: getSynonyms(t, "devSsoGuide"),
|
synonyms: getSynonyms(t, "devSsoGuide"),
|
||||||
supportsAutomate: false,
|
supportsAutomate: false,
|
||||||
automationSettings: null
|
automationSettings: null
|
||||||
@@ -844,6 +847,7 @@ export function useTranslatedToolCatalog(): TranslatedToolCatalog {
|
|||||||
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
categoryId: ToolCategoryId.ADVANCED_TOOLS,
|
||||||
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
subcategoryId: SubcategoryId.DEVELOPER_TOOLS,
|
||||||
link: "https://docs.stirlingpdf.com/Paid-Offerings/#activating-your-license",
|
link: "https://docs.stirlingpdf.com/Paid-Offerings/#activating-your-license",
|
||||||
|
endpoints: ["dev-airgapped-docs"],
|
||||||
synonyms: getSynonyms(t, "devAirgapped"),
|
synonyms: getSynonyms(t, "devAirgapped"),
|
||||||
supportsAutomate: false,
|
supportsAutomate: false,
|
||||||
automationSettings: null
|
automationSettings: null
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export default function HomePage() {
|
|||||||
handleBackToTools,
|
handleBackToTools,
|
||||||
readerMode,
|
readerMode,
|
||||||
setLeftPanelView,
|
setLeftPanelView,
|
||||||
|
toolAvailability,
|
||||||
} = useToolWorkflow();
|
} = useToolWorkflow();
|
||||||
|
|
||||||
const { openFilesModal } = useFilesModalContext();
|
const { openFilesModal } = useFilesModalContext();
|
||||||
@@ -249,19 +250,21 @@ export default function HomePage() {
|
|||||||
<AppsIcon sx={{ fontSize: '1.5rem' }} />
|
<AppsIcon sx={{ fontSize: '1.5rem' }} />
|
||||||
<span className="mobile-bottom-button-label">{t('quickAccess.allTools', 'Tools')}</span>
|
<span className="mobile-bottom-button-label">{t('quickAccess.allTools', 'Tools')}</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
{toolAvailability['automate']?.available !== false && (
|
||||||
className="mobile-bottom-button"
|
<button
|
||||||
aria-label={t('quickAccess.automate', 'Automate')}
|
className="mobile-bottom-button"
|
||||||
onClick={() => {
|
aria-label={t('quickAccess.automate', 'Automate')}
|
||||||
handleToolSelect('automate');
|
onClick={() => {
|
||||||
if (isMobile) {
|
handleToolSelect('automate');
|
||||||
setActiveMobileView('tools');
|
if (isMobile) {
|
||||||
}
|
setActiveMobileView('tools');
|
||||||
}}
|
}
|
||||||
>
|
}}
|
||||||
<LocalIcon icon="automation-outline" width="1.5rem" height="1.5rem" />
|
>
|
||||||
<span className="mobile-bottom-button-label">{t('quickAccess.automate', 'Automate')}</span>
|
<LocalIcon icon="automation-outline" width="1.5rem" height="1.5rem" />
|
||||||
</button>
|
<span className="mobile-bottom-button-label">{t('quickAccess.automate', 'Automate')}</span>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
className="mobile-bottom-button"
|
className="mobile-bottom-button"
|
||||||
aria-label={t('home.mobile.openFiles', 'Open files')}
|
aria-label={t('home.mobile.openFiles', 'Open files')}
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ export const DEFAULT_PREFERENCES: UserPreferences = {
|
|||||||
const STORAGE_KEY = 'stirlingpdf_preferences';
|
const STORAGE_KEY = 'stirlingpdf_preferences';
|
||||||
|
|
||||||
class PreferencesService {
|
class PreferencesService {
|
||||||
|
private serverDefaults: Partial<UserPreferences> = {};
|
||||||
|
|
||||||
|
setServerDefaults(defaults: Partial<UserPreferences>): void {
|
||||||
|
this.serverDefaults = defaults;
|
||||||
|
}
|
||||||
|
|
||||||
getPreference<K extends keyof UserPreferences>(
|
getPreference<K extends keyof UserPreferences>(
|
||||||
key: K
|
key: K
|
||||||
): UserPreferences[K] {
|
): UserPreferences[K] {
|
||||||
@@ -53,6 +59,10 @@ class PreferencesService {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error reading preference:', key, error);
|
console.error('Error reading preference:', key, error);
|
||||||
}
|
}
|
||||||
|
// Use server defaults if available, otherwise use hardcoded defaults
|
||||||
|
if (key in this.serverDefaults && this.serverDefaults[key] !== undefined) {
|
||||||
|
return this.serverDefaults[key]!;
|
||||||
|
}
|
||||||
return DEFAULT_PREFERENCES[key];
|
return DEFAULT_PREFERENCES[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,16 +85,18 @@ class PreferencesService {
|
|||||||
const stored = localStorage.getItem(STORAGE_KEY);
|
const stored = localStorage.getItem(STORAGE_KEY);
|
||||||
if (stored) {
|
if (stored) {
|
||||||
const preferences = JSON.parse(stored) as Partial<UserPreferences>;
|
const preferences = JSON.parse(stored) as Partial<UserPreferences>;
|
||||||
// Merge with defaults to ensure all preferences exist
|
// Merge with server defaults first, then stored preferences
|
||||||
return {
|
return {
|
||||||
...DEFAULT_PREFERENCES,
|
...DEFAULT_PREFERENCES,
|
||||||
|
...this.serverDefaults,
|
||||||
...preferences,
|
...preferences,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error reading preferences', error);
|
console.error('Error reading preferences', error);
|
||||||
}
|
}
|
||||||
return { ...DEFAULT_PREFERENCES };
|
// Merge server defaults with hardcoded defaults
|
||||||
|
return { ...DEFAULT_PREFERENCES, ...this.serverDefaults };
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAllPreferences(): void {
|
clearAllPreferences(): void {
|
||||||
|
|||||||
+101
-10
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Stack, Paper, Text, Loader, Group, MultiSelect } from '@mantine/core';
|
import { Button, Stack, Paper, Text, Loader, Group, MultiSelect, Switch } from '@mantine/core';
|
||||||
import { alert } from '@app/components/toast';
|
import { alert } from '@app/components/toast';
|
||||||
import RestartConfirmationModal from '@app/components/shared/config/RestartConfirmationModal';
|
import RestartConfirmationModal from '@app/components/shared/config/RestartConfirmationModal';
|
||||||
import { useRestartServer } from '@app/components/shared/config/useRestartServer';
|
import { useRestartServer } from '@app/components/shared/config/useRestartServer';
|
||||||
@@ -9,6 +9,11 @@ import PendingBadge from '@app/components/shared/config/PendingBadge';
|
|||||||
import { useLoginRequired } from '@app/hooks/useLoginRequired';
|
import { useLoginRequired } from '@app/hooks/useLoginRequired';
|
||||||
import LoginRequiredBanner from '@app/components/shared/config/LoginRequiredBanner';
|
import LoginRequiredBanner from '@app/components/shared/config/LoginRequiredBanner';
|
||||||
|
|
||||||
|
interface UISettingsData {
|
||||||
|
defaultHideUnavailableTools?: boolean;
|
||||||
|
defaultHideUnavailableConversions?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
interface EndpointsSettingsData {
|
interface EndpointsSettingsData {
|
||||||
toRemove?: string[];
|
toRemove?: string[];
|
||||||
groupsToRemove?: string[];
|
groupsToRemove?: string[];
|
||||||
@@ -31,11 +36,24 @@ export default function AdminEndpointsSection() {
|
|||||||
sectionName: 'endpoints',
|
sectionName: 'endpoints',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
settings: uiSettings,
|
||||||
|
setSettings: setUiSettings,
|
||||||
|
loading: uiLoading,
|
||||||
|
saving: uiSaving,
|
||||||
|
fetchSettings: fetchUiSettings,
|
||||||
|
saveSettings: saveUiSettings,
|
||||||
|
isFieldPending: isUiFieldPending,
|
||||||
|
} = useAdminSettings<UISettingsData>({
|
||||||
|
sectionName: 'ui',
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loginEnabled) {
|
if (loginEnabled) {
|
||||||
fetchSettings();
|
fetchSettings();
|
||||||
|
fetchUiSettings();
|
||||||
}
|
}
|
||||||
}, [loginEnabled, fetchSettings]);
|
}, [loginEnabled, fetchSettings, fetchUiSettings]);
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!validateLoginEnabled()) {
|
if (!validateLoginEnabled()) {
|
||||||
@@ -54,8 +72,29 @@ export default function AdminEndpointsSection() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleUiSave = async () => {
|
||||||
|
if (!validateLoginEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await saveUiSettings();
|
||||||
|
alert({
|
||||||
|
alertType: 'success',
|
||||||
|
title: t('admin.success', 'Success'),
|
||||||
|
body: t('admin.settings.saveSuccess', 'Settings saved successfully. Restart required for changes to take effect.'),
|
||||||
|
});
|
||||||
|
} catch (_error) {
|
||||||
|
alert({
|
||||||
|
alertType: 'error',
|
||||||
|
title: t('admin.error', 'Error'),
|
||||||
|
body: t('admin.settings.saveError', 'Failed to save settings'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Override loading state when login is disabled
|
// Override loading state when login is disabled
|
||||||
const actualLoading = loginEnabled ? loading : false;
|
const actualLoading = loginEnabled ? (loading || uiLoading) : false;
|
||||||
|
|
||||||
if (actualLoading) {
|
if (actualLoading) {
|
||||||
return (
|
return (
|
||||||
@@ -77,11 +116,16 @@ export default function AdminEndpointsSection() {
|
|||||||
'auto-redact',
|
'auto-redact',
|
||||||
'auto-rename',
|
'auto-rename',
|
||||||
'auto-split-pdf',
|
'auto-split-pdf',
|
||||||
|
'automate',
|
||||||
'booklet-imposition',
|
'booklet-imposition',
|
||||||
'cert-sign',
|
'cert-sign',
|
||||||
'compare',
|
'compare',
|
||||||
'compress-pdf',
|
'compress-pdf',
|
||||||
'crop',
|
'crop',
|
||||||
|
'dev-airgapped-docs',
|
||||||
|
'dev-api-docs',
|
||||||
|
'dev-folder-scanning-docs',
|
||||||
|
'dev-sso-guide-docs',
|
||||||
'edit-table-of-contents',
|
'edit-table-of-contents',
|
||||||
'eml-to-pdf',
|
'eml-to-pdf',
|
||||||
'extract-image-scans',
|
'extract-image-scans',
|
||||||
@@ -109,6 +153,7 @@ export default function AdminEndpointsSection() {
|
|||||||
'pdf-to-text',
|
'pdf-to-text',
|
||||||
'pdf-to-word',
|
'pdf-to-word',
|
||||||
'pdf-to-xml',
|
'pdf-to-xml',
|
||||||
|
'pipeline',
|
||||||
'rearrange-pages',
|
'rearrange-pages',
|
||||||
'remove-annotations',
|
'remove-annotations',
|
||||||
'remove-blanks',
|
'remove-blanks',
|
||||||
@@ -143,6 +188,9 @@ export default function AdminEndpointsSection() {
|
|||||||
'Security',
|
'Security',
|
||||||
'Other',
|
'Other',
|
||||||
'Advance',
|
'Advance',
|
||||||
|
'Automation',
|
||||||
|
'DeveloperTools',
|
||||||
|
'DeveloperDocs',
|
||||||
// Tool Groups
|
// Tool Groups
|
||||||
'CLI',
|
'CLI',
|
||||||
'Python',
|
'Python',
|
||||||
@@ -224,18 +272,61 @@ export default function AdminEndpointsSection() {
|
|||||||
disabled={!loginEnabled}
|
disabled={!loginEnabled}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Paper bg="var(--mantine-color-blue-light)" p="sm" radius="sm">
|
|
||||||
<Text size="xs" c="dimmed">
|
|
||||||
{t('admin.settings.endpoints.note', 'Note: Disabling endpoints restricts API access but does not remove UI components. Restart required for changes to take effect.')}
|
|
||||||
</Text>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
<Group justify="flex-end">
|
<Group justify="flex-end">
|
||||||
<Button onClick={handleSave} loading={saving} size="sm" disabled={!loginEnabled}>
|
<Button onClick={handleSave} loading={saving} size="sm" disabled={!loginEnabled}>
|
||||||
{t('admin.settings.save', 'Save Changes')}
|
{t('admin.settings.save', 'Save Endpoint Settings')}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Paper withBorder p="md" radius="md">
|
||||||
|
<Stack gap="md">
|
||||||
|
<div>
|
||||||
|
<Text fw={600} size="sm" mb="xs">{t('admin.settings.endpoints.userDefaults', 'User Preference Defaults')}</Text>
|
||||||
|
<Text size="xs" c="dimmed">
|
||||||
|
{t('admin.settings.endpoints.userDefaultsDescription', 'Set default values for user preferences. Users can override these in their personal settings.')}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
label={
|
||||||
|
<Group gap="xs">
|
||||||
|
<span>{t('admin.settings.endpoints.defaultHideUnavailableTools.label', 'Hide unavailable tools by default')}</span>
|
||||||
|
<PendingBadge show={isUiFieldPending('defaultHideUnavailableTools')} />
|
||||||
|
</Group>
|
||||||
|
}
|
||||||
|
description={t('admin.settings.endpoints.defaultHideUnavailableTools.description', 'Remove disabled tools instead of showing them greyed out')}
|
||||||
|
checked={uiSettings.defaultHideUnavailableTools || false}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (!loginEnabled) return;
|
||||||
|
setUiSettings({ ...uiSettings, defaultHideUnavailableTools: e.currentTarget.checked });
|
||||||
|
}}
|
||||||
|
disabled={!loginEnabled}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
label={
|
||||||
|
<Group gap="xs">
|
||||||
|
<span>{t('admin.settings.endpoints.defaultHideUnavailableConversions.label', 'Hide unavailable conversions by default')}</span>
|
||||||
|
<PendingBadge show={isUiFieldPending('defaultHideUnavailableConversions')} />
|
||||||
|
</Group>
|
||||||
|
}
|
||||||
|
description={t('admin.settings.endpoints.defaultHideUnavailableConversions.description', 'Remove disabled conversion options instead of showing them greyed out')}
|
||||||
|
checked={uiSettings.defaultHideUnavailableConversions || false}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (!loginEnabled) return;
|
||||||
|
setUiSettings({ ...uiSettings, defaultHideUnavailableConversions: e.currentTarget.checked });
|
||||||
|
}}
|
||||||
|
disabled={!loginEnabled}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Group justify="flex-end">
|
||||||
|
<Button onClick={handleUiSave} loading={uiSaving} size="sm" disabled={!loginEnabled}>
|
||||||
|
{t('admin.settings.save', 'Save User Defaults')}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user