Skip to content

Commit 9059125

Browse files
jwunderlCopilot
andauthored
add Import as asset Pack to github extension zone (microsoft#11080)
* add Import as asset Pack to github extension zone * forgot updateConfigAsync exists, easier * don't need to wrap updateConfigAsync like that * Update webapp/src/gitjson.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert copilot suggestion "Update webapp/src/gitjson.tsx", updateConfigAsync does not return truthy This reverts commit cf70adb. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0acbdca commit 9059125

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎webapp/src/gitjson.tsx‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import UserInfo = pxt.editor.UserInfo;
2020

2121
import { Accordion } from "../../react-common/components/controls/Accordion";
2222
import { Button } from "../../react-common/components/controls/Button"
23+
import { Checkbox } from "../../react-common/components/controls/Checkbox";
2324

2425
const MAX_COMMIT_DESCRIPTION_LENGTH = 70;
2526

@@ -63,6 +64,16 @@ class GithubComponent extends data.Component<GithubProps, GithubState> {
6364
this.handleGithubError = this.handleGithubError.bind(this);
6465
this.handlePullRequest = this.handlePullRequest.bind(this);
6566
this.handleSignoutGithub = this.handleSignoutGithub.bind(this);
67+
this.togglePxtJsonOption = this.togglePxtJsonOption.bind(this);
68+
}
69+
70+
public async togglePxtJsonOption(option: pxt.PxtJsonOption, checked: boolean) {
71+
if (option.type !== "checkbox") return;
72+
73+
await pkg.mainEditorPkg().updateConfigAsync(cfg => {
74+
(cfg as any)[option.property] = checked;
75+
});
76+
this.forceUpdate();
6677
}
6778

6879
clearCacheDiff(cachePrefix?: string, f?: DiffFile) {
@@ -1497,6 +1508,8 @@ class ExtensionZone extends sui.StatelessUIElement<GitHubViewProps> {
14971508
/^LICENSE/.test(f.path.toUpperCase()) || /^COPYING/.test(f.path.toUpperCase()))
14981509
const testurl = header && `${window.location.href.replace(/#.*$/, '')}#testproject:${header.id}`;
14991510
const showFork = user && user.id != githubId.owner;
1511+
const pxtJsonOptions = pxt.appTarget.appTheme?.pxtJsonOptions || [];
1512+
const cfg = pkg.mainPkg.config;
15001513

15011514
const inverted = !!pxt.appTarget.appTheme.invertedGitHub;
15021515
return <div className={`ui transparent ${inverted ? 'inverted' : ''} segment`}>
@@ -1543,6 +1556,20 @@ class ExtensionZone extends sui.StatelessUIElement<GitHubViewProps> {
15431556
{sui.helpIconLink("/github/offline", lf("Learn more about offline support for extensions."))}
15441557
</span>
15451558
</div>
1559+
{pxtJsonOptions.map(option => {
1560+
const checked = !!cfg?.[option.property as keyof pxt.PackageConfig];
1561+
return (
1562+
<div className="ui field" key={option.property}>
1563+
<Checkbox
1564+
id={`ext-opt-${option.property}`}
1565+
label={pxt.Util.rlf(`{id:setting}${option.label}`)}
1566+
isChecked={checked}
1567+
onChange={value => this.props.parent.togglePxtJsonOption(option, value)}
1568+
style="toggle"
1569+
/>
1570+
</div>
1571+
);
1572+
})}
15461573
</div>
15471574
}
15481575
}

0 commit comments

Comments
 (0)