mirror of
https://github.com/portainer/portainer.git
synced 2025-08-08 15:25:22 +02:00
fix(analytics): load public settings [EE-3590] (#7128)
This commit is contained in:
parent
1551b02fde
commit
95f706aabe
7 changed files with 56 additions and 16 deletions
|
@ -2,8 +2,8 @@ import clsx from 'clsx';
|
|||
|
||||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
import { Environment } from '@/portainer/environments/types';
|
||||
import { useSettings } from '@/portainer/settings/queries';
|
||||
import { Settings } from '@/portainer/settings/types';
|
||||
import { usePublicSettings } from '@/portainer/settings/queries';
|
||||
import { PublicSettingsViewModel } from '@/portainer/models/settings';
|
||||
|
||||
interface Props {
|
||||
showLastCheckInDate?: boolean;
|
||||
|
@ -58,7 +58,7 @@ export function EdgeIndicator({
|
|||
}
|
||||
|
||||
function useHasHeartbeat(environment: Environment, associated: boolean) {
|
||||
const settingsQuery = useSettings(undefined, associated);
|
||||
const settingsQuery = usePublicSettings({ enabled: associated });
|
||||
|
||||
if (!associated) {
|
||||
return false;
|
||||
|
@ -81,7 +81,10 @@ function useHasHeartbeat(environment: Environment, associated: boolean) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function getCheckinInterval(environment: Environment, settings: Settings) {
|
||||
function getCheckinInterval(
|
||||
environment: Environment,
|
||||
settings: PublicSettingsViewModel
|
||||
) {
|
||||
const asyncMode = environment.Edge.AsyncMode;
|
||||
|
||||
if (asyncMode) {
|
||||
|
@ -104,7 +107,7 @@ function getCheckinInterval(environment: Environment, settings: Settings) {
|
|||
!environment.EdgeCheckinInterval ||
|
||||
environment.EdgeCheckinInterval === 0
|
||||
) {
|
||||
return settings.EdgeAgentCheckinInterval;
|
||||
return settings.Edge.CheckinInterval;
|
||||
}
|
||||
|
||||
return environment.EdgeCheckinInterval;
|
||||
|
|
|
@ -30,9 +30,9 @@ export function KubeconfigPrompt({
|
|||
const [page, setPage] = useState(1);
|
||||
const [pageLimit, setPageLimit] = usePaginationLimitState(storageKey);
|
||||
|
||||
const expiryQuery = usePublicSettings((settings) =>
|
||||
expiryMessage(settings.KubeconfigExpiry)
|
||||
);
|
||||
const expiryQuery = usePublicSettings({
|
||||
select: (settings) => expiryMessage(settings.KubeconfigExpiry),
|
||||
});
|
||||
|
||||
const { selection, toggle: toggleSelection, selectionSize } = useSelection();
|
||||
const { environments, totalCount } = useEnvironmentList({
|
||||
|
|
|
@ -34,6 +34,8 @@ export function PublicSettingsViewModel(settings) {
|
|||
this.EnableTelemetry = settings.EnableTelemetry;
|
||||
this.OAuthLogoutURI = settings.OAuthLogoutURI;
|
||||
this.KubeconfigExpiry = settings.KubeconfigExpiry;
|
||||
this.Features = settings.Features;
|
||||
this.Edge = new EdgeSettingsViewModel(settings.Edge);
|
||||
}
|
||||
|
||||
export function InternalAuthSettingsViewModel(data) {
|
||||
|
@ -75,3 +77,11 @@ export function OAuthSettingsViewModel(data) {
|
|||
this.SSO = data.SSO;
|
||||
this.LogoutURI = data.LogoutURI;
|
||||
}
|
||||
|
||||
export function EdgeSettingsViewModel(data = {}) {
|
||||
this.CheckinInterval = data.CheckinInterval;
|
||||
this.PingInterval = data.PingInterval;
|
||||
this.SnapshotInterval = data.SnapshotInterval;
|
||||
this.CommandInterval = data.CommandInterval;
|
||||
this.AsyncMode = data.AsyncMode;
|
||||
}
|
||||
|
|
|
@ -15,12 +15,17 @@ import {
|
|||
} from './settings.service';
|
||||
import { Settings } from './types';
|
||||
|
||||
export function usePublicSettings<T = PublicSettingsViewModel>(
|
||||
select?: (settings: PublicSettingsViewModel) => T
|
||||
) {
|
||||
export function usePublicSettings<T = PublicSettingsViewModel>({
|
||||
enabled,
|
||||
select,
|
||||
}: {
|
||||
select?: (settings: PublicSettingsViewModel) => T;
|
||||
enabled?: boolean;
|
||||
} = {}) {
|
||||
return useQuery(['settings', 'public'], () => getPublicSettings(), {
|
||||
select,
|
||||
...withError('Unable to retrieve public settings'),
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue