mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
Disable cleanup by default and show errors in admin area
This commit is contained in:
parent
593d1021b6
commit
3330ed8d1b
6 changed files with 53 additions and 1 deletions
|
@ -23,6 +23,7 @@ export const PadPage = ()=>{
|
|||
const pads = useStore(state=>state.pads)
|
||||
const [currentPage, setCurrentPage] = useState<number>(0)
|
||||
const [deleteDialog, setDeleteDialog] = useState<boolean>(false)
|
||||
const [errorText, setErrorText] = useState<string|null>(null)
|
||||
const [padToDelete, setPadToDelete] = useState<string>('')
|
||||
const pages = useMemo(()=>{
|
||||
if(!pads){
|
||||
|
@ -72,6 +73,11 @@ export const PadPage = ()=>{
|
|||
settingsSocket.on('results:cleanupPadRevisions', (data)=>{
|
||||
let newPads = useStore.getState().pads?.results ?? []
|
||||
|
||||
if (data.error) {
|
||||
setErrorText(data.error)
|
||||
return
|
||||
}
|
||||
|
||||
newPads.forEach((pad)=>{
|
||||
if (pad.padName === data.padId) {
|
||||
pad.revisionNumber = data.keepRevisions
|
||||
|
@ -118,6 +124,21 @@ export const PadPage = ()=>{
|
|||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
<Dialog.Root open={errorText !== null}>
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay className="dialog-confirm-overlay"/>
|
||||
<Dialog.Content className="dialog-confirm-content">
|
||||
<div>
|
||||
<div>Error occured: {errorText}</div>
|
||||
<div className="settings-button-bar">
|
||||
<button onClick={() => {
|
||||
setErrorText(null)
|
||||
}}>OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
<h1><Trans i18nKey="ep_admin_pads:ep_adminpads2_manage-pads"/></h1>
|
||||
<SearchField value={searchTerm} onChange={v=>setSearchTerm(v.target.value)} placeholder={t('ep_admin_pads:ep_adminpads2_search-heading')}/>
|
||||
<table>
|
||||
|
|
|
@ -171,6 +171,14 @@
|
|||
*/
|
||||
"showSettingsInAdminPage": "${SHOW_SETTINGS_IN_ADMIN_PAGE:true}",
|
||||
|
||||
/*
|
||||
* Settings for cleanup of pads
|
||||
*/
|
||||
"cleanup": {
|
||||
"enabled": false,
|
||||
"keepRevisions": 5
|
||||
},
|
||||
|
||||
/*
|
||||
The authentication method used by the server.
|
||||
The default value is sso
|
||||
|
|
|
@ -162,6 +162,14 @@
|
|||
*/
|
||||
"showSettingsInAdminPage": true,
|
||||
|
||||
/*
|
||||
* Settings for cleanup of pads
|
||||
*/
|
||||
"cleanup": {
|
||||
"enabled": false,
|
||||
"keepRevisions": 5
|
||||
},
|
||||
|
||||
/*
|
||||
* Node native SSL support
|
||||
*
|
||||
|
|
|
@ -254,6 +254,13 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
})
|
||||
|
||||
socket.on('cleanupPadRevisions', async (padId: string) => {
|
||||
if (!settings.cleanup.enabled) {
|
||||
socket.emit('results:cleanupPadRevisions', {
|
||||
error: 'Cleanup disabled. Enable cleanup in settings.json: cleanup.enabled => true',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const padExists = await padManager.doesPadExists(padId);
|
||||
if (padExists) {
|
||||
logger.info(`Cleanup pad revisions: ${padId}`);
|
||||
|
@ -265,9 +272,16 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
keepRevisions: settings.cleanup.keepRevisions,
|
||||
});
|
||||
logger.info('successful cleaned up pad: ', padId)
|
||||
} else {
|
||||
socket.emit('results:cleanupPadRevisions', {
|
||||
error: 'Error cleaning up pad',
|
||||
});
|
||||
}
|
||||
} catch (err: any) {
|
||||
logger.error(`Error in pad ${padId}: ${err.stack || err}`);
|
||||
socket.emit('results:cleanupPadRevisions', {
|
||||
error: err.toString(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ exports.deleteRevisions = async (padId: string, keepRevisions: number): Promise<
|
|||
|
||||
logger.debug('Initial pad is valid')
|
||||
|
||||
if (pad.head < keepRevisions) {
|
||||
if (pad.head <= keepRevisions) {
|
||||
logger.debug('Pad has not enough revisions')
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -384,6 +384,7 @@ exports.showSettingsInAdminPage = true;
|
|||
* Settings for cleanup of pads
|
||||
*/
|
||||
exports.cleanup = {
|
||||
enabled: false,
|
||||
keepRevisions: 100,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue