144 | ${pulls.map((item) => {
145 | if (!has_pinned || parseInt(this.filteredPull, 10) !== item.public_id) {
146 | return html``;
147 | }
148 |
149 | let author = null;
150 | if (typeof this.authors[item.authored_by] != "undefined") {
151 | author = this.authors[item.authored_by];
152 | }
153 |
154 | return html`
155 |
172 | `;
173 | })}
174 |
175 |
189 |
190 | ${pulls.map((item) => {
191 | if (has_pinned && parseInt(this.filteredPull, 10) === item.public_id) {
192 | return html``;
193 | }
194 |
195 | let author = null;
196 | if (typeof this.authors[item.authored_by] != "undefined") {
197 | author = this.authors[item.authored_by];
198 | }
199 |
200 | return html`
201 |
218 | `;
219 | })}
220 |
221 | `;
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/src/paths/index/components/files/FileList.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css, customElement, property } from 'lit-element';
2 |
3 | import RootItem from "./RootItem"
4 | import FileItem from "./FileItem";
5 |
6 | @customElement('gr-file-list')
7 | export default class FileList extends LitElement {
8 | static get styles() {
9 | return css`
10 | /** Colors and variables **/
11 | :host {
12 | --files-background-color: #fcfcfa;
13 | --files-border-color: #515c6c;
14 | }
15 | @media (prefers-color-scheme: dark) {
16 | :host {
17 | --files-background-color: #0d1117;
18 | --files-border-color: #515c6c;
19 | }
20 | }
21 |
22 | /** Component styling **/
23 | :host {
24 | position: relative;
25 | }
26 |
27 | :host .file-list {
28 | background-color: var(--files-background-color);
29 | border-right: 2px solid var(--files-border-color);
30 | width: 320px;
31 | min-height: 216px;
32 | }
33 |
34 | :host .file-list-folder .file-list-folder {
35 | margin-left: 12px;
36 | }
37 |
38 | :host .branch-selector {
39 | display: none;
40 | position: absolute;
41 | top: 32px;
42 | left: 0;
43 | right: 0;
44 | flex-direction: column;
45 | gap: 4px;
46 | background-color: var(--g-background-extra2-color);
47 | border-top: 2px solid var(--g-background-color);
48 | border-bottom: 2px solid var(--g-background-color);
49 | padding: 10px 14px;
50 | }
51 | :host .branch-selector.branch-selector--active {
52 | display: flex;
53 | }
54 |
55 | :host .branch-selector ul {
56 | display: flex;
57 | flex-direction: column;
58 | align-items: flex-end;
59 | gap: 2px;
60 | list-style: none;
61 | margin: 0;
62 | padding: 0;
63 | }
64 |
65 | :host .branch-selector ul li {
66 | color: var(--link-font-color);
67 | cursor: pointer;
68 | padding: 2px 0;
69 | }
70 | :host .branch-selector ul li:hover {
71 | color: var(--link-font-color-hover);
72 | }
73 |
74 | @media only screen and (max-width: 900px) {
75 | :host {
76 | width: 100%
77 | }
78 |
79 | :host .file-list {
80 | width: 100% !important;
81 | }
82 |
83 | :host .branch-selector {
84 | border-top-width: 4px;
85 | border-bottom-width: 4px;
86 | font-size: 105%;
87 | padding: 16px 24px;
88 | top: 40px;
89 | }
90 |
91 | :host .branch-selector ul {
92 | gap: 4px;
93 | }
94 |
95 | :host .branch-selector ul li {
96 | padding: 4px 8px;
97 | }
98 | }
99 | `;
100 | }
101 |
102 | @property({ type: Array }) branches = [];
103 | @property({ type: Object }) files = {};
104 |
105 | @property({ type: String }) selectedRepository = "godotengine/godot";
106 | @property({ type: String }) selectedBranch = "master";
107 | @property({ type: String }) selectedPath = "";
108 | @property({ type: Array }) selectedFolders = [];
109 | @property({ type: String }) filteredPull = "";
110 |
111 | constructor() {
112 | super();
113 |
114 | this._branchSelectorActive = false;
115 | }
116 |
117 | _onBranchClicked() {
118 | this._branchSelectorActive = !this._branchSelectorActive;
119 | this.requestUpdate();
120 | }
121 |
122 | _onBranchSelected(branchName) {
123 | this._branchSelectorActive = false;
124 |
125 | if (this.selectedBranch !== branchName) {
126 | this.selectedFolders = [];
127 | }
128 |
129 | this.requestUpdate();
130 |
131 | this.dispatchEvent(greports.util.createEvent("branchselect", {
132 | "branch": branchName,
133 | }));
134 | }
135 |
136 | _toggleEntry(entryType, entryPath, failOnMatch) {
137 | if (entryType === "root") {
138 | this.selectedFolders = [];
139 |
140 | this.requestUpdate();
141 | } else if (entryType === "folder") {
142 | const entryIndex = this.selectedFolders.indexOf(entryPath);
143 | if (entryIndex >= 0) {
144 | if (!failOnMatch) {
145 | this.selectedFolders.splice(entryIndex, 1);
146 | }
147 | } else {
148 | this.selectedFolders.push(entryPath);
149 | }
150 |
151 | this.requestUpdate();
152 | }
153 | }
154 |
155 | _onItemClicked(entryType, entryPath, entryPulls) {
156 | this._toggleEntry(entryType, entryPath, true);
157 |
158 | this.dispatchEvent(greports.util.createEvent("pathclick", {
159 | "type": entryType,
160 | "path": entryPath,
161 | "pulls": entryPulls,
162 | }));
163 | }
164 |
165 | _onItemIconClicked(entryType, entryPath, entryPulls) {
166 | this._toggleEntry(entryType, entryPath, false);
167 |
168 | if (entryType === "root" || entryType === "file") {
169 | this.dispatchEvent(greports.util.createEvent("pathclick", {
170 | "type": entryType,
171 | "path": entryPath,
172 | "pulls": entryPulls,
173 | }));
174 | }
175 | }
176 |
177 | renderFolder(branchFiles, folderFiles) {
178 | return html`
179 |
180 | ${(folderFiles.length > 0) ?
181 | folderFiles.map((item) => {
182 | if (this.filteredPull !== "" && !item.pulls.includes(parseInt(this.filteredPull, 10))) {
183 | return html``;
184 | }
185 |
186 | return html`
187 |
188 |
197 |
198 | ${(this.selectedFolders.includes(item.path)) ?
199 | this.renderFolder(branchFiles, branchFiles[item.path] || []) : null
200 | }
201 |
202 | `;
203 | }) : html`
204 |
This path is empty
205 | `
206 | }
207 |
208 | `;
209 | }
210 |
211 | render() {
212 | const branchFiles = this.files[this.selectedBranch];
213 | const topLevel = branchFiles[""] || [];
214 |
215 | const branchesClassList = [ "branch-selector" ];
216 | if (this._branchSelectorActive) {
217 | branchesClassList.push("branch-selector--active");
218 | }
219 |
220 | return html`
221 |