@noldova/git.window 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/package.json +10 -10
  2. package/src/api/index.d.ts +53 -4
  3. package/src/api/index.js +1 -0
  4. package/src/api/index.js.map +1 -1
  5. package/src/app/components/git-account-dialog/git-account-dialog.component.js +3 -3
  6. package/src/app/components/git-accounts/git-accounts.component.js +3 -3
  7. package/src/app/components/git-agents/git-agents.component.js +3 -3
  8. package/src/app/components/git-branch-card/git-branch-card.component.js +3 -3
  9. package/src/app/components/git-branch-drop/git-branch-drop.component.js +3 -3
  10. package/src/app/components/git-bulk-branch-dialog/git-bulk-branch-dialog.component.js +3 -3
  11. package/src/app/components/git-bulk-push-dialog/git-bulk-push-dialog.component.js +3 -3
  12. package/src/app/components/git-clone-dialog/git-clone-dialog.component.js +6 -10
  13. package/src/app/components/git-clone-dialog/git-clone-dialog.component.js.map +1 -1
  14. package/src/app/components/git-command-log/git-command-log.component.js +3 -3
  15. package/src/app/components/git-commit-card/git-commit-card.component.js +3 -3
  16. package/src/app/components/git-commit-detail/git-commit-detail.component.js +3 -3
  17. package/src/app/components/git-commit-detail-view/git-commit-detail-view.component.js +3 -3
  18. package/src/app/components/git-commit-document/git-commit-document.component.js +3 -3
  19. package/src/app/components/git-conflict-detail/git-conflict-detail.component.js +3 -3
  20. package/src/app/components/git-conflicts/git-conflicts.component.js +5 -5
  21. package/src/app/components/git-conflicts/git-conflicts.component.js.map +1 -1
  22. package/src/app/components/git-dashboard/git-dashboard.component.js +3 -3
  23. package/src/app/components/git-diff-files/git-diff-files.component.js +3 -3
  24. package/src/app/components/git-discard-dialog/git-discard-dialog.component.js +3 -3
  25. package/src/app/components/git-file-group/git-file-group.component.js +3 -3
  26. package/src/app/components/git-file-layout-button/git-file-layout-button.component.js +3 -3
  27. package/src/app/components/git-force-push-dialog/git-force-push-dialog.component.js +3 -3
  28. package/src/app/components/git-history/git-history.component.js +29 -15
  29. package/src/app/components/git-history/git-history.component.js.map +1 -1
  30. package/src/app/components/git-host-row/git-host-row.component.js +3 -3
  31. package/src/app/components/git-person-avatar/git-person-avatar.component.js +3 -3
  32. package/src/app/components/git-pull-request-commits/git-pull-request-commits.component.js +3 -3
  33. package/src/app/components/git-pull-request-conflicts/git-pull-request-conflicts.component.js +3 -3
  34. package/src/app/components/git-pull-request-files/git-pull-request-files.component.js +3 -3
  35. package/src/app/components/git-pull-request-threads/git-pull-request-threads.component.js +11 -12
  36. package/src/app/components/git-pull-request-threads/git-pull-request-threads.component.js.map +1 -1
  37. package/src/app/components/git-pull-requests/git-pull-requests.component.js +3 -3
  38. package/src/app/components/git-rebase/git-rebase.component.js +3 -3
  39. package/src/app/components/git-rebase-preview/git-rebase-preview.component.js +3 -3
  40. package/src/app/components/git-reference-text/git-reference-text.component.js +3 -3
  41. package/src/app/components/git-repository/git-repository.component.js +19 -17
  42. package/src/app/components/git-repository/git-repository.component.js.map +1 -1
  43. package/src/app/components/git-repository-scan-dialog/git-repository-scan-dialog.component.js +3 -3
  44. package/src/app/components/git-switch-merge-dialog/git-switch-merge-dialog.component.js +3 -3
  45. package/src/app/components/git-undo-menu/git-undo-menu.component.js +3 -3
  46. package/src/app/components/git-view/git-view.component.js +4 -17
  47. package/src/app/components/git-view/git-view.component.js.map +1 -1
  48. package/src/app/components/git-workspace/git-visible.directive.js +3 -3
  49. package/src/app/components/git-workspace/git-workspace.component.js +59 -7
  50. package/src/app/components/git-workspace/git-workspace.component.js.map +1 -1
  51. package/src/app/components/git-workspace-across/git-workspace-across.component.js +3 -3
  52. package/src/app/components/git-workspace-across-view/git-workspace-across-view.component.js +3 -3
  53. package/src/app/components/git-workspaces/git-workspaces.component.js +4 -4
  54. package/src/app/enums/git-workspace-column.js +19 -0
  55. package/src/app/enums/git-workspace-column.js.map +1 -0
  56. package/src/app/models/git-force-push-offer.js +20 -3
  57. package/src/app/models/git-force-push-offer.js.map +1 -1
  58. package/src/app/models/git-workspace-header.js +31 -0
  59. package/src/app/models/git-workspace-header.js.map +1 -0
  60. package/src/app/models/git-workspace-overview.js +11 -0
  61. package/src/app/models/git-workspace-overview.js.map +1 -1
  62. package/src/app/models/git-workspace-page-sort.js +32 -0
  63. package/src/app/models/git-workspace-page-sort.js.map +1 -0
  64. package/src/app/models/git-workspace-row.js +7 -2
  65. package/src/app/models/git-workspace-row.js.map +1 -1
  66. package/src/app/models/git-workspace-sort.js +81 -0
  67. package/src/app/models/git-workspace-sort.js.map +1 -0
  68. package/src/app/services/git-action-notices.js +36 -0
  69. package/src/app/services/git-action-notices.js.map +1 -0
  70. package/src/app/services/git-code-colors.js +3 -3
  71. package/src/app/services/git-recent-repositories.js +18 -6
  72. package/src/app/services/git-recent-repositories.js.map +1 -1
  73. package/src/app/services/git-view-commands.js +46 -3
  74. package/src/app/services/git-view-commands.js.map +1 -1
  75. package/src/app/services/git-view-state.service.js +63 -75
  76. package/src/app/services/git-view-state.service.js.map +1 -1
  77. package/src/app/services/git-window-part.js +4 -1
  78. package/src/app/services/git-window-part.js.map +1 -1
  79. package/src/app/services/git-workspace-sorts.js +43 -0
  80. package/src/app/services/git-workspace-sorts.js.map +1 -0
  81. package/src/app/services/git-workspaces.js +3 -0
  82. package/src/app/services/git-workspaces.js.map +1 -1
  83. package/src/resources.js +49 -0
  84. package/src/resources.js.map +1 -1
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { GitWorkspaceColumn } from "../enums/git-workspace-column.js";
10
+ // A page's order: a column and its direction, as a file manager's panel sorts. A row with nothing in the column, such
11
+ // as one not read yet, goes last in either direction, and rows the column holds alike keep the repositories' order, by
12
+ // name, then by parent folder.
13
+ export class GitWorkspaceSort {
14
+ static byName = new GitWorkspaceSort(GitWorkspaceColumn.Repository, false);
15
+ static collator = new Intl.Collator(undefined, { sensitivity: "base", numeric: true });
16
+ static weight = 1_000_000;
17
+ static moreWeight = 0.5;
18
+ static textColumns = [GitWorkspaceColumn.Repository, GitWorkspaceColumn.Branch, GitWorkspaceColumn.PullRequest];
19
+ column;
20
+ isDescending;
21
+ constructor(column, isDescending) {
22
+ this.column = column;
23
+ this.isDescending = isDescending;
24
+ }
25
+ // The order a header's click gives: its column ascending, or the other way when it's already sorted by it.
26
+ next(column) {
27
+ return new GitWorkspaceSort(column, column === this.column && !this.isDescending);
28
+ }
29
+ apply(rows) {
30
+ const isText = GitWorkspaceSort.textColumns.includes(this.column);
31
+ return [...rows].sort((a, b) => (isText ? this.compareKeys(this.textKeyOf(a), this.textKeyOf(b), GitWorkspaceSort.compareText)
32
+ : this.compareKeys(this.numberKeyOf(a), this.numberKeyOf(b), (left, right) => left - right)) || GitWorkspaceSort.compareText(a.name, b.name)
33
+ || GitWorkspaceSort.compareText(a.parent, b.parent));
34
+ }
35
+ compareKeys(left, right, compare) {
36
+ if (Object.isNull(left) || Object.isNull(right))
37
+ return Number(Object.isNull(left)) - Number(Object.isNull(right));
38
+ const order = compare(left, right);
39
+ return this.isDescending ? -order : order;
40
+ }
41
+ // Repository by name; Branch by name, none for a detached head or a folder not read; Pull request by the pull request's
42
+ // label, none for a branch without one or a host that can't be asked.
43
+ textKeyOf(row) {
44
+ switch (this.column) {
45
+ case GitWorkspaceColumn.Repository:
46
+ return row.name;
47
+ case GitWorkspaceColumn.Branch:
48
+ return row.branch().length === 0 ? null : row.branch();
49
+ default:
50
+ return row.pullRequest()?.label ?? null;
51
+ }
52
+ }
53
+ // Checks by failing checks; Open by how many pull requests are open, more after a full page, none while the host can't
54
+ // be asked.
55
+ numberKeyOf(row) {
56
+ switch (this.column) {
57
+ case GitWorkspaceColumn.Checks:
58
+ return row.checks().length === 0 ? null : row.failing();
59
+ case GitWorkspaceColumn.Open: {
60
+ const listed = row.openListed();
61
+ return Object.isNull(listed) ? null : listed.rows.length + (listed.hasMore ? GitWorkspaceSort.moreWeight : 0);
62
+ }
63
+ default:
64
+ return this.summaryKeyOf(row.summary());
65
+ }
66
+ }
67
+ // Sync by how far behind, then ahead; Changes by conflicts, then files; Fetched by when.
68
+ summaryKeyOf(summary) {
69
+ if (Object.isNull(summary) || summary.isUnread)
70
+ return null;
71
+ if (this.column === GitWorkspaceColumn.Sync)
72
+ return Object.isNull(summary.upstream) ? null : summary.behind * GitWorkspaceSort.weight + summary.ahead;
73
+ if (this.column === GitWorkspaceColumn.Changes)
74
+ return summary.conflicts * GitWorkspaceSort.weight + summary.files;
75
+ return Object.isNull(summary.fetchedAt) ? null : Date.parse(summary.fetchedAt);
76
+ }
77
+ static compareText(left, right) {
78
+ return GitWorkspaceSort.collator.compare(left, right);
79
+ }
80
+ }
81
+ //# sourceMappingURL=git-workspace-sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-workspace-sort.js","sourceRoot":"","sources":["../../../../../../../src/noldova.git.window/src/app/models/git-workspace-sort.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAKtE,sHAAsH;AACtH,uHAAuH;AACvH,+BAA+B;AAC/B,MAAM,OAAO,gBAAgB;IACpB,MAAM,CAAU,MAAM,GAAqB,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAErG,MAAM,CAAU,QAAQ,GAAkB,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/G,MAAM,CAAU,MAAM,GAAW,SAAS,CAAC;IAC3C,MAAM,CAAU,UAAU,GAAW,GAAG,CAAC;IACzC,MAAM,CAAU,WAAW,GAAkC,CAAC,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,CAAC,MAAM,EAAE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AC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChH,CAAC;YACD;gBACE,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,yFAAyF;IACjF,YAAY,CAAC,OAAoC;QACvD,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ;YAC5C,OAAO,IAAI,CAAC;QACd,IAAI,IAAI,CAAC,MAAM,KAAK,kBAAkB,CAAC,IAAI;YACzC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,gBAAgB,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3G,IAAI,IAAI,CAAC,MAAM,KAAK,kBAAkB,CAAC,OAAO;YAC5C,OAAO,OAAO,CAAC,SAAS,GAAG,gBAAgB,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QACrE,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACjF,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,IAAY,EAAE,KAAa;QACpD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { NotificationPost, NotificationSeverity, QualifiedName } from "@noldova/desktop.protocol";
10
+ import { Resources } from "../../resources.js";
11
+ // Git's action results as Desktop's notifications, which toast and stay in the notification list until the person
12
+ // dismisses them: an error for an action refused or failed, a warning for one that went through with something to look
13
+ // at, and a success for one whose end shows nowhere else. Each module posts its own kinds, `<module>.actionFailed`,
14
+ // `<module>.actionWarning` and `<module>.actionDone`, which its manifest declares.
15
+ export class GitActionNotices {
16
+ context;
17
+ module;
18
+ constructor(context, module) {
19
+ this.context = context;
20
+ this.module = module;
21
+ }
22
+ // Titled by the action, as its control names it, with what went wrong as its text and what the person may do next.
23
+ async failAsync(action, message, actions = []) {
24
+ await this.postAsync(Resources.actionFailedKind, action, message, NotificationSeverity.Error, actions);
25
+ }
26
+ async warnAsync(action, message) {
27
+ await this.postAsync(Resources.actionWarningKind, action, message, NotificationSeverity.Warning);
28
+ }
29
+ async succeedAsync(action, message) {
30
+ await this.postAsync(Resources.actionDoneKind, action, message, NotificationSeverity.Success);
31
+ }
32
+ async postAsync(kind, title, text, severity, actions = []) {
33
+ await this.context.postNotificationAsync(new NotificationPost(QualifiedName.parse(`${this.module}${Resources.qualifiedNameSeparator}${kind}`), null, title, text, severity, null, actions, null));
34
+ }
35
+ }
36
+ //# sourceMappingURL=git-action-notices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-action-notices.js","sourceRoot":"","sources":["../../../../../../../src/noldova.git.window/src/app/services/git-action-notices.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAA2B,gBAAgB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG3H,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,kHAAkH;AAClH,uHAAuH;AACvH,oHAAoH;AACpH,mFAAmF;AACnF,MAAM,OAAO,gBAAgB;IACV,OAAO,CAAqB;IAC5B,MAAM,CAAS;IAEhC,YAAmB,OAA2B,EAAE,MAAc;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,mHAAmH;IAC5G,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,OAAe,EAAE,UAAyC,EAAE;QACjG,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzG,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,OAAe;QACpD,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACnG,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,OAAsB;QAC9D,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAChG,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,IAAmB,EAAE,QAA8B,EAAE,UAAyC,EAAE;QACnJ,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,sBAAsB,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAC9J,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -46,10 +46,10 @@ export class GitCodeColors {
46
46
  done(language, tokenizer) {
47
47
  this.loaded.update(t => new Map([...t, [language, tokenizer]]));
48
48
  }
