Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #360 from eclipse-che4z/sync-def-profile
Browse files Browse the repository at this point in the history
Store workspace sync profiles and show it on vscode status bar
  • Loading branch information
roman-kupriyanov authored Jan 5, 2024
2 parents 81c7601 + 907576f commit 6c497a4
Show file tree
Hide file tree
Showing 17 changed files with 583 additions and 186 deletions.
8 changes: 8 additions & 0 deletions packages/explorer-for-endevor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@
"command": "e4e.historyCompareWith",
"title": "Compare with ...",
"category": "Explorer for Endevor"
},
{
"command": "e4e.updateConnectionLocation",
"title": "Update Connection Location"
}
],
"submenus": [
Expand Down Expand Up @@ -918,6 +922,10 @@
{
"command": "e4e.historyCompareWith",
"when": "false"
},
{
"command": "e4e.updateConnectionLocation",
"when": "false"
}
],
"editor/context": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* © 2023 Broadcom Inc and/or its subsidiaries; All rights reserved
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*/

import { EndevorServiceName } from '../settings/_doc/Settings';
import { Action } from '../store/_doc/Actions';
import {
EndevorId,
EndevorLocationName,
EndevorServiceDescriptions,
ExistingEndevorServiceDescriptions,
ValidEndevorConnection,
ValidEndevorSearchLocationDescriptions,
} from '../store/_doc/v2/Store';
import { addNewSearchLocation } from './location/addNewSearchLocation';
import { addNewServiceCommand } from './service/addNewService';

