From 716af4ca500b26ae9cf0b745ecf09127f127cdc5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 2 Jul 2017 16:42:28 +0300 Subject: [PATCH] added ui-introspection + some refactoring... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/filesystem.js | 16 +- ui (gen4)/features/meta.js | 1 + ui (gen4)/features/ui-preact-render.js | 1 - ui (gen4)/features/ui-widgets.js | 252 +++++++++++++++---------- 4 files changed, 165 insertions(+), 105 deletions(-) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index cf27db34..cd042f94 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -2421,12 +2421,16 @@ module.FileSystemWriterUI = core.ImageGridFeatures.Feature({ //--------------------------------------------------------------------- -core.ImageGridFeatures.Feature('fs', [ - 'index-format', - 'fs-info', - 'fs-loader', - 'fs-writer', -]) +core.ImageGridFeatures.Feature({ + tag: 'fs', + suggested: [ + 'index-format', + 'fs-info', + 'fs-loader', + 'fs-writer', + ], + isApplicable: FileSystemInfo.isApplicable, +}) diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index 624356a3..732df6f3 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -64,6 +64,7 @@ core.ImageGridFeatures.Feature('viewer-testing', [ 'workspace', 'ui', + 'ui-introspection', 'keyboard', // XXX use one... diff --git a/ui (gen4)/features/ui-preact-render.js b/ui (gen4)/features/ui-preact-render.js index c1aa0a57..0f88d8a0 100755 --- a/ui (gen4)/features/ui-preact-render.js +++ b/ui (gen4)/features/ui-preact-render.js @@ -18,7 +18,6 @@ if(typeof(preact) == 'undefined'){ } var h = preact.h - var object = require('lib/object') var actions = require('lib/actions') var features = require('lib/features') diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 3ce2892c..f48c5dc8 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -665,75 +665,6 @@ var DialogsActions = actions.Actions({ })], - // Show doc for action... - // - // XXX STUB... - // XXX this needs to: - // - be a widget - // - handle focus - // - handle keyboard - // - handle search... - // - format action links/references... - // - markdown??? - // - ... - // XXX use pWiki??? - // XXX should we have navigation??? - // ...i.e. opening links is done in the viewer and we have - // ability to go back and forth... - showDoc: ['Help/Action help...', - makeUIDialog(function(actions){ - var that = this - actions = actions || this.actions.sort() - actions = actions instanceof Array ? actions : [actions] - - var doc = this.getDoc(actions) - var res = $('
') - .addClass('help-dialog') - - actions.forEach(function(action){ - res.append($('
') - .prop('tabindex', true) - .append($('

') - .text(doc[action][2])) - .append($('') - .text(doc[action][0])) - .append($('
') - .text('Features: ' - + that.getHandlerSourceTags(action) - .join(', '))) - .append($('
')) - // parse the action doc... - .append($('
')
-						.html((doc[action][1] || '')
-							// html stuff...
-							.replace(/&/g, '&')
-							.replace(//g, '>')
-							// normalize tabs -- convert tabs and tabbed 
-							// spaces into 4 spaces...
-							// NOTE: the code internally uses only tabs, 
-							// 		but this will help make the view 
-							// 		consistent.
-							.replace(/ {0,3}\t/g, '    ')
-							// comments...
-							.replace(/(\/\/.*)\n/g, '$1\n')
-							// notes...
-							.replace(/NOTE:/g, 'NOTE:')
-							.replace(/XXX/g, 'XXX')
-							// action links...
-							.replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g, 
-								function(match, a, b, c){
-									return c == action ?
-										`${a}${b}`
-										: `${a}${b}`
-								})
-					)))
-			})
-
-			return res
-		})],
-
-
 	listDialogs: ['Interface/Dialog/Dialog list...',
 		makeUIDialog(function(){
 			var actions = this
@@ -808,6 +739,160 @@ module.Dialogs = core.ImageGridFeatures.Feature({
 
 /*********************************************************************/
 
+var UIIntrospectionActions = actions.Actions({
+	// Show doc for action...
+	//
+	// XXX STUB...
+	// XXX this needs to:
+	// 		- be a widget
+	// 		- handle focus
+	// 		- handle keyboard
+	// 		- handle search...
+	// 		- format action links/references...
+	// 		- markdown???
+	// 		- ...
+	// XXX use pWiki???
+	// XXX should we have navigation???
+	// 		...i.e. opening links is done in the viewer and we have 
+	// 		ability to go back and forth...
+	showDoc: ['Help/Action help...',
+		makeUIDialog(function(actions){
+			var that = this
+			actions = actions || this.actions.sort()
+			actions = actions instanceof Array ? actions : [actions]
+
+			var doc = this.getDoc(actions)
+			var res = $('
') + .addClass('help-dialog') + + actions.forEach(function(action){ + res.append($('
') + .prop('tabindex', true) + .append($('

') + .text(doc[action][2])) + .append($('') + .text(doc[action][0])) + .append($('
') + .text('Features: ' + + that.getHandlerSourceTags(action) + .join(', '))) + .append($('
')) + // parse the action doc... + .append($('
')
+						.html((doc[action][1] || '')
+							// html stuff...
+							.replace(/&/g, '&')
+							.replace(//g, '>')
+							// normalize tabs -- convert tabs and tabbed 
+							// spaces into 4 spaces...
+							// NOTE: the code internally uses only tabs, 
+							// 		but this will help make the view 
+							// 		consistent.
+							.replace(/ {0,3}\t/g, '    ')
+							// comments...
+							.replace(/(\/\/.*)\n/g, '$1\n')
+							// notes...
+							.replace(/NOTE:/g, 'NOTE:')
+							.replace(/XXX/g, 'XXX')
+							// action links...
+							.replace(/(\s)(\.([\w_]+[\w\d_]*)\([^)]*\))/g, 
+								function(match, a, b, c){
+									return c == action ?
+										`${a}${b}`
+										: `${a}${b}`
+								})
+					)))
+			})
+
+			return res
+		})],
+
+	// XXX show more info about features:
+	// 		.title
+	// 		.doc
+	// 		.module
+	// 		...
+	showFeatures: ['System/Features...',
+		core.doc`Show feature load information...`,
+		makeUIDialog(function(){
+			var that = this
+			return browse.makeLister(null, function(path, make){
+				var features = that.features || {}
+
+				// XXX get feature doc...
+				var draw = function(heading, list){
+					make.Heading(heading)
+					;(list || [])
+						.forEach(function(tag){
+							make(tag)
+						}) }
+
+				draw('Loaded', that.features.features)
+				draw('Excluded', that.features.excluded)
+				draw('Disabled', that.features.disabled)
+				draw('Not applicable', that.features.unapplicable)
+
+				if(features.error){
+					var error = features.error
+					error.missing_suggested && error.missing_suggested.length > 0
+						&& draw('Missing (non-critical)', error.missing_suggested)
+					error.missing && error.missing.length > 0
+						&& draw('Missing (critical)', error.missing)
+					// XXX loops...
+					// XXX conflicts...
+				}
+			})
+		})],
+
+	// XXX is this the right way to go???
+	// XXX should this pe a separate feature???
+	about: ['Help/$About...',
+		{'dialogTitle': 'ImageGrid.Viewer'},
+		makeUIDialog(function(path, options){
+			return browse.makeList(
+				null,
+				[
+					// XXX add  basic description (About)...
+
+					// XXX get this from package.json...
+					['Version:', '4.0.0a'],
+					// XXX
+					['Build:', '-'],
+
+					'---',
+
+					// XXX load the license file...
+					['License:', 'Pre Release'],
+
+					// XXX include other lib list and license info...
+					// XXX
+
+					// XXX include nw credits.html...
+					// XXX
+				], {
+					cls: 'table-view'
+				})
+		})],
+})
+
+var UIIntrospection = 
+module.UIIntrospection = core.ImageGridFeatures.Feature({
+	title: '',
+	doc: '',
+
+	tag: 'ui-introspection',
+	depends: [
+		'ui',
+		'ui-dialogs',
+	],
+
+	actions: UIIntrospectionActions,
+})
+
+
+
+//---------------------------------------------------------------------
 // NOTE: yes, this is a funny name ;)
 //
 // XXX should we also add a hide-path config feature???
@@ -1321,34 +1406,6 @@ var BrowseActionsActions = actions.Actions({
 					&& this.modal.client.dom[state == 'on' ? 'addClass' : 'removeClass']('show-keys')
 			})],
 
-	// XXX is this the right way to go???
-	about: ['Help/$About...',
-		{'dialogTitle': 'ImageGrid.Viewer'},
-		makeUIDialog(function(path, options){
-			return browse.makeList(
-				null,
-				[
-					// XXX add  basic description (About)...
-
-					// XXX get this from package.json...
-					['Version:', '4.0.0a'],
-					// XXX
-					['Build:', '-'],
-
-					'---',
-
-					// XXX load the license file...
-					['License:', 'Pre Release'],
-
-					// XXX include other lib list and license info...
-					// XXX
-
-					// XXX include nw credits.html...
-					// XXX
-				], {
-					cls: 'table-view'
-				})
-		})],
 })
 
 var BrowseActions = 
@@ -1843,7 +1900,6 @@ var WidgetTestActions = actions.Actions({
 			setTimeout(step, 1000)
 		}], 
 
-
 	// XXX make this a toggler....
 	partitionByMonth: ['Test/',
 		function(){