|
2 | 2 | import './home.scss'; |
3 | 3 | import type { Disposable } from 'vscode'; |
4 | 4 | import type { State } from '../../home/protocol'; |
5 | | -import { DidChangeOrgSettingsType, DidChangeRepositoriesType, DidChangeSubscriptionType } from '../../home/protocol'; |
| 5 | +import { |
| 6 | + CollapseSectionCommandType, |
| 7 | + DidChangeOrgSettingsType, |
| 8 | + DidChangeRepositoriesType, |
| 9 | + DidChangeSubscriptionType, |
| 10 | +} from '../../home/protocol'; |
6 | 11 | import type { IpcMessage } from '../../protocol'; |
7 | 12 | import { ExecuteCommandType, onIpc } from '../../protocol'; |
8 | 13 | import { App } from '../shared/appBase'; |
@@ -33,6 +38,9 @@ export class HomeApp extends App<State> { |
33 | 38 | disposables.push( |
34 | 39 | DOM.on('[data-action]', 'click', (e, target: HTMLElement) => this.onDataActionClicked(e, target)), |
35 | 40 | DOM.on('[data-requires="repo"]', 'click', (e, target: HTMLElement) => this.onRepoFeatureClicked(e, target)), |
| 41 | + DOM.on('[data-section-toggle]', 'click', (e, target: HTMLElement) => |
| 42 | + this.onSectionToggleClicked(e, target), |
| 43 | + ), |
36 | 44 | ); |
37 | 45 |
|
38 | 46 | return disposables; |
@@ -89,6 +97,19 @@ export class HomeApp extends App<State> { |
89 | 97 | } |
90 | 98 | } |
91 | 99 |
|
| 100 | + private onSectionToggleClicked(_e: MouseEvent, _target: HTMLElement) { |
| 101 | + // const section = target.dataset.sectionToggle; |
| 102 | + // if (section === 'walkthrough') { |
| 103 | + this.state.walkthroughCollapsed = !this.state.walkthroughCollapsed; |
| 104 | + this.setState(this.state); |
| 105 | + this.updateCollapsedSections(this.state.walkthroughCollapsed); |
| 106 | + this.sendCommand(CollapseSectionCommandType, { |
| 107 | + section: 'walkthrough', |
| 108 | + collapsed: this.state.walkthroughCollapsed, |
| 109 | + }); |
| 110 | + // } |
| 111 | + } |
| 112 | + |
92 | 113 | private updateNoRepo() { |
93 | 114 | const { |
94 | 115 | repositories: { openCount, hasUnsafe, trusted }, |
@@ -129,10 +150,15 @@ export class HomeApp extends App<State> { |
129 | 150 | setElementVisibility('org-settings-drafts', drafts); |
130 | 151 | } |
131 | 152 |
|
| 153 | + private updateCollapsedSections(toggle = this.state.walkthroughCollapsed) { |
| 154 | + document.getElementById('section-walkthrough')!.classList.toggle('is-collapsed', toggle); |
| 155 | + } |
| 156 | + |
132 | 157 | private updateState() { |
133 | 158 | this.updateNoRepo(); |
134 | 159 | this.updatePromos(); |
135 | 160 | this.updateOrgSettings(); |
| 161 | + this.updateCollapsedSections(); |
136 | 162 | } |
137 | 163 | } |
138 | 164 |
|
|
0 commit comments