From 2bfb9ab639e2d63f768c1b2a93cd042a7be3f376 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Wed, 2 Aug 2023 20:55:29 +0200 Subject: [PATCH] (feat) refactor edit file --- ui_components/file_explorer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ui_components/file_explorer.py b/ui_components/file_explorer.py index 54d3352..fc5e88e 100644 --- a/ui_components/file_explorer.py +++ b/ui_components/file_explorer.py @@ -24,12 +24,11 @@ class FileExplorer(Dashboard.Item): def edit_file(self): short_path = st.session_state.selected_file.replace(self._directory, "") - if st.session_state.selected_file.endswith(".py"): + language = "python" if st.session_state.selected_file.endswith(".py") else "yaml" + if st.session_state.selected_file.endswith(".py") or st.session_state.selected_file.endswith(".yml"): st.session_state.editor_tabs[short_path] = {"content": load_file(st.session_state.selected_file), - "language": "python"} - elif st.session_state.selected_file.endswith(".yml"): - st.session_state.editor_tabs[short_path] = {"content": load_file(st.session_state.selected_file), - "language": "yaml"} + "language": language, + "file_path": st.session_state.selected_file} def __call__(self): bots = [bot.split("/")[-2] for bot in get_directories_from_directory(self._directory) if