Skip to content

Commit

Permalink
Exclude Playground link in production builds
Browse files Browse the repository at this point in the history
  • Loading branch information
gingi committed May 2, 2023
1 parent fc35a11 commit 83b308c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,24 @@ describe("ProfileButtonComponent", () => {
fixture.detectChanges();
expect(contextMenuServiceSpy.openMenu).toHaveBeenCalledOnce();
const items = contextMenuServiceSpy.lastMenu.items;
expect(items.length).toBe(13);
expect(items.length).toBe(14);
});

describe("Clicking on the profile", () => {
it("It shows a context menu", () => {
click(clickableEl);
expect(contextMenuServiceSpy.openMenu).toHaveBeenCalled();
const items = contextMenuServiceSpy.lastMenu.items;
expect(items.length).toEqual(13);
expect(items.length).toEqual(14);

let i = 0;
const expectMenuItem= (menuItemType, label?) => {
const menuItem = items[i++];
expect(menuItem instanceof menuItemType).toBe(true);
const expectMenuItem = (menuItemType, label?) => {
const menuItem = items[i++] as any;
expect(menuItem instanceof menuItemType)
.withContext(`Item ${i} [${menuItem.label}] is not a ${
menuItemType.name}`).toBe(true);
if (label) {
expect((menuItem as any).label).toEqual(label);
expect(menuItem.label).toEqual(label);
}
}

Expand All @@ -155,12 +157,13 @@ describe("ProfileButtonComponent", () => {
expectMenuItem(ContextMenuItem, "profile-button.authentication");
expectMenuItem(ContextMenuItem, "profile-button.keybindings");
expectMenuItem(MultiContextMenuItem, "Language (Preview)");
expectMenuItem(MultiContextMenuItem, "Developer");
expectMenuItem(ContextMenuItem, "profile-button.thirdPartyNotices");
expectMenuItem(ContextMenuItem, "profile-button.viewLogs");
expectMenuItem(ContextMenuItem, "profile-button.report");
expectMenuItem(ContextMenuItem, "profile-button.about");
expectMenuItem(ContextMenuSeparator);
expectMenuItem(MultiContextMenuItem, "Developer");
expectMenuItem(ContextMenuSeparator);
expectMenuItem(ContextMenuItem, "profile-button.logout");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,36 @@ export class ProfileButtonComponent implements OnDestroy, OnInit {
new ContextMenuItem({ label: this.i18n.t("profile-button.viewLogs"), click: () => this._openLogFolder() }),
new ContextMenuItem({ label: this.i18n.t("profile-button.report"), click: () => this._openGithubIssues() }),
new ContextMenuItem({ label: this.i18n.t("profile-button.about"), click: () => this._showAboutPage() }),
new ContextMenuSeparator(),
new ContextMenuItem({ label: this.i18n.t("profile-button.logout"), click: () => this._logout() }),

];

// Add the playground and theme menu items only in dev mode
if (isDevMode()) {
const devMenuItem = new MultiContextMenuItem({
label: "Developer",
subitems: [
new ContextMenuItem({ label: this.i18n.t("profile-button.viewTheme"), click: () => this._gotoThemeColors() })
],
});
items.splice(5, 0, devMenuItem);
items.push(
new ContextMenuSeparator(),
new MultiContextMenuItem({
label: "Developer",
subitems: [
new ContextMenuItem({
label: this.i18n.t("profile-button.viewTheme"),
click: () => this._gotoThemeColors()
}),
new ContextMenuItem({
label: this.i18n.t("profile-button.playground"),
click: () => this._gotoPlayground()
}),
],
})
);
}

items.push(
new ContextMenuSeparator(),
new ContextMenuItem({
label: this.i18n.t("profile-button.logout"),
click: () => this._logout()
})
);

items.unshift(this._getAutoUpdateMenuItem());
this.contextMenuService.openMenu(new ContextMenu(items));
}
Expand Down

0 comments on commit 83b308c

Please sign in to comment.