Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIFI-14042] - Display the branch information for version controlled Process Groups #9550

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
selectFlowLoadingStatus,
selectProcessGroups,
selectAnySelectedComponentIds,
selectTransitionRequired
selectTransitionRequired,
selectRegistryClients
} from '../../state/flow/flow.selectors';
import { CanvasUtils } from '../canvas-utils.service';
import { enterProcessGroup } from '../../state/flow/flow.actions';
Expand All @@ -41,6 +42,7 @@ import { NiFiCommon, TextTip } from '@nifi/shared';
})
export class ProcessGroupManager implements OnDestroy {
private destroyed$: Subject<boolean> = new Subject();
private registryClients = this.store.selectSignal(selectRegistryClients);

private dimensions: Dimension = {
width: 384,
Expand Down Expand Up @@ -1117,7 +1119,8 @@ export class ProcessGroupManager implements OnDestroy {
versionControl.each(function (this: any) {
if (self.isUnderVersionControl(processGroupData)) {
self.canvasUtils.canvasTooltip(VersionControlTip, d3.select(this), {
versionControlInformation: processGroupData.component.versionControlInformation
versionControlInformation: processGroupData.component.versionControlInformation,
registryClients: self.registryClients()
});
} else {
self.canvasUtils.resetCanvasTooltip(d3.select(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ import {
VersionControlInformationEntity
} from './index';
import { StatusHistoryRequest } from '../../../../state/status-history';
import { FetchComponentVersionsRequest } from '../../../../state/shared';
import { FetchComponentVersionsRequest, RegistryClientEntity } from '../../../../state/shared';
import { ErrorContext } from '../../../../state/error';

const CANVAS_PREFIX = '[Canvas]';
Expand Down Expand Up @@ -161,6 +161,11 @@ export const startProcessGroupPolling = createAction(`${CANVAS_PREFIX} Start Pro

export const stopProcessGroupPolling = createAction(`${CANVAS_PREFIX} Stop Process Group Polling`);

export const setRegistryClients = createAction(
`${CANVAS_PREFIX} Set Registry Clients`,
props<{ request: RegistryClientEntity[] }>()
);

export const loadConnectionsForComponent = createAction(
`${CANVAS_PREFIX} Load Connections For Component`,
props<{ id: string }>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ import { selectDocumentVisibilityState } from '../../../../state/document-visibi
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DocumentVisibility } from '../../../../state/document-visibility';
import { ErrorContextKey } from '../../../../state/error';
import { setRegistryClients } from './flow.actions';

@Injectable()
export class FlowEffects {
Expand Down Expand Up @@ -234,17 +235,19 @@ export class FlowEffects {
combineLatest([
this.flowService.getFlow(request.id),
this.flowService.getFlowStatus(),
this.flowService.getControllerBulletins()
this.flowService.getControllerBulletins(),
this.registryService.getRegistryClients()
]).pipe(
map(([flow, flowStatus, controllerBulletins]) => {
map(([flow, flowStatus, controllerBulletins, registryClientsResponse]) => {
this.store.dispatch(resetPollingFlowAnalysis());
return FlowActions.loadProcessGroupSuccess({
response: {
id: request.id,
flow: flow,
flowStatus: flowStatus,
controllerBulletins: controllerBulletins,
connectedStateChanged
connectedStateChanged,
registryClients: registryClientsResponse.registries
}
});
}),
Expand Down Expand Up @@ -339,7 +342,7 @@ export class FlowEffects {
request,
registryClients: response.registries
};

this.store.dispatch(setRegistryClients({ request: response.registries }));
return FlowActions.openImportFromRegistryDialog({ request: dialogRequest });
}),
catchError((errorResponse: HttpErrorResponse) =>
Expand Down Expand Up @@ -3460,7 +3463,7 @@ export class FlowEffects {
revision: versionInfo.processGroupRevision,
registryClients: registryClients.registries
};

this.store.dispatch(setRegistryClients({ request: registryClients.registries }));
return FlowActions.openSaveVersionDialog({ request: dialogRequest });
}),
catchError((errorResponse: HttpErrorResponse) => of(this.snackBarOrFullScreenError(errorResponse)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
setFlowAnalysisOpen,
setNavigationCollapsed,
setOperationCollapsed,
setRegistryClients,
setSkipTransform,
setTransitionRequired,
startComponent,
Expand Down Expand Up @@ -158,6 +159,7 @@ export const initialState: FlowState = {
parameterProviderBulletins: [],
reportingTaskBulletins: []
},
registryClients: [],
copiedSnippet: null,
dragging: false,
saving: false,
Expand Down Expand Up @@ -270,11 +272,16 @@ export const flowReducer = createReducer(
};
draftState.flowStatus = response.flowStatus;
draftState.controllerBulletins = response.controllerBulletins;
draftState.registryClients = response.registryClients;
draftState.addedCache = [];
draftState.removedCache = [];
draftState.status = 'success' as const;
});
}),
on(setRegistryClients, (state, { request }) => ({
...state,
registryClients: request
})),
on(loadProcessGroupComplete, (state) => ({
...state,
status: 'complete' as const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ export const selectControllerBulletins = createSelector(
(state: FlowState) => state.controllerBulletins.bulletins // TODO - include others?
);

export const selectRegistryClients = createSelector(selectFlowState, (state: FlowState) => state.registryClients);

export const selectNavigationCollapsed = createSelector(
selectFlowState,
(state: FlowState) => state.navigationCollapsed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface LoadProcessGroupResponse {
flowStatus: ControllerStatusEntity;
controllerBulletins: ControllerBulletinsEntity;
connectedStateChanged: boolean;
registryClients: RegistryClientEntity[];
}

export interface LoadConnectionSuccess {
Expand Down Expand Up @@ -536,6 +537,7 @@ export interface CopiedSnippet {

export interface VersionControlTipInput {
versionControlInformation: VersionControlInformation;
registryClients?: RegistryClientEntity[];
}

/*
Expand Down Expand Up @@ -631,6 +633,7 @@ export interface FlowState {
flowStatus: ControllerStatusEntity;
refreshRpgDetails: RefreshRemoteProcessGroupPollingDetailsRequest | null;
controllerBulletins: ControllerBulletinsEntity;
registryClients: RegistryClientEntity[];
dragging: boolean;
transitionRequired: boolean;
skipTransform: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
this.timeOffset = timeOffset;
});

const sortedRegistries = dialogRequest.registryClients.slice().sort((a, b) => {
return this.nifiCommon.compareString(a.component.name, b.component.name);
});
const sortedRegistries = dialogRequest.registryClients
.slice()
.filter((registry) => registry.permissions.canRead)
.sort((a, b) => {
return this.nifiCommon.compareString(a.component.name, b.component.name);
});

sortedRegistries.forEach((registryClient: RegistryClientEntity) => {
if (registryClient.permissions.canRead) {
Expand All @@ -153,8 +156,9 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
this.clientBranchingSupportMap.set(registryClient.id, registryClient.component.supportsBranching);
});

const initialRegistry = this.registryClientOptions.length > 0 ? this.registryClientOptions[0].value : null;
this.importFromRegistryForm = this.formBuilder.group({
registry: new FormControl(this.registryClientOptions[0].value, Validators.required),
registry: new FormControl(initialRegistry, Validators.required),
branch: new FormControl(null),
bucket: new FormControl(null, Validators.required),
flow: new FormControl(null, Validators.required),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
this.forceCommit = !!dialogRequest.forceCommit;

if (dialogRequest.registryClients) {
const sortedRegistries = dialogRequest.registryClients.slice().sort((a, b) => {
return this.nifiCommon.compareString(a.component.name, b.component.name);
});
const sortedRegistries = dialogRequest.registryClients
.slice()
.filter((registry) => registry.permissions.canRead)
.sort((a, b) => {
return this.nifiCommon.compareString(a.component.name, b.component.name);
});

sortedRegistries.forEach((registryClient: RegistryClientEntity) => {
if (registryClient.permissions.canRead) {
Expand All @@ -107,8 +110,9 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
this.clientBranchingSupportMap.set(registryClient.id, registryClient.component.supportsBranching);
});

const initialRegistry = this.registryClientOptions.length > 0 ? this.registryClientOptions[0].value : null;
this.saveVersionForm = formBuilder.group({
registry: new FormControl(this.registryClientOptions[0].value, Validators.required),
registry: new FormControl(initialRegistry, Validators.required),
branch: new FormControl(null),
bucket: new FormControl(null, Validators.required),
flowName: new FormControl(null, Validators.required),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,33 @@
-->

<div class="tooltip" [style.left.px]="left" [style.top.px]="top">
<div>
{{ getTrackingMessage() }}
</div>
<div>
@if (data?.versionControlInformation; as vci) {
<div class="flex flex-col gap-y-2 mb-3">
<div>
<div>Flow Name</div>
<div class="tertiary-color font-medium">{{ vci.flowName }}</div>
</div>
<div>
<div>Version</div>
<div class="tertiary-color font-medium">{{ vci.version }}</div>
</div>
<div>
<div>Registry</div>
<div class="tertiary-color font-medium">{{ vci.registryName }}</div>
</div>
@if (supportsBranching() && vci.branch) {
<div>
<div>Branch</div>
<div class="tertiary-color font-medium">{{ vci.branch }}</div>
</div>
}
<div>
<div>Bucket</div>
<div class="tertiary-color font-medium">{{ vci.bucketName }}</div>
</div>
</div>
}
<div class="italic">
{{ data?.versionControlInformation?.stateExplanation }}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { Component, Input } from '@angular/core';
import { VersionControlInformation, VersionControlTipInput } from '../../../../state/flow';
import { RegistryClientEntity } from '../../../../../../state/shared';

@Component({
selector: 'version-control-tip',
Expand All @@ -36,4 +37,14 @@ export class VersionControlTip {

return '';
}

supportsBranching(): boolean {
if (this.data?.registryClients && this.data?.registryClients.length > 0) {
const vci = this.data.versionControlInformation;
return this.data.registryClients.some((client: RegistryClientEntity) => {
return client.id === vci.registryId && client.component.supportsBranching;
});
}
return false;
}
}