allow us to import formerly blocked system tiddlers (#5479)

This commit is contained in:
Mario Pietsch 2021-05-25 23:21:57 +02:00 committed by GitHub
parent 123666c240
commit c6ed4aa84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 8 deletions

View File

@ -23,7 +23,11 @@ Upgrader/Plugins/Suppressed/Incompatible: Blocked incompatible or obsolete plugi
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> not being newer than existing <<existing>>).
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>.
Upgrader/State/Suppressed: Blocked temporary state tiddler.
Upgrader/System/Disabled: Disabled system tiddler.
Upgrader/System/Suppressed: Blocked system tiddler.
Upgrader/System/Warning: Core module tiddler.
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable.
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
Upgrader/Tiddler/Disabled: Disabled tiddler.
Upgrader/Tiddler/Selected: User selected.
Upgrader/Tiddler/Unselected: Unselected tiddler.

View File

@ -12,8 +12,8 @@ Upgrader module that suppresses certain system tiddlers that shouldn't be import
/*global $tw: false */
"use strict";
var DONT_IMPORT_LIST = ["$:/StoryList","$:/HistoryList"],
DONT_IMPORT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/Import"],
var DONT_IMPORT_LIST = ["$:/Import"],
UNSELECT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/StoryList","$:/HistoryList"],
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
exports.upgrade = function(wiki,titles,tiddlers) {
@ -26,11 +26,10 @@ exports.upgrade = function(wiki,titles,tiddlers) {
tiddlers[title] = Object.create(null);
messages[title] = $tw.language.getString("Import/Upgrader/System/Suppressed");
} else {
for(var t=0; t<DONT_IMPORT_PREFIX_LIST.length; t++) {
var prefix = DONT_IMPORT_PREFIX_LIST[t];
for(var t=0; t<UNSELECT_PREFIX_LIST.length; t++) {
var prefix = UNSELECT_PREFIX_LIST[t];
if(title.substr(0,prefix.length) === prefix) {
tiddlers[title] = Object.create(null);
messages[title] = $tw.language.getString("Import/Upgrader/State/Suppressed");
messages[title] = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
}
}
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {

View File

@ -522,10 +522,15 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
});
// Give the active upgrader modules a chance to process the incoming tiddlers
var messages = this.wiki.invokeUpgraders(incomingTiddlers,importData.tiddlers);
// Deselect any disabled, but _not_ suppressed tiddlers
var systemMessage = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
$tw.utils.each(messages,function(message,title) {
newFields["message-" + title] = message;
if (message.indexOf(systemMessage) !== -1) {
newFields["selection-" + title] = "unchecked";
}
});
// Deselect any suppressed tiddlers
// Deselect suppressed tiddlers ... they have been removed and can't be selected anymore
$tw.utils.each(importData.tiddlers,function(tiddler,title) {
if($tw.utils.count(tiddler) === 0) {
newFields["selection-" + title] = "unchecked";

View File

@ -12,6 +12,24 @@ title: $:/core/ui/ImportListing
</$list>
\end
\define selectionInfo()
\whitespace trim
<$set name="escUnselected" value={{{[{$:/language/Import/Upgrader/Tiddler/Unselected}escaperegexp[]addprefix[(?g)]]}}}>
<$list filter="[all[current]get<messageField>regexp<escUnselected>]" variable="ignore">
<$text text={{{[all[current]get<selectionField>match[checked]then{$:/language/Import/Upgrader/Tiddler/Selected}else[]]}}}/>
</$list>
</$set>
\end
\define libraryInfo()
\whitespace trim
<$set name="escUnselected" value={{{[{$:/language/Import/Upgrader/Tiddler/Unselected}escaperegexp[]addprefix[(?g)]]}}}>
<$list filter="[all[current]get<messageField>!regexp<escUnselected>]" variable="ignore">
<$text text={{{[all[current]get<messageField>]}}}/>
</$list>
</$set>
\end
\define selectionField() selection-$(payloadTiddler)$
\define renameField() rename-$(payloadTiddler)$
@ -69,7 +87,8 @@ title: $:/core/ui/ImportListing
</$reveal>
</td>
<td>
<$view field=<<messageField>>/>
<<selectionInfo>>
<<libraryInfo>>
<<overWriteWarning>>
</td>
</tr>