Skip to content

Commit 9615112

Browse files
committed
feat(touchedPlanModal): Update the styles of touched files.
1 parent d844324 commit 9615112

File tree

3 files changed

+67
-20
lines changed

3 files changed

+67
-20
lines changed

src/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export default class InvioPlugin extends Plugin {
341341
// The operations above are almost read only and kind of safe.
342342
// The operations below begins to write or delete (!!!) something.
343343
await insertSyncPlanRecordByVault(this.db, plan, this.vaultRandomID);
344+
let view: StatsView;
344345
if (triggerSource !== "dry") {
345346
// getNotice(
346347
// t("syncrun_step7", {
@@ -352,7 +353,7 @@ export default class InvioPlugin extends Plugin {
352353
// if we are at the root path export all files, otherwise only export files in the folder we are exporting
353354
allFiles = allFiles.filter((file: TFile) => new Path(file.path).directory.asString.startsWith(basePath.asString) && (file.extension === "md") && (!file.name.endsWith('.conflict.md')));
354355
// Make functions of StatsView static
355-
const view = await HTMLGenerator.beginBatch(this, allFiles);
356+
view = await HTMLGenerator.beginBatch(this, allFiles);
356357
log.info('init stats view: ', view);
357358
if (view) {
358359
const initData: Record<string, FileOrFolderMixedState> = {};
@@ -503,6 +504,10 @@ export default class InvioPlugin extends Plugin {
503504
maxSteps: `${MAX_STEPS}`,
504505
})
505506
);
507+
view?.info(t("syncrun_step8", {
508+
maxSteps: `${MAX_STEPS}`,
509+
}));
510+
506511
this.syncStatus = "finish";
507512
this.syncStatus = "idle";
508513

src/touchedPlanModel.ts

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { App, Modal, Notice, PluginSettingTab, Setting } from "obsidian";
22
import type InvioPlugin from "./main"; // unavoidable
33
import type { TransItemType } from "./i18n";
4-
import { createElement, FilePlus2, Trash, ArrowDownToLine, ArrowUpToLine } from "lucide";
4+
import { createElement, FilePlus2, Trash, ArrowDownToLine, ArrowUpToLine, FileText } from "lucide";
55

66
import { log } from "./moreOnLog";
77
import { FileOrFolderMixedState } from "./baseTypes";
@@ -71,20 +71,28 @@ export class TouchedPlanModel extends Modal {
7171
});
7272
const ulRemote = contentEl.createEl("ul");
7373
toRemoteFiles.forEach((val) => {
74-
const li = ulRemote.createEl("li", {
75-
text: val.key,
76-
cls: 'file-item-action'
77-
});
78-
if (val.decision === 'uploadLocalToRemote') {
79-
const iconSvgCreate = createElement(FilePlus2);
80-
iconSvgCreate.addClass('file-item-action-icon')
81-
li.appendChild(iconSvgCreate)
82-
} else {
83-
const iconSvgTrash = createElement(Trash);
84-
iconSvgTrash.addClass('file-item-action-icon')
85-
li.appendChild(iconSvgTrash)
86-
}
74+
const li = ulRemote.createEl('li', {
75+
cls: 'file-item-action'
76+
});
77+
const fileIcon = createElement(FileText);
78+
fileIcon.addClass('file-item-action-prefix')
79+
li.appendChild(fileIcon);
80+
81+
li.createEl('span', {
82+
text: val.key,
83+
cls: 'file-item-action-name'
8784
});
85+
86+
if (val.decision === 'uploadLocalToRemote') {
87+
const iconSvgCreate = createElement(FilePlus2);
88+
iconSvgCreate.addClass('file-item-action-icon')
89+
li.appendChild(iconSvgCreate)
90+
} else {
91+
const iconSvgTrash = createElement(Trash);
92+
iconSvgTrash.addClass('file-item-action-icon')
93+
li.appendChild(iconSvgTrash)
94+
}
95+
});
8896
}
8997

9098

@@ -94,10 +102,18 @@ export class TouchedPlanModel extends Modal {
94102
});
95103
const ulLocal = contentEl.createEl("ul");
96104
toLocalFiles.forEach((val) => {
97-
const li = ulLocal.createEl("li", {
98-
text: val.key,
105+
const li = ulLocal.createEl('li', {
99106
cls: 'file-item-action'
100107
});
108+
const fileIcon = createElement(FileText);
109+
fileIcon.addClass('file-item-action-prefix')
110+
li.appendChild(fileIcon);
111+
112+
li.createEl('span', {
113+
text: val.key,
114+
cls: 'file-item-action-name'
115+
});
116+
101117
if (val.decision === 'downloadRemoteToLocal') {
102118
const iconSvgCreate = createElement(FilePlus2);
103119
iconSvgCreate.addClass('file-item-action-icon')
@@ -116,10 +132,18 @@ export class TouchedPlanModel extends Modal {
116132
});
117133
const ulConflict = contentEl.createEl("ul");
118134
conflictFiles.forEach((val) => {
119-
const li = ulConflict.createEl("li", {
120-
text: val.key,
135+
const li = ulConflict.createEl('li', {
121136
cls: 'file-item-action'
122137
});
138+
const fileIcon = createElement(FileText);
139+
fileIcon.addClass('file-item-action-prefix')
140+
li.appendChild(fileIcon);
141+
142+
li.createEl('span', {
143+
text: val.key,
144+
cls: 'file-item-action-name'
145+
});
146+
123147
if (val.decision === 'downloadRemoteToLocal') {
124148
const iconSvgSyncDown = createElement(ArrowDownToLine);
125149
iconSvgSyncDown.addClass('file-item-action-icon')

styles.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,30 @@
150150

151151
.file-item-action {
152152
margin: 8px auto;
153+
width: 100%;
153154
display: flex;
154-
justify-content: flex-start;
155+
justify-content: space-between;
155156
align-items: center;
157+
color: currentColor;
158+
border-bottom: 1px solid var(--divider-color);
159+
padding: 8px 2px;
160+
}
161+
.file-item-action-name {
162+
flex: 1 1 auto;
163+
font-size: small;
164+
overflow: hidden;
165+
text-overflow: ellipsis;
166+
}
167+
.file-item-action-prefix {
168+
flex: 0 0 auto;
169+
font-size: var(--font-text-size);
170+
width: var(--font-text-size);
171+
height: var(--font-text-size);
172+
margin-right: 4px;
156173
}
157174

158175
.file-item-action-icon {
176+
flex: 0 0 auto;
159177
font-size: var(--font-text-size);
160178
width: var(--font-text-size);
161179
height: var(--font-text-size);

0 commit comments

Comments
 (0)