|
12 | 12 |
|
13 | 13 | // Manager
|
14 | 14 |
|
15 |
| -Manager::Manager(const ftxui::Component& infoView, const ftxui::Component& filterView, const ftxui::Component& promotionView) { |
| 15 | +Manager::Manager(const ftxui::Component& infoView, const ftxui::Component& filterView) { |
16 | 16 | using namespace ftxui;
|
17 | 17 |
|
18 | 18 | tabSelection = Menu(&tab_entries, &tab_index, MenuOption::HorizontalAnimated());
|
19 | 19 |
|
20 | 20 | tabContent = Container::Tab({
|
21 | 21 | infoView,
|
22 |
| - filterView, |
23 |
| - promotionView |
| 22 | + filterView |
24 | 23 | },
|
25 | 24 | &tab_index);
|
26 | 25 |
|
@@ -102,112 +101,3 @@ ftxui::Element CommitInfoManager::renderInfoView(const cpplibostree::Commit& dis
|
102 | 101 | filler()
|
103 | 102 | });
|
104 | 103 | }
|
105 |
| - |
106 |
| -// ContentPromotionManager |
107 |
| - |
108 |
| -ContentPromotionManager::ContentPromotionManager(bool show_tooltips): show_tooltips(show_tooltips) { |
109 |
| - using namespace ftxui; |
110 |
| - |
111 |
| - subjectComponent = Input(&newSubject, "subject"); |
112 |
| -} |
113 |
| - |
114 |
| -void ContentPromotionManager::setBranchRadiobox(ftxui::Component radiobox) { |
115 |
| - using namespace ftxui; |
116 |
| - |
117 |
| - branchSelection = CatchEvent(radiobox, [&](const Event& event) { |
118 |
| - // copy commit id |
119 |
| - if (event == Event::Return) { |
120 |
| - subjectComponent->TakeFocus(); |
121 |
| - } |
122 |
| - return false; |
123 |
| - }); |
124 |
| -} |
125 |
| - |
126 |
| -void ContentPromotionManager::setApplyButton(ftxui::Component button) { |
127 |
| - applyButton = button; |
128 |
| -} |
129 |
| - |
130 |
| -ftxui::Elements ContentPromotionManager::renderPromotionCommand(cpplibostree::OSTreeRepo& ostreeRepo, const std::string& selectedCommitHash) { |
131 |
| - using namespace ftxui; |
132 |
| - |
133 |
| - assert(branchSelection); |
134 |
| - assert(applyButton); |
135 |
| - |
136 |
| - Elements line; |
137 |
| - line.push_back(text("ostree commit") | bold); |
138 |
| - line.push_back(text(" --repo=" + ostreeRepo.getRepoPath()) | bold); |
139 |
| - line.push_back(text(" -b " + ostreeRepo.getBranches().at(static_cast<size_t>(selectedBranch))) | bold); |
140 |
| - line.push_back(text(" --keep-metadata") | bold); |
141 |
| - // optional subject |
142 |
| - if (!newSubject.empty()) { |
143 |
| - line.push_back(text(" -s \"") | bold); |
144 |
| - line.push_back(text(newSubject) | color(Color::BlueLight) | bold); |
145 |
| - line.push_back(text("\"") | bold); |
146 |
| - } |
147 |
| - // commit |
148 |
| - line.push_back(text(" --tree=ref=" + selectedCommitHash) | bold); |
149 |
| - |
150 |
| - return line; |
151 |
| -} |
152 |
| - |
153 |
| -ftxui::Component ContentPromotionManager::composePromotionComponent() { |
154 |
| - using namespace ftxui; |
155 |
| - |
156 |
| - return Container::Vertical({ |
157 |
| - branchSelection, |
158 |
| - Container::Vertical({ |
159 |
| - subjectComponent, |
160 |
| - applyButton, |
161 |
| - }), |
162 |
| - }); |
163 |
| -} |
164 |
| - |
165 |
| -ftxui::Element ContentPromotionManager::renderPromotionView(cpplibostree::OSTreeRepo& ostreeRepo, int screenHeight, const cpplibostree::Commit& displayCommit) { |
166 |
| - using namespace ftxui; |
167 |
| - |
168 |
| - assert(branchSelection); |
169 |
| - assert(applyButton); |
170 |
| - |
171 |
| - // compute screen element sizes |
172 |
| - int screenOverhead {8}; // borders, footer, etc. |
173 |
| - int commitWinHeight {3}; |
174 |
| - int apsectWinHeight {8}; |
175 |
| - int tooltipsWinHeight {2}; |
176 |
| - int branchSelectWinHeight = screenHeight - screenOverhead - commitWinHeight - apsectWinHeight - tooltipsWinHeight; |
177 |
| - // tooltips only get shown, if the window is sufficiently large |
178 |
| - if (branchSelectWinHeight < 4) { |
179 |
| - tooltipsWinHeight = 0; |
180 |
| - branchSelectWinHeight = 4; |
181 |
| - } |
182 |
| - |
183 |
| - // build elements |
184 |
| - auto commitHashElem = vbox({text(" Commit: ") | bold | color(Color::Green), text(" " + displayCommit.hash)}) | flex; |
185 |
| - auto branchWin = window(text("New Branch"), branchSelection->Render() | vscroll_indicator | frame); |
186 |
| - auto subjectWin = window(text("Subject"), subjectComponent->Render()) | flex; |
187 |
| - auto applyButtonWin = applyButton->Render() | color(Color::Green) | size(WIDTH, GREATER_THAN, 9) | flex; |
188 |
| - |
189 |
| - auto toolTipContent = [&](size_t tip) { |
190 |
| - return vbox({ |
191 |
| - separatorCharacter("⎯"), |
192 |
| - text(" 🛈 " + tool_tip_strings.at(tip)), |
193 |
| - }); |
194 |
| - }; |
195 |
| - auto toolTipsWin = !show_tooltips || tooltipsWinHeight < 2 ? filler() : // only show if screen is reasonable size |
196 |
| - branchSelection->Focused() ? toolTipContent(0) : |
197 |
| - subjectComponent->Focused() ? toolTipContent(1) : |
198 |
| - applyButton->Focused() ? toolTipContent(2) : |
199 |
| - filler(); |
200 |
| - |
201 |
| - // build element composition |
202 |
| - return vbox({ |
203 |
| - commitHashElem | size(HEIGHT, EQUAL, commitWinHeight), |
204 |
| - branchWin | size(HEIGHT, LESS_THAN, branchSelectWinHeight), |
205 |
| - vbox({ |
206 |
| - subjectWin, |
207 |
| - applyButtonWin, |
208 |
| - }) | flex | size(HEIGHT, LESS_THAN, apsectWinHeight), |
209 |
| - hflow(renderPromotionCommand(ostreeRepo, displayCommit.hash)) | flex_grow, |
210 |
| - filler(), |
211 |
| - toolTipsWin, |
212 |
| - }) | flex_grow; |
213 |
| -} |
0 commit comments