@gitkraken/gitkraken-components 11.0.4 → 11.0.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 11.0.5
4
+
5
+ - Implemented branch pinning feature ([#378](https://github.com/gitkraken/GitKrakenComponents/pull/378))
6
+ - Added ids to the ref node component to be able to add user education annotations to the graph ([#378](https://github.com/gitkraken/GitKrakenComponents/pull/378))
7
+ - Added new icon to the graph for the pin branch to left action ([#378](https://github.com/gitkraken/GitKrakenComponents/pull/378))
8
+
3
9
  ## 11.0.4
4
10
 
5
11
  - Fixed commit shortcuts (cmd+enter / cmd+shift+enter) not firing in GKD when the WIP input is focused by allowing modifier-based shortcuts to bubble. ([#377](https://github.com/gitkraken/GitKrakenComponents/pull/377))
@@ -6,7 +6,7 @@ import type { Sha } from '../../domain/commit/CommitTypes';
6
6
  import type { CssVariables } from '../../domain/generic/GenericTypes';
7
7
  import type { GraphCommitDescDisplayMode, GraphMarkerType, GraphSearchMode, GraphZone, GraphZoneType, ShiftSelectMode } from '../../domain/graph/GraphConstants';
8
8
  import type { ThrottledFn } from '../../domain/graph/GraphHelpers';
9
- import type { AbsoluteNodeLeftByColumn, AvatarUrlByEmail, AvatarUrlRequestedByEmail, ChildrenBySha, ColumnColorByColumn, DownstreamsByUpstream, EdgeByColumn, ExcludeByType, ExcludeRefsById, ExcludeRemotesByName, FormatCommitMessage, FormatRefShorthand, GetExternalIcon, GetMissingAvatar, GetMissingRefMetadata, GraphColumnSetting, GraphColumnsSettings, GraphContexts, GraphMarkerColors, GraphMarkerRowIndices, GraphPlatform, GraphRefGroup, GraphRow, GraphZoneModeConstants, GraphZonesByType, Head, HighlightedShas, IncludeOnlyRefsById, IncludeOnlyRemotesByName, IsRefShorthandValid, IsSelectedBySha, NodeOffsetByColumn, NodeOpacityByColumn, OnClearCurrentlyHoveredGraphCommit, OnClickCommit, OnClickGraphRef, OnClickGraphRow, OnClickRef, OnCommitContextMenu, OnCommitMessageChange, OnCurrentlyHoveredGraphCommit, OnDoubleClickCommit, OnDoubleClickGraphRef, OnDoubleClickGraphRow, OnDoubleClickRef, OnEmailsMissingAvatarUrls, OnFilterColumnClick, OnFormatCommitDateTime, OnGraphColumnReOrdered, OnGraphColumnResized, OnGraphColumnsReOrdered, OnGraphMouseEnter, OnGraphMouseLeave, OnGraphRefNodeHovered, OnGraphRefNodeUnhovered, OnGraphResized, OnGraphRowHovered, OnGraphRowUnhovered, OnGraphScrollForZone, OnGraphVisibleRowsChanged, OnGraphZoneResize, OnGraphZoneResizeEnd, OnLoadSelectedGraphRow, OnPopupGraphHeaderContextMenu, OnRefBeginDrag, OnRefCanDrag, OnRefCanDrop, OnRefContextMenu, OnRefCreate, OnRefCreateCancel, OnRefCreateContextMenu, OnRefDragEnter, OnRefDragLeave, OnRefDrop, OnRefEndDrag, OnRefNodeHovered, OnRefNodeUnhovered, OnRefShorthandChange, OnRefsMissingMetadata, OnRefZoneContextMenu, OnRefZoneHovered, OnRefZoneUnhovered, OnRowContextMenu, OnScrollForZone, OnSelectGraphRows, OnSettingsClick, OnShowMoreCommits, OnToggleRefNodesShown, OnToggleRefsVisibilityClick, OnWipMessageBlur, OnWipMessageFocus, ProcessedGraphRow, ProcessedGraphRowBySha, RefMetadataById, RefMetadataRequestedById, RefMetadataType, RefsMissingMetadata, Remote, ReserverInfoBySha, RowEdges, RowStats, RowStatsConstraints, ShaByRefId, Tag, TopAndBottomVisibleRowIndex } from '../../domain/graph/GraphTypes';
9
+ import type { AbsoluteNodeLeftByColumn, AvatarUrlByEmail, AvatarUrlRequestedByEmail, ChildrenBySha, ColumnColorByColumn, DownstreamsByUpstream, EdgeByColumn, ExcludeByType, ExcludeRefsById, ExcludeRemotesByName, FormatCommitMessage, FormatRefShorthand, GetExternalIcon, GetMissingAvatar, GetMissingRefMetadata, GraphColumnSetting, GraphColumnsSettings, GraphContexts, GraphMarkerColors, GraphMarkerRowIndices, GraphPlatform, GraphRefGroup, GraphRow, GraphZoneModeConstants, GraphZonesByType, Head, HighlightedShas, IncludeOnlyRefsById, IncludeOnlyRemotesByName, IsRefShorthandValid, IsSelectedBySha, NodeOffsetByColumn, NodeOpacityByColumn, OnClearCurrentlyHoveredGraphCommit, OnClickCommit, OnClickGraphRef, OnClickGraphRow, OnClickRef, OnColumnsCalculated, OnCommitContextMenu, OnCommitMessageChange, OnCurrentlyHoveredGraphCommit, OnDoubleClickCommit, OnDoubleClickGraphRef, OnDoubleClickGraphRow, OnDoubleClickRef, OnEmailsMissingAvatarUrls, OnFilterColumnClick, OnFormatCommitDateTime, OnGraphColumnReOrdered, OnGraphColumnResized, OnGraphColumnsReOrdered, OnGraphMouseEnter, OnGraphMouseLeave, OnGraphRefNodeHovered, OnGraphRefNodeUnhovered, OnGraphResized, OnGraphRowHovered, OnGraphRowUnhovered, OnGraphScrollForZone, OnGraphVisibleRowsChanged, OnGraphZoneResize, OnGraphZoneResizeEnd, OnLoadSelectedGraphRow, OnPopupGraphHeaderContextMenu, OnRefBeginDrag, OnRefCanDrag, OnRefCanDrop, OnRefContextMenu, OnRefCreate, OnRefCreateCancel, OnRefCreateContextMenu, OnRefDragEnter, OnRefDragLeave, OnRefDrop, OnRefEndDrag, OnRefNodeHovered, OnRefNodeUnhovered, OnRefShorthandChange, OnRefsMissingMetadata, OnRefZoneContextMenu, OnRefZoneHovered, OnRefZoneUnhovered, OnRowContextMenu, OnScrollForZone, OnSelectGraphRows, OnSettingsClick, OnShowMoreCommits, OnToggleRefNodesShown, OnToggleRefsVisibilityClick, OnWipMessageBlur, OnWipMessageFocus, ProcessedGraphRow, ProcessedGraphRowBySha, RefMetadataById, RefMetadataRequestedById, RefMetadataType, RefsMissingMetadata, Remote, ReserverInfoBySha, RowEdges, RowStats, RowStatsConstraints, ShaByRefId, Tag, TopAndBottomVisibleRowIndex } from '../../domain/graph/GraphTypes';
10
10
  import type { TranslationFn } from '../../domain/language/LanguageTypes';
11
11
  import type { CreateRefFormData, RefIconsPosition } from '../../domain/ref/RefTypes';
12
12
  import type { OnBlur, OnKeyDown, OnKeyUp, OnMouseDown, OnResizeParams } from '../../domain/ui/UiTypes';
@@ -54,6 +54,12 @@ export interface StateProps {
54
54
  isInUnsupportedRebase?: boolean;
55
55
  isLoadingRows?: boolean;
56
56
  pendingCommitMessageSummary?: string;
57
+ /**
58
+ * Full name of the branch to pin to the left-most column (column 0).
59
+ * Example: "refs/heads/main" or "refs/remotes/origin/main"
60
+ * If null or undefined, no branch is pinned.
61
+ */
62
+ pinnedBranchFullName?: string | null;
57
63
  shiftSelectMode?: ShiftSelectMode;
58
64
  suppressNonRefRowTooltips?: boolean;
59
65
  refMetadataById?: RefMetadataById | null;
@@ -93,6 +99,12 @@ export interface DispatchProps {
93
99
  onGraphColumnsReOrdered?: OnGraphColumnsReOrdered;
94
100
  onFilterColumnClick?: OnFilterColumnClick;
95
101
  onColumnResized?: OnGraphColumnResized;
102
+ /**
103
+ * Callback invoked when column numbers are calculated for each commit.
104
+ * Receives a map of SHA → column number.
105
+ * Used to sync column layout data back to the parent application.
106
+ */
107
+ onColumnsCalculated?: OnColumnsCalculated;
96
108
  onFocusWipNodeInput?: OnWipMessageFocus;
97
109
  onMessageChange?: OnCommitMessageChange;
98
110
  onPopupGraphHeaderContextMenu?: OnPopupGraphHeaderContextMenu;
@@ -190,6 +202,7 @@ declare class GraphContainer extends React.Component<Props, ComponentState> impl
190
202
  hasMergeNodeChildBySha: HasMergeNodeChildBySha;
191
203
  reserverInfoBySha: ReserverInfoBySha;
192
204
  columnsUsed: ColumnsUsed;
205
+ pinnedBranchShas: Set<Sha>;
193
206
  rowsStats?: Record<string, RowStats>;
194
207
  workDirStats: WorkDirStats;
195
208
  excludeByType: ExcludeByType;
@@ -320,7 +333,7 @@ declare class GraphContainer extends React.Component<Props, ComponentState> impl
320
333
  getEndingAndPassThroughEdgesByColumnFromPrevRow(graphRow: ProcessedGraphRow, prevRowEdges: RowEdges): RowEdges;
321
334
  getFinalEdgeStateForGraphAndRow(graphRow: ProcessedGraphRow, prevRowEdges: RowEdges): RowEdges;
322
335
  loadEdgesBySha(): void;
323
- processRows(graphRows?: GraphRow[]): void;
336
+ processRows(graphRows?: GraphRow[], pinnedBranchFullName?: string | null): void;
324
337
  getStartingEdgesByColumn(currentRow: ProcessedGraphRow): EdgeByColumn;
325
338
  formatCommitDateTimeCallback: OnFormatCommitDateTime;
326
339
  formatCommitMessageCallback: FormatCommitMessage;
@@ -333,12 +346,11 @@ declare class GraphContainer extends React.Component<Props, ComponentState> impl
333
346
  selectNext(topological?: boolean): void;
334
347
  selectPrevious(topological?: boolean): void;
335
348
  selectHead(upstream?: boolean): void;
336
- getAvailableColumnAndUseIt(): number;
337
349
  getColumns(graphRow: GraphRow): number;
338
350
  getFilteredHeadsForGraphRow(row: GraphRow, hasIncludes: boolean): Head[];
339
351
  getFilteredRemotesForGraphRow(row: GraphRow, hasIncludes: boolean): Remote[];
340
352
  getFilteredTagsForGraphRow(row: GraphRow, hasIncludes: boolean, rowHasVisibleChild: boolean): Tag[];
341
- loadRowsbySha(graphRows: GraphRow[]): void;
353
+ loadRowsbySha(graphRows: GraphRow[], pinnedBranchFullName?: string | null): void;
342
354
  updateRowStatsConstraints(): void;
343
355
  updateTimelines(): void;
344
356
  clearTimelines(): void;
@@ -13,7 +13,9 @@ export type RefNodeProps = {
13
13
  hasRefs: boolean;
14
14
  isActive: boolean;
15
15
  isGhostRef: boolean;
16
+ isHidden?: boolean;
16
17
  isInUnsupportedRebase: boolean;
18
+ isPinned: boolean;
17
19
  isRefGroupIncluded: boolean;
18
20
  key?: string;
19
21
  onClick: OnClickRef;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ type Props = React.ComponentProps<'div'> & {
3
+ className?: string;
4
+ isRefGhost: boolean;
5
+ isRefHidden: boolean;
6
+ isRefActive: boolean;
7
+ isRefPinned: boolean;
8
+ };
9
+ declare const RefNodeAnnotationTarget: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLDivElement>>;
10
+ export default RefNodeAnnotationTarget;
@@ -22,6 +22,7 @@ type RefNodesProps = {
22
22
  numGraphColumns: number;
23
23
  onClickRef: OnClickRef;
24
24
  onMissingRefMetadata: GetMissingRefMetadata;
25
+ pinnedBranchFullName?: string | null;
25
26
  refGroupContexts: RefGroupContexts | null;
26
27
  refGroupsByName: RefGroup[];
27
28
  refIconsPosition: RefIconsPosition;
@@ -42,5 +43,5 @@ type RefNodesProps = {
42
43
  type: CommitType;
43
44
  useColumnHeaderIcons: boolean;
44
45
  };
45
- declare function RefNodes({ enabledRefMetadataTypes, column, columnForColoring, context, enableShowHideRefsOptions, targetRef, hasActive, hasRefs, getExternalIcon, includeOnlyRefsById, includeOnlyRemotesByName, isGhostRef, isHovered, isInUnsupportedRebase, numGraphColumns, onMissingRefMetadata, refGroupContexts, refGroupsByName, refIconsPosition, refMetadata, refNodeHovered, sha, showRemoteNamesOnRefs, showContextMenuForGroupedRef, onClickRef, onDoubleClickRef, onToggleRefNodesShown, onRefBeginDrag, onRefCanDrag, onRefCanDrop, onRefDragEnter, onRefDragLeave, onRefDrop, onRefEndDrag, translate, type, useColumnHeaderIcons, }: RefNodesProps): ReactElement<'span' | 'div'>;
46
+ declare function RefNodes({ enabledRefMetadataTypes, column, columnForColoring, context, enableShowHideRefsOptions, targetRef, hasActive, hasRefs, getExternalIcon, includeOnlyRefsById, includeOnlyRemotesByName, isGhostRef, isHovered, isInUnsupportedRebase, numGraphColumns, onMissingRefMetadata, pinnedBranchFullName, refGroupContexts, refGroupsByName, refIconsPosition, refMetadata, refNodeHovered, sha, showRemoteNamesOnRefs, showContextMenuForGroupedRef, onClickRef, onDoubleClickRef, onToggleRefNodesShown, onRefBeginDrag, onRefCanDrag, onRefCanDrop, onRefDragEnter, onRefDragLeave, onRefDrop, onRefEndDrag, translate, type, useColumnHeaderIcons, }: RefNodesProps): ReactElement<'span' | 'div'>;
46
47
  export default RefNodes;
@@ -36,6 +36,7 @@ type RefZoneProps = {
36
36
  onRefDragLeave: OnRefDragLeave;
37
37
  onRefDrop: OnRefDrop;
38
38
  onRefEndDrag: OnRefEndDrag;
39
+ pinnedBranchFullName?: string | null;
39
40
  refGroupContexts: RefGroupContexts | null;
40
41
  refGroupsByName: GraphRefGroup[];
41
42
  refIconsPosition: RefIconsPosition;
@@ -15,6 +15,7 @@ interface StateProps {
15
15
  isInUnsupportedRebase: boolean;
16
16
  isRefShorthandValid: IsRefShorthandValid;
17
17
  hoveredRefZoneSha?: Sha;
18
+ pinnedBranchFullName?: string | null;
18
19
  refIconsPosition: RefIconsPosition;
19
20
  refMetadataById?: RefMetadataById | null;
20
21
  shouldShowRefLine: boolean;
@@ -31,6 +31,8 @@ export declare const REF_ZONE_MARGIN_LEFT = 2;
31
31
  export declare const REF_ZONE_MARGIN_RIGHT = 6;
32
32
  export declare const REF_NODE_ICON_WIDTH = 14;
33
33
  export declare const REF_NODE_ICON_MARGIN = 5;
34
+ export declare const REF_NODE_ACTIVE_ANNOTATION_ID = "gk-graph-ref-active";
35
+ export declare const REF_NODE_PINNED_ANNOTATION_ID = "gk-graph-ref-pinned";
34
36
  export declare const REF_NODE_ICON_SPACING: number;
35
37
  export declare const REF_NODE_OUTER_SPACING = 10;
36
38
  export declare const REF_ZONE_SHOW_ICON_WIDTH = 55;
@@ -145,6 +145,9 @@ export type HasSpecialChildBySha = {
145
145
  export type ReserverInfoBySha = {
146
146
  [id: Sha]: ReserverInfo;
147
147
  };
148
+ export type ColumnNumberBySha = {
149
+ [sha: Sha]: number;
150
+ };
148
151
  export type RefTargetFunc = () => Element | null | undefined;
149
152
  export type ColumnContentGenerator = () => ReactElement<any>;
150
153
  export type GraphItemContext = string | Object;
@@ -396,7 +399,7 @@ export type DownstreamsByUpstream = {
396
399
  [upstreamName: string]: string[];
397
400
  };
398
401
  export type GraphPlatform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin';
399
- export type ExternalIconKeys = 'added' | 'author' | 'branch' | 'changes' | 'check' | 'commit' | 'datetime' | 'deleted' | 'files' | 'filter' | 'graph' | 'head' | 'hide' | `issue-${IssueTrackerType}` | 'loading' | 'message' | 'modified' | 'pull-request' | 'remote' | `remote-${HostingServiceType}` | 'renamed' | 'resolved' | 'settings' | 'show' | 'stash' | 'tag' | 'upstream-ahead' | 'upstream-behind' | 'warning' | 'worktree';
402
+ export type ExternalIconKeys = 'added' | 'author' | 'branch' | 'changes' | 'check' | 'commit' | 'datetime' | 'deleted' | 'files' | 'filter' | 'graph' | 'head' | 'hide' | `issue-${IssueTrackerType}` | 'loading' | 'message' | 'modified' | 'pin' | 'pull-request' | 'remote' | `remote-${HostingServiceType}` | 'renamed' | 'resolved' | 'settings' | 'show' | 'stash' | 'tag' | 'upstream-ahead' | 'upstream-behind' | 'warning' | 'worktree';
400
403
  export type GetExternalIcon = (key: ExternalIconKeys) => ReactElement<any>;
401
404
  export type GetMissingAvatar = (email: string, sha: string) => void;
402
405
  export type GetMissingRefMetadata = (id: string, types: RefMetadataType[]) => void;
@@ -474,3 +477,9 @@ export type OnGraphColumnResized = (graphZoneType: GraphZoneType, columnSettings
474
477
  export type OnShowMoreCommits = () => void;
475
478
  export type OnEmailsMissingAvatarUrls = (emails: AvatarUrlByEmail) => void;
476
479
  export type OnRefsMissingMetadata = (refs: RefsMissingMetadata) => void;
480
+ /**
481
+ * Callback invoked when column numbers are calculated for each commit.
482
+ * Receives a map of SHA → column number.
483
+ * Used to sync column layout data back to the parent application.
484
+ */
485
+ export type OnColumnsCalculated = (columnsBySha: ColumnNumberBySha) => void;
@@ -0,0 +1,21 @@
1
+ import type { Sha } from '../commit/CommitTypes';
2
+ import type { GraphRow } from './GraphTypes';
3
+ /**
4
+ * Identifies commits that belong to the pinned branch by following the first-parent chain.
5
+ * Returns a Set of SHAs that are part of the pinned branch.
6
+ */
7
+ export declare function identifyPinnedBranchCommits(graphRows: GraphRow[], pinnedBranchFullName?: string | null): Set<Sha>;
8
+ /**
9
+ * Gets the next available column number, marking it as used.
10
+ * When reserveColumn0ForPinned is true, starts searching from column 1.
11
+ */
12
+ export declare function getAvailableColumnAndUseIt(columnsUsed: {
13
+ [column: number]: boolean;
14
+ }, reserveColumn0ForPinned?: boolean): number;
15
+ /**
16
+ * Determines the column number for a parent commit based on pinning status and parent index.
17
+ * For pinned parents, always reserve column 0; for non-pinned, use normal logic.
18
+ */
19
+ export declare function getParentColumn(columnsUsed: {
20
+ [column: number]: boolean;
21
+ }, isParentPinned: boolean, parentIndex: number, currentColumn: number, hasPinnedBranch: boolean): number;