Commit 713c48dd authored by AUTOMATIC's avatar AUTOMATIC

add an 'installed' tag to extensions

parent 991e2dce
...@@ -206,12 +206,13 @@ def refresh_available_extensions_from_data(hide_tags): ...@@ -206,12 +206,13 @@ def refresh_available_extensions_from_data(hide_tags):
if url is None: if url is None:
continue continue
existing = installed_extension_urls.get(normalize_git_url(url), None)
extension_tags = extension_tags + ["installed"] if existing else extension_tags
if len([x for x in extension_tags if x in tags_to_hide]) > 0: if len([x for x in extension_tags if x in tags_to_hide]) > 0:
hidden += 1 hidden += 1
continue continue
existing = installed_extension_urls.get(normalize_git_url(url), None)
install_code = f"""<input onclick="install_extension_from_index(this, '{html.escape(url)}')" type="button" value="{"Install" if not existing else "Installed"}" {"disabled=disabled" if existing else ""} class="gr-button gr-button-lg gr-button-secondary">""" install_code = f"""<input onclick="install_extension_from_index(this, '{html.escape(url)}')" type="button" value="{"Install" if not existing else "Installed"}" {"disabled=disabled" if existing else ""} class="gr-button gr-button-lg gr-button-secondary">"""
tags_text = ", ".join([f"<span class='extension-tag' title='{tags.get(x, '')}'>{x}</span>" for x in extension_tags]) tags_text = ", ".join([f"<span class='extension-tag' title='{tags.get(x, '')}'>{x}</span>" for x in extension_tags])
...@@ -222,7 +223,11 @@ def refresh_available_extensions_from_data(hide_tags): ...@@ -222,7 +223,11 @@ def refresh_available_extensions_from_data(hide_tags):
<td>{html.escape(description)}</td> <td>{html.escape(description)}</td>
<td>{install_code}</td> <td>{install_code}</td>
</tr> </tr>
"""
"""
for tag in [x for x in extension_tags if x not in tags]:
tags[tag] = tag
code += """ code += """
</tbody> </tbody>
...@@ -272,7 +277,7 @@ def create_ui(): ...@@ -272,7 +277,7 @@ def create_ui():
install_extension_button = gr.Button(elem_id="install_extension_button", visible=False) install_extension_button = gr.Button(elem_id="install_extension_button", visible=False)
with gr.Row(): with gr.Row():
hide_tags = gr.CheckboxGroup(value=["ads", "localization"], label="Hide extensions with tags", choices=["script", "ads", "localization"]) hide_tags = gr.CheckboxGroup(value=["ads", "localization", "installed"], label="Hide extensions with tags", choices=["script", "ads", "localization", "installed"])
install_result = gr.HTML() install_result = gr.HTML()
available_extensions_table = gr.HTML() available_extensions_table = gr.HTML()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment