Skip to content

Commit 8128951

Browse files
authored
Disable TypeScript by default (#986)
Temporarily until flathub/org.freedesktop.Sdk.Extension.typescript#29
1 parent e5c077b commit 8128951

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

data/app.gschema.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<key name="first-run" type="b">
1919
<default>true</default>
2020
</key>
21+
<key name="typescript" type="b">
22+
<default>false</default>
23+
</key>
2124
</schema>
2225
<schema id="@app_id@.Session" path="/re/sonny/Workbench/">
2326
<key name="show-code" type="b">

src/Extensions/Extensions.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Interface from "./Extensions.blp" with { type: "uri" };
66
import illustration from "./extensions.svg";
77

88
import "./Extension.js";
9-
import { getFlatpakInfo } from "../util.js";
9+
import { getFlatpakInfo, settings } from "../util.js";
1010

1111
export const action_extensions = new Gio.SimpleAction({
1212
name: "extensions",
@@ -34,6 +34,7 @@ export function Extensions({ window }) {
3434

3535
extension_typescript.available = isTypeScriptAvailable();
3636
extension_typescript.command = `flatpak install flathub org.freedesktop.Sdk.Extension.${node}//${freedesktop_version} org.freedesktop.Sdk.Extension.typescript//${freedesktop_version}`;
37+
extension_typescript.visible = isTypeScriptEnabled();
3738

3839
for (const extension of [
3940
extension_rust,
@@ -71,6 +72,7 @@ export function isValaAvailable() {
7172
let typescript_available = null;
7273
export function isTypeScriptAvailable() {
7374
typescript_available ??=
75+
isTypeScriptEnabled() &&
7476
Gio.File.new_for_path("/usr/lib/sdk/typescript").query_exists(null) &&
7577
Gio.File.new_for_path(`/usr/lib/sdk/${node}`).query_exists(null);
7678
return typescript_available;
@@ -80,3 +82,7 @@ const llvm = "llvm18";
8082
const node = "node20";
8183
const runtime = getFlatpakInfo().get_string("Application", "runtime");
8284
const freedesktop_version = runtime.endsWith("master") ? "24.08" : "24.08";
85+
86+
export function isTypeScriptEnabled() {
87+
return settings.get_boolean("typescript");
88+
}

src/Library/Library.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
needsAdditionalPermissions,
2222
showPermissionsDialog,
2323
} from "../Permissions/Permissions.js";
24+
import { isTypeScriptEnabled } from "../Extensions/Extensions.js";
2425

2526
export default function Library({ application }) {
2627
const objects = build(resource);
@@ -75,8 +76,10 @@ export default function Library({ application }) {
7576
{ id: "python", name: _("Python"), index: 2 },
7677
{ id: "rust", name: _("Rust"), index: 3 },
7778
{ id: "vala", name: _("Vala"), index: 4 },
78-
{ id: "typescript", name: _("TypeScript"), index: 5 },
7979
];
80+
if (isTypeScriptEnabled()) {
81+
languages.push({ id: "typescript", name: _("TypeScript"), index: 5 });
82+
}
8083
const languages_by_id = Object.fromEntries(
8184
languages.map((language) => [language.id, language]),
8285
);

src/window.blp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,7 @@ Adw.ApplicationWindow window {
180180
}
181181

182182
DropDown dropdown_code_lang {
183-
model: StringList {
184-
strings [
185-
"JavaScript",
186-
"Vala",
187-
"Rust",
188-
"Python",
189-
"TypeScript",
190-
]
191-
};
183+
model: StringList {};
192184

193185
tooltip-text: _("Switch Document");
194186
}

src/window.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
Extensions,
3232
isRustAvailable,
3333
isTypeScriptAvailable,
34+
isTypeScriptEnabled,
3435
isValaAvailable,
3536
} from "./Extensions/Extensions.js";
3637
import { Permissions } from "./Permissions/Permissions.js";
@@ -70,6 +71,14 @@ export default function Window({ application, session }) {
7071
});
7172
Permissions({ window });
7273

74+
const dropdown_code_lang = builder.get_object("dropdown_code_lang");
75+
for (const lang of ["JavaScript", "Vala", "Rust", "Python"]) {
76+
dropdown_code_lang.model.append(lang);
77+
}
78+
if (isTypeScriptEnabled()) {
79+
dropdown_code_lang.model.append("TypeScript");
80+
}
81+
7382
// Popover menu theme switcher
7483
const button_menu = builder.get_object("button_menu");
7584
const popover = button_menu.get_popover();

0 commit comments

Comments
 (0)