49
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: GitCodeColors, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
50
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: GitCodeColors, providedIn: "root" });
49
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: GitCodeColors, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
50
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: GitCodeColors, providedIn: "root" });
51
51
  }
52
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: GitCodeColors, decorators: [{
52
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: GitCodeColors, decorators: [{
53
53
  type: Injectable,
54
54
  args: [{ providedIn: "root" }]
55
55
  }], ctorParameters: () => [] });
@@ -11,25 +11,37 @@ import { Resources } from "../../resources.js";
11
11
  import { GitWindowStorage } from "./git-window-storage.js";
12
12
  export class GitRecentRepositories {
13
13
  static KEY = "git.recentRepositories";
14
+ static OPENED_KEY = "git.openedRepositories";
14
15
  static LIMIT = 20;
15
16
  static folders = signal([], /* @ts-ignore */
16
17
  ...(ngDevMode ? [{ debugName: "folders" }] : /* istanbul ignore next */ []));
18
+ static openedFolders = signal([], /* @ts-ignore */
19
+ ...(ngDevMode ? [{ debugName: "openedFolders" }] : /* istanbul ignore next */ []));
17
20
  static recent = GitRecentRepositories.folders.asReadonly();
21
+ static opened = GitRecentRepositories.openedFolders.asReadonly();
18
22
  static restore() {
19
- GitRecentRepositories.folders.set(GitWindowStorage.readArray(GitRecentRepositories.KEY).filter(t => Object.isString(t)));
23
+ const recent = GitRecentRepositories.read(GitRecentRepositories.KEY);
24
+ const opened = GitRecentRepositories.read(GitRecentRepositories.OPENED_KEY);
25
+ GitRecentRepositories.folders.set(recent);
26
+ GitRecentRepositories.openedFolders.set([...opened, ...recent.filter(t => !opened.includes(t))]);
20
27
  }
21
28
  static remember(folder) {
22
- GitRecentRepositories.save([folder, ...GitRecentRepositories.folders().filter(t => t !== folder)].slice(0, GitRecentRepositories.LIMIT));
29
+ GitRecentRepositories.save([folder, ...GitRecentRepositories.folders().filter(t => t !== folder)].slice(0, GitRecentRepositories.LIMIT), [folder, ...GitRecentRepositories.openedFolders().filter(t => t !== folder)]);
23
30
  }
24
31
  static forget(folders) {
25
- GitRecentRepositories.save(GitRecentRepositories.folders().filter(t => !folders.has(t)));
32
+ GitRecentRepositories.save(GitRecentRepositories.folders().filter(t => !folders.has(t)), GitRecentRepositories.openedFolders().filter(t => !folders.has(t)));
26
33
  }
27
34
  static nameOf(folder) {
28
35
  return Resources.formatHistoryTitle(folder);
29
36
  }
30
- static save(folders) {
31
- GitRecentRepositories.folders.set(folders);
32
- GitWindowStorage.write(GitRecentRepositories.KEY, [...folders]);
37
+ static read(key) {
38
+ return GitWindowStorage.readArray(key).filter(t => Object.isString(t));
39
+ }
40
+ static save(recent, opened) {
41
+ GitRecentRepositories.folders.set(recent);
42
+ GitRecentRepositories.openedFolders.set(opened);
43
+ GitWindowStorage.write(GitRecentRepositories.KEY, [...recent]);
44
+ GitWindowStorage.write(GitRecentRepositories.OPENED_KEY, [...opened]);
33
45
  }
34
46
  }
35
47
  //# sourceMappingURL=git-recent-repositories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"git-recent-repositories.js","sourceRoot":"","sources":["../../../../../../../src/noldova.git.window/src/app/services/git-recent-repositories.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAe,MAAM,EAAuB,MAAM,eAAe,CAAC;AACzE,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,O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C,GAAG,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC"}
1
+ {"version":3,"file":"git-recent-repositories.js","sourceRoot":"","sources":["../../../../../../../src/noldova.git.window/src/app/services/git-recent-repositories.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAe,MAAM,EAAuB,MAAM,eAAe,CAAC;AACzE,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAU,GAAG,GAAW,wBAAwB,CAAC;IACvD,MAAM,CAAU,UAAU,GAAW,wBAAwB,CAAC;IAC9D,MAAM,CAAU,KAAK,GAAW,EAAE,CAAC;IACnC,MAAM,CAAU,OAAO,GAAsC,MAAM,CAAoB,EAAE;gFAAC,CAAC;IAC3F,MAAM,CAAU,aAAa,GAAsC,MAAM,CAAoB,EAAE;sFAAC,CAAC;IAElG,MAAM,CAAU,MAAM,GAA8B,qBAAqB,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IAC/F,MAAM,CAAU,MAAM,GAA8B,qBAAqB,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;IAErG,MAAM,CAAC,OAAO;QACnB,MAAM,MAAM,GAAsB,qBAAqB,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QACxF,MAAM,MAAM,GAAsB,qBAAqB,CAAC,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAC/F,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1C,qBAAqB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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ChD,gBAAgB,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QAC/D,gBAAgB,CAAC,KAAK,CAAC,qBAAqB,CAAC,UAAU,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC"}
@@ -7,7 +7,10 @@
7
7
  */
8
8
  import { signal } from "@angular/core";
9
9
  import "@noldova/context.core";
10
+ import { JsonReader } from "@noldova/context.json";
10
11
  import { CommandContribution } from "@noldova/desktop.window";
12
+ import { GitViewPhase } from "../enums/git-view-phase.js";
13
+ import { GitForcePushOffer } from "../models/git-force-push-offer.js";
11
14
  import { Resources } from "../../resources.js";
12
15
  export class GitViewCommands {
13
16
  static front = signal(null, /* @ts-ignore */
@@ -19,17 +22,57 @@ export class GitViewCommands {
19
22
  GitViewCommands.front.set(null);
20
23
  };
21
24
  }
22
- static contributions() {
25
+ // The view's commands, and the actions a push-refused notification carries, which take the notices to say why they
26
+ // can't act.
27
+ static contributions(notices) {
23
28
  return [
24
- GitViewCommands.of(Resources.fetchCommand, Resources.fetchTitle, Resources.historyActionIcons.Fetch, null, t => t.canWrite(), t => t.fetchAsync()),
29
+ GitViewCommands.fetch(notices),
25
30
  GitViewCommands.of(Resources.pullCommand, Resources.pullTitle, Resources.pullIcon, null, t => t.canPull(), t => t.pullAsync()),
26
31
  GitViewCommands.of(Resources.pushCommand, Resources.pushTitle, Resources.pushIcon, Resources.pushKey, t => t.canPush(), t => t.pushAsync()),
27
32
  GitViewCommands.of(Resources.stashCommand, Resources.stashTitle, Resources.stashIcon, Resources.stashKey, t => t.canStash(), t => t.stashAsync()),
28
33
  GitViewCommands.of(Resources.stageAllCommand, Resources.stageAllTitle, Resources.stageIcon, null, t => t.canStageAll(), t => t.stageAllAsync()),
29
34
  GitViewCommands.of(Resources.commitCommand, Resources.commitTitle, Resources.commitIcon, null, t => t.canCommit(), t => t.commitAsync(t.commitMessage())),
30
- GitViewCommands.of(Resources.newBranchCommand, Resources.newBranchTitle, Resources.statusBarBranchIcon, Resources.newBranchKey, t => t.canWrite(), t => t.newBranchAsync())
35
+ GitViewCommands.of(Resources.newBranchCommand, Resources.newBranchTitle, Resources.statusBarBranchIcon, Resources.newBranchKey, t => t.canWrite(), t => t.newBranchAsync()),
36
+ GitViewCommands.forcePush(notices)
31
37
  ];
32
38
  }
39
+ // Fetch for the front view's repository, or, with `{ folder }` as a push-refused notification's Fetch runs it, for that
40
+ // folder only.
41
+ static fetch(notices) {
42
+ const plain = GitViewCommands.of(Resources.fetchCommand, Resources.fetchTitle, Resources.historyActionIcons.Fetch, null, t => t.canWrite(), t => t.fetchAsync());
43
+ return new CommandContribution(Resources.fetchCommand, Resources.fetchTitle, Resources.historyActionIcons.Fetch, null, async (commandArguments) => {
44
+ if (Object.isNull(commandArguments))
45
+ return await plain.runAsync(null);
46
+ const folder = JsonReader.fromValue(commandArguments).readString(Resources.fetchFolderField);
47
+ await GitViewCommands.offeredAsync(notices, folder, Resources.fetchOfferLabel, Resources.fetchVerb, async (state) => await state.fetchAsync());
48
+ return null;
49
+ }, commandArguments => !Object.isNull(commandArguments) || plain.isEnabled(null));
50
+ }
51
+ // Only a push-refused notification's Force push runs it, with the offer as its arguments: it is disabled without them, so
52
+ // command search leaves it out, no menu or agent tool names it, and a run without them throws before anything is pushed.
53
+ // It asks first, as the view's own offer did, and pushes only for the folder the front view shows.
54
+ static forcePush(notices) {
55
+ return new CommandContribution(Resources.forcePushChangesCommand, Resources.forcePushLabel, Resources.pushIcon, null, async (commandArguments) => {
56
+ const offer = GitForcePushOffer.fromJson(commandArguments);
57
+ await GitViewCommands.offeredAsync(notices, offer.folder, Resources.forcePushLabel, Resources.forcePushVerb, async (state) => await state.offerForcePushAsync(offer));
58
+ return null;
59
+ }, commandArguments => !Object.isNull(commandArguments));
60
+ }
61
+ // A notification's action acts on its own repository only: with no Git view, or another repository shown, it says to show
62
+ // that repository first; while Git is busy there, during another action or a read, it says to try again after; and when
63
+ // the view couldn't read it, as for a folder that isn't a repository or a Git that is missing, it says so.
64
+ static async offeredAsync(notices, folder, action, verb, act) {
65
+ const state = GitViewCommands.front();
66
+ const title = Resources.formatRepositoryAction(action, folder);
67
+ if (Object.isNull(state) || state.folder() !== folder)
68
+ await notices.warnAsync(title, Resources.formatShowRepositoryFirst(verb, folder));
69
+ else if (state.canWrite())
70
+ await act(state);
71
+ else if (state.busy() || state.phase() === GitViewPhase.Loading)
72
+ await notices.warnAsync(title, Resources.formatRepositoryBusy(verb, folder));
73
+ else
74
+ await notices.warnAsync(title, Resources.formatRepositoryUnread(verb, folder));
75
+ }
33
76
  static of(name, title, icon, key, can, run) {
34
77
  const ready = () => {
35
78
  const state = GitViewCommands.front();
@@ -1 +1 @@
1
- {"version":3,"file":"git-view-commands.js","sourceRoot":"","sources":["../../../../../../../src/noldova.git.window/src/app/services/git-view-commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAC;AAC5D,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,OAAO,eAAe;IAClB,MAAM,CAAU,KAAK,GAA+C,MAAM,CAA6B,IAAI;8EAAC,CAAC;IAE9G,MAAM,CAAC,MAAM,CAAC,KAA0B;QAC7C,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,KAAK;gBACnC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,OAAO;YACL,eAAe,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,UAAU,EAAE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AAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;YACzJ,eAAe,CAAC,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,cAAc,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,EAC/I,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;SAC3B,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,IAAY,EAAE,GAAkB,EAAE,GAA4C,EAC3H,GAAqD;QACrD,MAAM,KAAK,GAAG,GAA+B,EAAE;YAC7C,MAAM,KAAK,GAA+B,eAAe,CAAC,KAAK,EAAE,CAAC;YAClE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5D,CAAC,CAAC;QACF,OAAO,IAAI,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE;YAChE,MAAM,KAAK,GAA+B,KAAK,EAAE,CAAC;YAClD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;gBACvB,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC"}
1
+ {"version":3,"file":"git-view-commands.js","sourceRoot":"","sources":["../../../../../../../src/noldova.git.window/src/app/services/git-view-commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE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,CAAC,IAAY,EAAE,KAAa,EAAE,IAAY,EAAE,GAAkB,EAAE,GAA4C,EAC3H,GAAqD;QACrD,MAAM,KAAK,GAAG,GAA+B,EAAE;YAC7C,MAAM,KAAK,GAA+B,eAAe,CAAC,KAAK,EAAE,CAAC;YAClE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5D,CAAC,CAAC;QACF,OAAO,IAAI,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE;YAChE,MAAM,KAAK,GAA+B,KAAK,EAAE,CAAC;YAClD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;gBACvB,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC"}
@@ -7,9 +7,11 @@
7
7
  */
8
8
  import { computed, DestroyRef, effect, ErrorHandler, inject, Injectable, signal, untracked } from "@angular/core";
9
9
  import "@noldova/context.core";
10
+ import { CommandRun, NotificationAction, QualifiedName } from "@noldova/desktop.protocol";
10
11
  import { WindowPartTokens } from "@noldova/desktop.window";
11
12
  import { DiffScope, FailureCode, GitCode, UndoMode } from "@noldova/git.protocol";
12
13
  import { DialogService } from "@noldova/ui.components.angular";
14
+ import { GitForcePushDialogComponent } from "../components/git-force-push-dialog/git-force-push-dialog.component.js";
13
15
  import { GitFileGroupKind } from "../enums/git-file-group-kind.js";
14
16
  import { GitFileLayout } from "../enums/git-file-layout.js";
15
17
  import { GitViewPhase } from "../enums/git-view-phase.js";
@@ -17,6 +19,7 @@ import { StatusMissingException } from "../exceptions/status-missing.exception.j
17
19
  import { GitFileGroup } from "../models/git-file-group.js";
18
20
  import { GitForcePushOffer } from "../models/git-force-push-offer.js";
19
21
  import { Resources } from "../../resources.js";
22
+ import { GitActionNotices } from "./git-action-notices.js";
20
23
  import { GitCommitPrefixes } from "./git-commit-prefixes.js";
21
24
  import { GitFolder } from "./git-folder.js";
22
25
  import { GitFolderWatch } from "./git-folder-watch.js";
@@ -31,6 +34,7 @@ export class GitViewStateService {
31
34
  watch = new GitFolderWatch(this.client);
32
35
  errors = inject(ErrorHandler);
33
36
  dialogs = inject(DialogService);
37
+ notices = new GitActionNotices(this.context, Resources.gitModule);
34
38
  diffs = new Map();
35
39
  reads = 0;
36
40
  opened = 0;
@@ -63,10 +67,6 @@ export class GitViewStateService {
63
67
  ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
64
68
  discarded = signal(null, /* @ts-ignore */
65
69
  ...(ngDevMode ? [{ debugName: "discarded" }] : /* istanbul ignore next */ []));
66
- forcePushOffer = signal(null, /* @ts-ignore */
67
- ...(ngDevMode ? [{ debugName: "forcePushOffer" }] : /* istanbul ignore next */ []));
68
- fetchOffered = signal(false, /* @ts-ignore */
69
- ...(ngDevMode ? [{ debugName: "fetchOffered" }] : /* istanbul ignore next */ []));
70
70
  recentActions = signal([], /* @ts-ignore */
71
71
  ...(ngDevMode ? [{ debugName: "recentActions" }] : /* istanbul ignore next */ []));
72
72
  fileLayout = signal(GitFileLayout.Folders, /* @ts-ignore */
@@ -254,25 +254,25 @@ export class GitViewStateService {
254
254
  return Object.isNull(folder) ? Promise.reject(new StatusMissingException()) : this.client.markerCheckAsync(folder);
255
255
  }
256
256
  resolveConflictAsync(path, resolution, text) {
257
- return this.writeAsync((folder, basedOn) => this.client.resolveConflictAsync(folder, path, resolution, text, basedOn));
257
+ return this.writeAsync(Resources.resolveConflictTitle, (folder, basedOn) => this.client.resolveConflictAsync(folder, path, resolution, text, basedOn));
258
258
  }
259
259
  continueOperationAsync() {
260
- return this.writeAsync((folder, basedOn) => this.client.continueOperationAsync(folder, basedOn));
260
+ return this.writeAsync(Resources.continueOperationTitle, (folder, basedOn) => this.client.continueOperationAsync(folder, basedOn));
261
261
  }
262
262
  abortOperationAsync() {
263
- return this.writeAsync((folder, basedOn) => this.client.abortOperationAsync(folder, basedOn));
263
+ return this.writeAsync(Resources.abortOperationTitle, (folder, basedOn) => this.client.abortOperationAsync(folder, basedOn));
264
264
  }
265
265
  skipOperationAsync() {
266
- return this.writeAsync((folder, basedOn) => this.client.skipOperationAsync(folder, basedOn));
266
+ return this.writeAsync(Resources.skipOperationTitle, (folder, basedOn) => this.client.skipOperationAsync(folder, basedOn));
267
267
  }
268
268
  stageAsync(paths) {
269
- return this.writeAsync((folder, basedOn) => this.client.stageAsync(folder, paths, basedOn));
269
+ return this.writeAsync(Resources.stageLabel, (folder, basedOn) => this.client.stageAsync(folder, paths, basedOn));
270
270
  }
271
271
  unstageAsync(paths) {
272
- return this.writeAsync((folder, basedOn) => this.client.unstageAsync(folder, paths, basedOn));
272
+ return this.writeAsync(Resources.unstageLabel, (folder, basedOn) => this.client.unstageAsync(folder, paths, basedOn));
273
273
  }
274
274
  discardAsync(paths) {
275
- return this.writeAsync(async (folder, basedOn) => {
275
+ return this.writeAsync(Resources.discardLabel, async (folder, basedOn) => {
276
276
  await this.client.discardAsync(folder, paths, basedOn);
277
277
  const entry = (await this.readJournalAsync(folder))?.entries.at(-1) ?? null;
278
278
  this.discarded.set(entry?.undo === UndoMode.Checkpoint ? entry : null);
@@ -280,10 +280,10 @@ export class GitViewStateService {
280
280
  }
281
281
  undoDiscardAsync() {
282
282
  const entry = this.discarded();
283
- return Object.isNull(entry) ? Promise.resolve() : this.undoEntryAsync(entry);
283
+ return Object.isNull(entry) ? Promise.resolve(false) : this.undoEntryAsync(entry);
284
284
  }
285
285
  undoEntryAsync(entry) {
286
- return this.writeAsync((folder, basedOn) => this.client.undoAsync(folder, entry.id, basedOn), true);
286
+ return this.writeAsync(Resources.undoLabel, (folder, basedOn) => this.client.undoAsync(folder, entry.id, basedOn), true);
287
287
  }
288
288
  async readRecentActionsAsync() {
289
289
  const folder = this.folder();
@@ -296,38 +296,46 @@ export class GitViewStateService {
296
296
  return !Object.isNull(folder) && (await this.readJournalAsync(folder))?.checkpoints === true;
297
297
  }
298
298
  stageLinesAsync(path, lines, staged) {
299
- return this.writeAsync((folder, basedOn) => staged ? this.client.unstageLinesAsync(folder, path, lines, basedOn) : this.client.stageLinesAsync(folder, path, lines, basedOn));
299
+ return this.writeAsync(staged ? Resources.unstageLabel : Resources.stageLabel, (folder, basedOn) => staged ? this.client.unstageLinesAsync(folder, path, lines, basedOn) : this.client.stageLinesAsync(folder, path, lines, basedOn));
300
300
  }
301
301
  async switchBranchAsync(name) {
302
302
  const folder = this.folder();
303
303
  if (Object.isNull(folder))
304
304
  return;
305
- await GitPendingSwitch.runAsync(folder, name, () => this.writeAsync((at, basedOn) => this.client.switchBranchAsync(at, name, basedOn)));
305
+ await GitPendingSwitch.runAsync(folder, name, async () => {
306
+ await this.writeAsync(Resources.switchBranchTitle, (at, basedOn) => this.client.switchBranchAsync(at, name, basedOn));
307
+ });
306
308
  }
307
309
  createBranchAsync(name) {
308
- return this.writeAsync((folder, basedOn) => this.client.createBranchAsync(folder, name, basedOn));
310
+ return this.writeAsync(Resources.createBranchTitle, (folder, basedOn) => this.client.createBranchAsync(folder, name, basedOn));
309
311
  }
312
+ // A push refused as behind offers Force push, a lease on the upstream's commit the status read, when the status shows the upstream
313
+ // ahead with that commit, and Fetch otherwise, as the notification's action.
314
+ // The notification names the repository, since it stays in the list after another repository shows, and its action
315
+ // carries the folder, so it acts only on that repository.
310
316
  pushAsync() {
311
- const offer = GitForcePushOffer.of(this.status());
312
- return this.writeAsync(async (folder, basedOn) => {
313
- const opened = this.opened;
314
- try {
315
- await this.client.pushAsync(folder, basedOn);
316
- }
317
- catch (error) {
318
- if (opened === this.opened && GitRuntimeClient.failureOf(error)?.gitCode === GitCode.PushBehind) {
319
- this.forcePushOffer.set(offer);
320
- this.fetchOffered.set(Object.isNull(offer));
321
- }
322
- throw error;
323
- }
324
- });
317
+ const folder = this.folder();
318
+ if (Object.isNull(folder))
319
+ return Promise.resolve(false);
320
+ const offer = GitForcePushOffer.of(folder, this.status());
321
+ return this.writeAsync(Resources.formatRepositoryAction(Resources.pushLabel, folder), (at, basedOn) => this.client.pushAsync(at, basedOn), false, error => GitRuntimeClient.failureOf(error)?.gitCode !== GitCode.PushBehind ? [] : [Object.isNull(offer)
322
+ ? new NotificationAction(Resources.fetchOfferLabel, new CommandRun(QualifiedName.parse(Resources.fetchCommand), { [Resources.fetchFolderField]: folder }))
323
+ : new NotificationAction(Resources.forcePushOfferLabel, new CommandRun(QualifiedName.parse(Resources.forcePushChangesCommand), offer.toJson()))]);
324
+ }
325
+ // Asks first, naming the branch, its upstream and the commit it leases, as the push-refused notification's Force push does.
326
+ async offerForcePushAsync(offer) {
327
+ const dialog = this.dialogs.open(GitForcePushDialogComponent, ".cancel");
328
+ dialog.componentRef?.setInput("offer", offer);
329
+ const isForced = await new Promise(resolve => dialog.componentInstance?.answered.subscribe(resolve));
330
+ dialog.close();
331
+ if (isForced)
332
+ await this.forcePushAsync(offer);
325
333
  }
326
334
  fetchAsync() {
327
- return this.writeAsync((folder, basedOn) => this.client.fetchAsync(folder, basedOn));
335
+ return this.writeAsync(Resources.fetchOfferLabel, (folder, basedOn) => this.client.fetchAsync(folder, basedOn));
328
336
  }
329
337
  stashAsync() {
330
- return this.writeAsync((folder, basedOn) => this.client.stashAsync(folder, null, true, basedOn));
338
+ return this.writeAsync(Resources.stashActionTitle, (folder, basedOn) => this.client.stashAsync(folder, null, true, basedOn));
331
339
  }
332
340
  stageAllAsync() {
333
341
  return this.stageAsync(this.groups().filter(t => t.kind === GitFileGroupKind.Changes).flatMap(t => t.rows.map(row => row.path)));
@@ -338,31 +346,16 @@ export class GitViewStateService {
338
346
  await this.createBranchAsync(name);
339
347
  }
340
348
  forcePushAsync(offer) {
341
- return this.writeAsync((folder, basedOn) => this.client.forcePushAsync(folder, offer.expected, basedOn));
349
+ return this.writeAsync(Resources.forcePushLabel, (folder, basedOn) => this.client.forcePushAsync(folder, offer.expected, basedOn));
342
350
  }
343
- async createBranchAtAsync(name, id) {
344
- let made = false;
345
- await this.writeAsync(async (folder, basedOn) => {
346
- await this.client.createBranchAtAsync(folder, name, id, basedOn);
347
- made = true;
348
- });
349
- return made;
351
+ createBranchAtAsync(name, id) {
352
+ return this.writeAsync(Resources.createBranchTitle, (folder, basedOn) => this.client.createBranchAtAsync(folder, name, id, basedOn));
350
353
  }
351
- async rebaseAsync(onto, steps, updateRefs) {
352
- let ran = false;
353
- await this.writeAsync(async (folder, basedOn) => {
354
- await this.client.rebaseAsync(folder, onto, steps, updateRefs, basedOn);
355
- ran = true;
356
- });
357
- return ran;
354
+ rebaseAsync(onto, steps, updateRefs) {
355
+ return this.writeAsync(Resources.rebaseTitle, (folder, basedOn) => this.client.rebaseAsync(folder, onto, steps, updateRefs, basedOn));
358
356
  }
359
- async createTagAsync(name, id) {
360
- let made = false;
361
- await this.writeAsync(async (folder, basedOn) => {
362
- await this.client.createTagAsync(folder, name, id, basedOn);
363
- made = true;
364
- });
365
- return made;
357
+ createTagAsync(name, id) {
358
+ return this.writeAsync(Resources.createTagTitle, (folder, basedOn) => this.client.createTagAsync(folder, name, id, basedOn));
366
359
  }
367
360
  async setAmendingAsync(amending) {
368
361
  const folder = this.folder();
@@ -386,16 +379,16 @@ export class GitViewStateService {
386
379
  }
387
380
  }
388
381
  cherryPickAsync(id) {
389
- return this.writeAsync((folder, basedOn) => this.client.cherryPickAsync(folder, id, basedOn));
382
+ return this.writeAsync(Resources.cherryPickLabel, (folder, basedOn) => this.client.cherryPickAsync(folder, id, basedOn));
390
383
  }
391
384
  mergeAsync(id) {
392
- return this.writeAsync((folder, basedOn) => this.client.mergeAsync(folder, id, basedOn));
385
+ return this.writeAsync(Resources.mergeLabel, (folder, basedOn) => this.client.mergeAsync(folder, id, basedOn));
393
386
  }
394
387
  revertAsync(id) {
395
- return this.writeAsync((folder, basedOn) => this.client.revertAsync(folder, id, basedOn));
388
+ return this.writeAsync(Resources.revertLabel, (folder, basedOn) => this.client.revertAsync(folder, id, basedOn));
396
389
  }
397
390
  pullAsync() {
398
- return this.writeAsync((folder, basedOn) => this.client.pullAsync(folder, basedOn));
391
+ return this.writeAsync(Resources.pullLabel, (folder, basedOn) => this.client.pullAsync(folder, basedOn));
399
392
  }
400
393
  async followAgainAsync() {
401
394
  const folder = this.folder();
@@ -407,12 +400,8 @@ export class GitViewStateService {
407
400
  }
408
401
  async commitAsync(message) {
409
402
  const opened = this.opened;
410
- let committed = false;
411
403
  const amending = this.amending();
412
- await this.writeAsync(async (folder, basedOn) => {
413
- await (amending ? this.client.amendAsync(folder, message, basedOn) : this.client.commitAsync(folder, message, basedOn));
414
- committed = true;
415
- });
404
+ const committed = await this.writeAsync(amending ? Resources.amendCommitLabel : Resources.commitLabel, (folder, basedOn) => amending ? this.client.amendAsync(folder, message, basedOn) : this.client.commitAsync(folder, message, basedOn));
416
405
  if (!committed || opened !== this.opened)
417
406
  return false;
418
407
  this.amending.set(false);
@@ -439,8 +428,6 @@ export class GitViewStateService {
439
428
  this.failure.set(null);
440
429
  this.watchFailure.set(null);
441
430
  this.discarded.set(null);
442
- this.forcePushOffer.set(null);
443
- this.fetchOffered.set(false);
444
431
  this.recentActions.set([]);
445
432
  this.message.set("");
446
433
  this.diffs.clear();
@@ -487,34 +474,35 @@ export class GitViewStateService {
487
474
  return null;
488
475
  }
489
476
  }
490
- async writeAsync(write, showsStale = false) {
477
+ // Whether the write went through; a refusal or failure posts an error notification titled by the action.
478
+ async writeAsync(action, write, showsStale = false, actionsOf = () => []) {
491
479
  const folder = this.folder();
492
480
  const status = this.status();
493
481
  if (Object.isNull(folder) || Object.isNull(status) || this.busy())
494
- return;
482
+ return false;
483
+ let isWritten = false;
495
484
  const opened = this.opened;
496
485
  this.busy.set(true);
497
- this.failure.set(null);
498
486
  this.discarded.set(null);
499
- this.forcePushOffer.set(null);
500
- this.fetchOffered.set(false);
501
487
  try {
502
488
  await write(folder, status.fingerprint);
489
+ isWritten = true;
503
490
  }
504
491
  catch (error) {
505
492
  if (!GitRuntimeClient.isFailure(error))
506
493
  throw error;
507
494
  if (opened === this.opened && (showsStale || GitRuntimeClient.failureOf(error)?.code !== FailureCode.Stale))
508
- this.failure.set(GitViewStateService.messageOf(error));
495
+ await this.notices.failAsync(action, GitViewStateService.messageOf(error), actionsOf(error));
509
496
  }
510
497
  finally {
511
498
  this.busy.set(false);
512
499
  }
513
500
  if (opened !== this.opened)
514
- return;
501
+ return isWritten;
515
502
  this.branchLoads++;
516
503
  this.branches.set(null);
517
504
  await this.refreshAsync();
505
+ return isWritten;
518
506
  }
519
507
  show(phase, status) {
520
508
  this.phase.set(phase);
@@ -546,10 +534,10 @@ export class GitViewStateService {
546
534
  return GitViewPhase.GitTooOld;
547
535
  return GitViewPhase.Failed;
548
536
  }
549
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: GitViewStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
550
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: GitViewStateService });
537
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: GitViewStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
538
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: GitViewStateService });
551
539
  }
552
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: GitViewStateService, decorators: [{
540
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: GitViewStateService, decorators: [{
553
541
  type: Injectable
554
542
  }], ctorParameters: () => [] });
555
543
  //# sourceMappingURL=git-view-state.service.js.map