You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/03/14 20:35:30 UTC

[GitHub] [superset] betodealmeida commented on a change in pull request #19141: feat(ui): Adding manifest prefix config

betodealmeida commented on a change in pull request #19141:
URL: https://github.com/apache/superset/pull/19141#discussion_r826355166



##########
File path: superset/extensions.py
##########
@@ -63,22 +63,33 @@ def init_app(self, app: Flask) -> None:
         self.app = app
         # Preload the cache
         self.parse_manifest_json()
+        self.register_processor(app)
 
-        @app.context_processor
-        def get_manifest() -> Dict[str, Callable[[str], List[str]]]:
-            loaded_chunks = set()
-
-            def get_files(bundle: str, asset_type: str = "js") -> List[str]:
-                files = self.get_manifest_files(bundle, asset_type)
-                filtered_files = [f for f in files if f not in loaded_chunks]
-                for f in filtered_files:
-                    loaded_chunks.add(f)
-                return filtered_files
-
-            return dict(
-                js_manifest=lambda bundle: get_files(bundle, "js"),
-                css_manifest=lambda bundle: get_files(bundle, "css"),
-            )
+    def register_processor(self, app: Flask) -> None:
+        app.template_context_processors[None].append(self.get_manifest)
+
+    def get_manifest(self) -> Dict[str, Callable[[str], List[str]]]:
+        loaded_chunks = set()
+
+        def get_files(bundle: str, asset_type: str = "js") -> List[str]:
+            files = self.get_manifest_files(bundle, asset_type)
+            filtered_files = [
+                self.apply_resource_prefix(f) for f in files if f not in loaded_chunks
+            ]
+            for f in filtered_files:
+                loaded_chunks.add(f)

Review comment:
       No need to do this (specially if CI is green) but this can be simplified:
   ```suggestion
               loaded_chunks.update(filtered_files)
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org