export const addServiceAndLocationCommand = async (
dispatch: (action: Action) => Promise<void>,
serviceConfigurations: {
getAllServiceNames: () => ReadonlyArray<EndevorServiceName>;
getValidServiceDescriptions: () => Promise<ExistingEndevorServiceDescriptions>;
},
configurations: {
getConnectionDetails: (
id: EndevorId
) => Promise<ValidEndevorConnection | undefined>;
getServiceDescriptionsBySearchLocationId: (
searchLocationId: EndevorId
) => Promise<EndevorServiceDescriptions>;
getSearchLocationNames: () => ReadonlyArray<EndevorLocationName>;
getValidSearchLocationDescriptionsForService: (
serviceId: EndevorId
) => ValidEndevorSearchLocationDescriptions;
getValidUsedServiceDescriptions: () => Promise<ExistingEndevorServiceDescriptions>;
}
) => {
const serviceId = await addNewServiceCommand(dispatch, serviceConfigurations);
if (serviceId) {
await addNewSearchLocation(dispatch, configurations)(serviceId);
}
};
1 change: 1 addition & 0 deletions packages/explorer-for-endevor/src/commands/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const CommandId = {

// service commands
ADD_SERVICE_AND_LOCATION: `${COMMAND_PREFIX}.addServiceAndLocation`,
UPDATE_CONNECTION_LOCATION: `${COMMAND_PREFIX}.updateConnectionLocation`,
ADD_NEW_SERVICE: `${COMMAND_PREFIX}.addNewService`,
EDIT_SERVICE: `${COMMAND_PREFIX}.editService`,
HIDE_SERVICE: `${COMMAND_PREFIX}.hideService`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ export const addNewSearchLocation =
if (!locationChosen(dialogResult)) {
const createdSearchLocation = dialogResult;
dispatch({
type: Actions.ENDEVOR_SEARCH_LOCATION_CREATED,
type: Actions.ENDEVOR_SEARCH_LOCATION_ADDED,
serviceId,
searchLocationId: createdSearchLocation.id,
searchLocation: {
value: createdSearchLocation.value,
id: createdSearchLocation.id,
isDefault: false,
},
});
reporter.sendTelemetryEvent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const addNewServiceCommand = async (
createdService.value.connection.status === EndevorConnectionStatus.VALID
) {
dispatch({
type: Actions.ENDEVOR_SERVICE_CREATED,
type: Actions.ENDEVOR_SERVICE_ADDED,
serviceId: createdService.id,
service: {
id: createdService.id,
value: createdService.value.connection.value,
Expand All @@ -96,6 +97,7 @@ export const addNewServiceCommand = async (
id: createdService.id,
}
: undefined,
isDefault: false,
},
connectionStatus: {
status: createdService.value.connection.status,
Expand All @@ -104,7 +106,8 @@ export const addNewServiceCommand = async (
});
} else {
dispatch({
type: Actions.ENDEVOR_SERVICE_CREATED,
type: Actions.ENDEVOR_SERVICE_ADDED,
serviceId: createdService.id,
service: {
id: createdService.id,
value: createdService.value.connection.value,
Expand All @@ -114,6 +117,7 @@ export const addNewServiceCommand = async (
id: createdService.id,
}
: undefined,
isDefault: false,
},
connectionStatus: {
status: createdService.value.connection.status,
Expand Down
59 changes: 12 additions & 47 deletions packages/explorer-for-endevor/src/commands/sync/pullFromEndevor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,9 @@ import {
} from '../../store/scm/workspace';
import { reporter } from '../../globals';
import { getWorkspaceUri } from '@local/vscode-wrapper/workspace';
import {
askForService,
dialogCancelled as serviceDialogCancelled,
} from '../../dialogs/locations/endevorServiceDialogs';
import {
askForSearchLocation,
dialogCancelled as locationDialogCancelled,
} from '../../dialogs/locations/endevorSearchLocationDialogs';
import {
EndevorId,
ValidEndevorSearchLocationDescriptions,
ExistingEndevorServiceDescriptions,
} from '../../store/_doc/v2/Store';
import { EndevorId } from '../../store/_doc/v2/Store';
import { withNotificationProgress } from '@local/vscode-wrapper/window';
import { isError } from '../../utils';
import { SyncActions, UpdateLastUsed } from '../../store/scm/_doc/Actions';
import {
PullFromEndevorCommandCompletedStatus,
TelemetryEvents,
Expand All @@ -46,12 +33,13 @@ import {
EndevorAuthorizedService,
SearchLocation,
} from '../../api/_doc/Endevor';
import { Id } from '../../store/storage/_doc/Storage';
import {
askForChangeControlValue,
dialogCancelled as changeControlDialogCancelled,
} from '../../dialogs/change-control/endevorChangeControlDialogs';
import { createEndevorLogger } from '../../logger';
import { SyncServiceLocation } from '../../store/scm/resolvers';
import { Actions, UpdateLastUsed } from '../../store/_doc/Actions';

export const pullFromEndevorCommand = async (
dispatch: (action: UpdateLastUsed) => Promise<void>,
Expand All @@ -65,10 +53,7 @@ export const pullFromEndevorCommand = async (
}
| undefined
>,
getValidServiceDescriptions: () => Promise<ExistingEndevorServiceDescriptions>,
getValidSearchLocationDescriptions: () => ValidEndevorSearchLocationDescriptions,
getLastUsedServiceId: () => Id | undefined,
getLastUsedSearchLocationId: () => Id | undefined
getSyncServiceLocation: () => Promise<SyncServiceLocation | undefined>
): Promise<void> => {
const logger = createEndevorLogger();
logger.trace('Pull from Endevor into workspace called.');
Expand Down Expand Up @@ -99,47 +84,27 @@ export const pullFromEndevorCommand = async (
});
return;
}
const serviceDialogResult = await askForService(
await getValidServiceDescriptions(),
getLastUsedServiceId(),
'Last Used'
);
if (serviceDialogCancelled(serviceDialogResult)) {
logger.trace('No Endevor connection was selected.');
const syncServiceLocation = await getSyncServiceLocation();
if (!syncServiceLocation) {
reporter.sendTelemetryEvent({
type: TelemetryEvents.COMMAND_PULL_FROM_ENDEVOR_COMPLETED,
status: PullFromEndevorCommandCompletedStatus.CANCELLED,
});
return;
}
const serviceId = serviceDialogResult.id;
logger.updateContext({ serviceId });
const locationDialogResult = await askForSearchLocation(
getValidSearchLocationDescriptions(),
getLastUsedSearchLocationId(),
'Last Used'
);
if (locationDialogCancelled(locationDialogResult)) {
logger.trace('No Endevor inventory location was selected.');
reporter.sendTelemetryEvent({
type: TelemetryEvents.COMMAND_PULL_FROM_ENDEVOR_COMPLETED,
status: PullFromEndevorCommandCompletedStatus.CANCELLED,
});
return;
}
const searchLocationId = locationDialogResult.id;
const { serviceId, searchLocationId } = syncServiceLocation;
logger.updateContext({ serviceId, searchLocationId });
dispatch({
type: SyncActions.UPDATE_LAST_USED,
lastUsedServiceId: serviceId,
lastUsedSearchLocationId: searchLocationId,
});
const connectionParams = await getConnectionConfiguration(
serviceId,
searchLocationId
);
if (!connectionParams) return;
const { service, searchLocation } = connectionParams;
dispatch({
type: Actions.UPDATE_LAST_USED,
lastUsedServiceId: serviceId,
lastUsedSearchLocationId: searchLocationId,
});
const pullChangeControlValue = await askForChangeControlValue({
ccid: searchLocation.ccid,
comment: searchLocation.comment,
Expand Down
65 changes: 13 additions & 52 deletions packages/explorer-for-endevor/src/commands/sync/syncWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,13 @@ import {
} from '../../store/scm/workspace';
import { reporter } from '../../globals';
import { getWorkspaceUri } from '@local/vscode-wrapper/workspace';
import {
askForService,
dialogCancelled as serviceDialogCancelled,
} from '../../dialogs/locations/endevorServiceDialogs';
import {
askForSearchLocation,
dialogCancelled as locationDialogCancelled,
} from '../../dialogs/locations/endevorSearchLocationDialogs';
import {
askForChangeControlValue,
dialogCancelled as changeControlDialogCancelled,
} from '../../dialogs/change-control/endevorChangeControlDialogs';
import {
EndevorId,
ValidEndevorSearchLocationDescriptions,
ExistingEndevorServiceDescriptions,
} from '../../store/_doc/v2/Store';
import { EndevorId } from '../../store/_doc/v2/Store';
import { withNotificationProgress } from '@local/vscode-wrapper/window';
import { isError } from '../../utils';
import {
SyncActions,
UpdateLastUsed,
WorkspaceSynced,
} from '../../store/scm/_doc/Actions';
import {
SyncWorkspaceCommandCompletedStatus,
TelemetryEvents,
Expand All @@ -54,11 +37,12 @@ import {
EndevorAuthorizedService,
SearchLocation,
} from '../../api/_doc/Endevor';
import { Id } from '../../store/storage/_doc/Storage';
import { createEndevorLogger } from '../../logger';
import { SyncServiceLocation } from '../../store/scm/resolvers';
import { Actions, UpdateLastUsed } from '../../store/_doc/Actions';

export const syncWorkspace = async (
dispatch: (action: WorkspaceSynced | UpdateLastUsed) => Promise<void>,
dispatch: (action: UpdateLastUsed) => Promise<void>,
getConnectionConfiguration: (
serviceId: EndevorId,
searchLocationId: EndevorId
Expand All @@ -69,10 +53,7 @@ export const syncWorkspace = async (
}
| undefined
>,
getValidServiceDescriptions: () => Promise<ExistingEndevorServiceDescriptions>,
getValidSearchLocationDescriptions: () => ValidEndevorSearchLocationDescriptions,
getLastUsedServiceId: () => Id | undefined,
getLastUsedSearchLocationId: () => Id | undefined
getSyncServiceLocation: () => Promise<SyncServiceLocation | undefined>
): Promise<void> => {
const logger = createEndevorLogger();
logger.trace('Synchronization of an Endevor workspace called.');
Expand Down Expand Up @@ -103,47 +84,27 @@ export const syncWorkspace = async (
});
return;
}
const serviceDialogResult = await askForService(
await getValidServiceDescriptions(),
getLastUsedServiceId(),
'Last Used'
);
if (serviceDialogCancelled(serviceDialogResult)) {
logger.trace('No Endevor connection was selected.');
reporter.sendTelemetryEvent({
type: TelemetryEvents.COMMAND_SYNC_WORKSPACE_COMPLETED,
status: SyncWorkspaceCommandCompletedStatus.CANCELLED,
});
return;
}
const serviceId = serviceDialogResult.id;
logger.updateContext({ serviceId });
const locationDialogResult = await askForSearchLocation(
getValidSearchLocationDescriptions(),
getLastUsedSearchLocationId(),
'Last Used'
);
if (locationDialogCancelled(locationDialogResult)) {
logger.trace('No Endevor inventory location was selected.');
const syncServiceLocation = await getSyncServiceLocation();
if (!syncServiceLocation) {
reporter.sendTelemetryEvent({
type: TelemetryEvents.COMMAND_SYNC_WORKSPACE_COMPLETED,
status: SyncWorkspaceCommandCompletedStatus.CANCELLED,
});
return;
}
const searchLocationId = locationDialogResult.id;
const { serviceId, searchLocationId } = syncServiceLocation;
logger.updateContext({ serviceId, searchLocationId });
dispatch({
type: SyncActions.UPDATE_LAST_USED,
lastUsedServiceId: serviceId,
lastUsedSearchLocationId: searchLocationId,
});
const connectionParams = await getConnectionConfiguration(
serviceId,
searchLocationId
);
if (!connectionParams) return;
const { service, searchLocation } = connectionParams;
dispatch({
type: Actions.UPDATE_LAST_USED,
lastUsedServiceId: serviceId,
lastUsedSearchLocationId: searchLocationId,
});
const syncChangeControlValue = await askForChangeControlValue({
ccid: searchLocation.ccid,
comment: searchLocation.comment,
Expand Down
Loading

0 comments on commit 6c497a4

Please sign in to comment.