1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-09 15:55:23 +02:00

Revert "feat(cache): introduce cache option [EE-6293] (#10641)" (#10658)

This reverts commit 2c032f1739.
This commit is contained in:
Ali 2023-11-20 15:08:19 +13:00 committed by GitHub
parent 2c032f1739
commit ecce501cf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 45 additions and 418 deletions

View file

@ -1,86 +0,0 @@
import { Form, Formik } from 'formik';
import { useCurrentUser } from '@/react/hooks/useUser';
import { notifySuccess } from '@/portainer/services/notifications';
import { updateAxiosAdapter } from '@/portainer/services/axios';
import { withError } from '@/react-tools/react-query';
import { TextTip } from '@@/Tip/TextTip';
import { LoadingButton } from '@@/buttons';
import { SwitchField } from '@@/form-components/SwitchField';
import { useUpdateUserMutation } from '../../useUpdateUserMutation';
type FormValues = {
useCache: boolean;
};
export function ApplicationSettingsForm() {
const { user } = useCurrentUser();
const updateSettingsMutation = useUpdateUserMutation();
const initialValues = {
useCache: user.UseCache,
};
return (
<Formik<FormValues>
initialValues={initialValues}
onSubmit={handleSubmit}
validateOnMount
enableReinitialize
>
{({ isValid, dirty, values, setFieldValue }) => (
<Form className="form-horizontal">
<TextTip color="orange" className="mb-3">
Enabling front-end data caching can mean that changes to Kubernetes
clusters made by other users or outside of Portainer may take up to
five minutes to show in your session. This caching only applies to
Kubernetes environments.
</TextTip>
<SwitchField
label="Enable front-end data caching for Kubernetes environments"
checked={values.useCache}
onChange={(value) => setFieldValue('useCache', value)}
labelClass="col-lg-2 col-sm-3" // match the label width of the other fields in the page
fieldClass="!mb-4"
/>
<div className="form-group">
<div className="col-sm-12">
<LoadingButton
loadingText="Saving..."
isLoading={updateSettingsMutation.isLoading}
disabled={!isValid || !dirty}
className="!ml-0"
data-cy="account-applicationSettingsSaveButton"
>
Save
</LoadingButton>
</div>
</div>
</Form>
)}
</Formik>
);
function handleSubmit(values: FormValues) {
updateSettingsMutation.mutate(
{
Id: user.Id,
UseCache: values.useCache,
},
{
onSuccess() {
updateAxiosAdapter(values.useCache);
notifySuccess(
'Success',
'Successfully updated application settings.'
);
// a full reload is required to update the angular $http cache setting
setTimeout(() => window.location.reload(), 2000); // allow 2s to show the success notification
},
...withError('Unable to update application settings'),
}
);
}
}

View file

@ -1,20 +0,0 @@
import { Settings } from 'lucide-react';
import { Widget, WidgetBody, WidgetTitle } from '@@/Widget';
import { ApplicationSettingsForm } from './ApplicationSettingsForm';
export function ApplicationSettingsWidget() {
return (
<div className="row">
<div className="col-sm-12">
<Widget>
<WidgetTitle icon={Settings} title="Application settings" />
<WidgetBody>
<ApplicationSettingsForm />
</WidgetBody>
</Widget>
</div>
</div>
);
}

View file

@ -1 +0,0 @@
export { ApplicationSettingsWidget } from './ApplicationSettingsWidget';

View file

@ -12,7 +12,6 @@ export function CreateHelmRepositoriesView() {
{ label: 'My account', link: 'portainer.account' },
{ label: 'Create Helm repository' },
]}
reload
/>
<div className="row">

View file

@ -1,32 +0,0 @@
import { useMutation } from 'react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { User } from '@/portainer/users/types';
import {
mutationOptions,
withInvalidate,
queryClient,
} from '@/react-tools/react-query';
import { userQueryKeys } from '@/portainer/users/queries/queryKeys';
import { useCurrentUser } from '@/react/hooks/useUser';
export function useUpdateUserMutation() {
const {
user: { Id: userId },
} = useCurrentUser();
return useMutation(
(user: Partial<User>) => updateUser(user, userId),
mutationOptions(withInvalidate(queryClient, [userQueryKeys.base()]))
// error notification should be handled by the caller
);
}
async function updateUser(user: Partial<User>, userId: number) {
try {
const { data } = await axios.put(`/users/${userId}`, user);
return data;
} catch (error) {
throw parseAxiosError(error);
}
}

View file

@ -17,7 +17,6 @@ function EdgeAutoCreateScriptView() {
{ label: 'Environments', link: 'portainer.endpoints' },
'Automatic Edge Environment Creation',
]}
reload
/>
<div className="mx-3">

View file

@ -54,7 +54,6 @@ function CreateView() {
<PageHeader
title="Update & Rollback"
breadcrumbs="Edge agent update and rollback"
reload
/>
<BetaAlert

View file

@ -78,7 +78,6 @@ function ItemView() {
{ label: 'Edge agent update and rollback', link: '^' },
item.name,
]}
reload
/>
<BetaAlert

View file

@ -56,8 +56,8 @@ export function ListView() {
<>
<PageHeader
title="Update & Rollback"
breadcrumbs="Update and rollback"
reload
breadcrumbs="Update and rollback"
/>
<BetaAlert

View file

@ -27,7 +27,6 @@ export function EnvironmentTypeSelectView() {
<PageHeader
title="Quick Setup"
breadcrumbs={[{ label: 'Environment Wizard' }]}
reload
/>
<div className="row">

View file

@ -71,7 +71,6 @@ export function EnvironmentCreationView() {
<PageHeader
title="Quick Setup"
breadcrumbs={[{ label: 'Environment Wizard' }]}
reload
/>
<div className={styles.wizardWrapper}>

View file

@ -22,7 +22,6 @@ export function HomeView() {
<PageHeader
title="Quick Setup"
breadcrumbs={[{ label: 'Environment Wizard' }]}
reload
/>
<div className="row">

View file

@ -18,7 +18,7 @@ import { ExperimentalFeatures } from './ExperimentalFeatures';
export function SettingsView() {
return (
<>
<PageHeader title="Settings" breadcrumbs="Settings" reload />
<PageHeader title="Settings" breadcrumbs="Settings" />
<div className="mx-4 space-y-4">
<ApplicationSettingsPanel onSuccess={handleSuccess} />

View file

@ -38,7 +38,6 @@ export function ItemView() {
<PageHeader
title="Team details"
breadcrumbs={[{ label: 'Teams' }, { label: team.Name }]}
reload
/>
{membershipsQuery.data && (

View file

@ -42,7 +42,6 @@ export function mockExampleData() {
RoleName: 'user',
Checked: false,
AuthenticationMethod: '',
UseCache: false,
},
{
Id: 13,
@ -70,7 +69,6 @@ export function mockExampleData() {
RoleName: 'user',
Checked: false,
AuthenticationMethod: '',
UseCache: false,
},
];

View file

@ -16,11 +16,7 @@ export function ListView() {
return (
<>
<PageHeader
title="Teams"
breadcrumbs={[{ label: 'Teams management' }]}
reload
/>
<PageHeader title="Teams" breadcrumbs={[{ label: 'Teams management' }]} />
{isAdmin && usersQuery.data && teamsQuery.data && (
<CreateTeamForm users={usersQuery.data} teams={teamsQuery.data} />