Browse Source

Updates graph typings and constants

main
Keith Daulton 1 year ago
committed by Keith Daulton
parent
commit
d85178e23f
3 changed files with 17 additions and 21 deletions
  1. +6
    -4
      src/plus/webviews/graph/graphWebview.ts
  2. +0
    -7
      src/plus/webviews/graph/protocol.ts
  3. +11
    -10
      src/webviews/apps/plus/graph/GraphWrapper.tsx

+ 6
- 4
src/plus/webviews/graph/graphWebview.ts View File

@ -65,7 +65,7 @@ import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '..
import type { GitSearch } from '../../../git/search';
import { getSearchQueryComparisonKey } from '../../../git/search';
import { showRepositoryPicker } from '../../../quickpicks/repositoryPicker';
import type { StoredGraphFilters, StoredGraphIncludeOnlyRef } from '../../../storage';
import type { StoredGraphFilters, StoredGraphIncludeOnlyRef, StoredGraphRefType } from '../../../storage';
import {
executeActionCommand,
executeCommand,
@ -1129,7 +1129,7 @@ export class GraphWebview extends WebviewBase {
repoPath: string | undefined,
id: string | undefined,
type: GitGraphRowType | undefined,
) {
): GitStashReference | GitRevisionReference | undefined {
if (repoPath == null || id == null) return undefined;
switch (type) {
@ -1890,7 +1890,9 @@ export class GraphWebview extends WebviewBase {
storedExcludeRefs = updateRecordValue(
storedExcludeRefs,
ref.id,
visible ? undefined : { id: ref.id, type: ref.type, name: ref.name, owner: ref.owner },
visible
? undefined
: { id: ref.id, type: ref.type as StoredGraphRefType, name: ref.name, owner: ref.owner },
);
}
@ -1920,7 +1922,7 @@ export class GraphWebview extends WebviewBase {
for (const ref of refs) {
storedIncludeOnlyRefs[ref.id] = {
id: ref.id,
type: ref.type,
type: ref.type as StoredGraphRefType,
name: ref.name,
owner: ref.owner,
};

+ 0
- 7
src/plus/webviews/graph/protocol.ts View File

@ -1,5 +1,4 @@
import type {
CommitDateTimeSource,
CssVariables,
ExcludeByType,
ExcludeRefsById,
@ -74,12 +73,6 @@ export const enum GraphMinimapMarkerTypes {
export const supportedRefMetadataTypes: GraphRefMetadataType[] = Object.values(GraphRefMetadataTypes);
export type GraphCommitDateTimeSource = CommitDateTimeSource;
export enum GraphCommitDateTimeSources {
RowEntry = 'rowEntry',
Tooltip = 'tooltip',
}
export interface State {
windowFocused?: boolean;
repositories?: GraphRepository[];

+ 11
- 10
src/webviews/apps/plus/graph/GraphWrapper.tsx View File

@ -2,6 +2,7 @@ import type {
GraphColumnSetting,
GraphColumnsSettings,
GraphContainerProps,
GraphMarkerType,
GraphPlatform,
GraphRef,
GraphRefGroup,
@ -10,7 +11,7 @@ import type {
GraphZoneType,
OnFormatCommitDateTime,
} from '@gitkraken/gitkraken-components';
import GraphContainer, { GRAPH_ZONE_TYPE, REF_ZONE_TYPE } from '@gitkraken/gitkraken-components';
import GraphContainer, { CommitDateTimeSources, commitZone, refZone } from '@gitkraken/gitkraken-components';
import { VSCodeCheckbox, VSCodeRadio, VSCodeRadioGroup } from '@vscode/webview-ui-toolkit/react';
import type { FormEvent, ReactElement } from 'react';
import React, { createElement, useEffect, useMemo, useRef, useState } from 'react';
@ -25,7 +26,6 @@ import type {
GraphAvatars,
GraphColumnName,
GraphColumnsConfig,
GraphCommitDateTimeSource,
GraphComponentConfig,
GraphExcludedRef,
GraphExcludeTypes,
@ -52,7 +52,6 @@ import {
DidChangeWorkingTreeNotificationType,
DidFetchNotificationType,
DidSearchNotificationType,
GraphCommitDateTimeSources,
GraphMinimapMarkerTypes,
} from '../../../../plus/webviews/graph/protocol';
import type { Subscription } from '../../../../subscription';
@ -104,7 +103,7 @@ export interface GraphWrapperProps {
}
const getGraphDateFormatter = (config?: GraphComponentConfig): OnFormatCommitDateTime => {
return (commitDateTime: number, source?: GraphCommitDateTimeSource) =>
return (commitDateTime: number, source?: CommitDateTimeSources) =>
formatCommitDateTime(commitDateTime, config?.dateStyle, config?.dateFormat, source);
};
@ -594,7 +593,7 @@ export function GraphWrapper({
};
const handleOnGraphRowHovered = (_event: any, graphZoneType: GraphZoneType, graphRow: GraphRow) => {
if (graphZoneType === REF_ZONE_TYPE || minimap.current == null) return;
if (graphZoneType === refZone || minimap.current == null) return;
minimap.current?.select(graphRow.date, true);
};
@ -886,7 +885,7 @@ export function GraphWrapper({
graphZoneType: GraphZoneType,
row: GraphRow,
) => {
if (graphZoneType === REF_ZONE_TYPE || graphZoneType === GRAPH_ZONE_TYPE) return;
if (graphZoneType === refZone || graphZoneType === commitZone) return;
onDoubleClickRow?.(row, true);
};
@ -1303,7 +1302,9 @@ export function GraphWrapper({
cssVariables={styleProps?.cssVariables}
dimMergeCommits={graphConfig?.dimMergeCommits}
enabledRefMetadataTypes={graphConfig?.enabledRefMetadataTypes}
enabledScrollMarkerTypes={graphConfig?.enabledScrollMarkerTypes}
enabledScrollMarkerTypes={
graphConfig?.enabledScrollMarkerTypes as GraphMarkerType[] | undefined
}
enableMultiSelection={graphConfig?.enableMultiSelection}
excludeRefsById={excludeRefsById}
excludeByType={excludeTypes}
@ -1366,12 +1367,12 @@ function formatCommitDateTime(
date: number,
style: DateStyle = DateStyle.Absolute,
format: DateTimeFormat | string = 'short+short',
source?: GraphCommitDateTimeSource,
source?: CommitDateTimeSources,
): string {
switch (source) {
case GraphCommitDateTimeSources.Tooltip:
case CommitDateTimeSources.Tooltip:
return `${formatDate(date, format)} (${fromNow(date)})`;
case GraphCommitDateTimeSources.RowEntry:
case CommitDateTimeSources.RowEntry:
default:
return style === DateStyle.Relative ? fromNow(date) : formatDate(date, format);
}

Loading…
Cancel
Save