Skip to content

Commit

Permalink
remove handling of legacy dependencies (#2444)
Browse files Browse the repository at this point in the history
  • Loading branch information
gayathrir11 authored Aug 8, 2023
1 parent a9a55ad commit 7f4c5c0
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 239 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-adults-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-application-studio': minor
---

Remove handling of legacy dependencies
5 changes: 5 additions & 0 deletions .changeset/neat-bobcats-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-server-depot': patch
---

Remove deprecated depot api that fetches project by id.
4 changes: 4 additions & 0 deletions .changeset/purple-waves-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
'@finos/legend-extension-dsl-service': patch
'@finos/legend-server-sdlc': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ export const TEST__setUpEditor = async (
latestProjectStructureVersion: PlainObject<ProjectStructureVersion>;
availableGenerationDescriptions: GenerationConfigurationDescription[];
projects: PlainObject<StoreProjectData>[];
projectData: PlainObject<StoreProjectData>[];
projectDependency: PlainObject<ProjectVersionEntities>[];
projectDependencyVersions: string[];
projectDependencyReport: PlainObject<RawProjectDependencyReport>;
Expand All @@ -236,7 +235,6 @@ export const TEST__setUpEditor = async (
entities,
latestProjectStructureVersion,
availableGenerationDescriptions,
projectData,
projects,
projectDependency,
projectDependencyVersions,
Expand Down Expand Up @@ -295,10 +293,6 @@ export const TEST__setUpEditor = async (
MOCK__editorStore.depotServerClient,
'getVersions',
).mockResolvedValue(projectDependencyVersions);
createSpy(
MOCK__editorStore.depotServerClient,
'getProjectById',
).mockResolvedValue(projectData);
createSpy(
MOCK__editorStore.depotServerClient,
'collectDependencyEntities',
Expand Down Expand Up @@ -417,7 +411,6 @@ export const TEST__setUpEditorWithDefaultSDLCData = (
...TEST_DATA__DefaultSDLCInfo.availableCodeGenerations,
],
projects: [],
projectData: [],
projectDependency: [],
projectDependencyVersions: [],
projectDependencyReport: TEST_DATA__DefaultDepotReport.dependencyReport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TEST_DATA__ProjectConfiguration = {
artifactId: 'dependency-test',
projectDependencies: [
{
projectId: 'PROD-1',
projectId: 'org.finos.legend:prod-1',
versionId: '2.0.0',
},
{
Expand All @@ -55,17 +55,6 @@ const TEST_DATA__ProjectConfiguration = {
metamodelDependencies: [],
};

const TEST_DATA__ProjectData = [
{
id: 'PROD-1',
projectId: 'PROD-1',
groupId: 'org.finos.legend',
artifactId: 'prod-1',
versions: ['1.0.0', '2.0.0'],
latestVersion: '2.0.0',
},
];

const TEST_DATA__Projects = [
{
id: 'PROD-1',
Expand Down Expand Up @@ -122,7 +111,6 @@ test.skip(integrationTest('Test Project Report With Conflicts'), async () => {
projectConfiguration: TEST_DATA__ProjectConfiguration,
latestProjectStructureVersion: TEST_DATA__latestProjectStructure,
projects: TEST_DATA__Projects,
projectData: TEST_DATA__ProjectData,
projectDependency: TEST_DATA__DependencyEntities,
projectDependencyReport: TEST_DATA__ProjectDependencyReportWithConflict,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
} from '../../__test-utils__/EditorComponentTestUtils.js';
import { LEGEND_STUDIO_TEST_ID } from '../../../../__lib__/LegendStudioTesting.js';
import type { EditorStore } from '../../../../stores/editor/EditorStore.js';
import type { ProjectDependency } from '@finos/legend-server-sdlc';
import { TEST_DATA__ProjectDependencyReport } from './TEST_DATA__ProjectDependencyReport.js';
import {
RawProjectDependencyReport,
Expand All @@ -49,7 +48,7 @@ const TEST_DATA__ProjectConfiguration = {
artifactId: 'dependency-test',
projectDependencies: [
{
projectId: 'PROD-1',
projectId: 'org.finos.legend:prod-1',
versionId: '2.0.0',
},
{
Expand All @@ -60,17 +59,6 @@ const TEST_DATA__ProjectConfiguration = {
metamodelDependencies: [],
};

const TEST_DATA__ProjectData = [
{
id: 'PROD-1',
projectId: 'PROD-1',
groupId: 'org.finos.legend',
artifactId: 'prod-1',
versions: ['1.0.0', '2.0.0'],
latestVersion: '2.0.0',
},
];

const TEST_DATA__Projects = [
{
id: 'PROD-1',
Expand Down Expand Up @@ -127,7 +115,6 @@ beforeEach(async () => {
projectConfiguration: TEST_DATA__ProjectConfiguration,
latestProjectStructureVersion: TEST_DATA__latestProjectStructure,
projects: TEST_DATA__Projects,
projectData: TEST_DATA__ProjectData,
projectDependency: TEST_DATA__DependencyEntities,
projectDependencyVersions: TEST_DATA__Versions,
projectDependencyReport: TEST_DATA__ProjectDependencyReport,
Expand All @@ -145,9 +132,7 @@ test(integrationTest('Test Project Dependency Editor'), async () => {
const editorGroup = renderResult.getByTestId(
LEGEND_STUDIO_TEST_ID.EDITOR_GROUP_CONTENT,
);
const updateButton = getByText(editorGroup, 'Update');
fireEvent.click(getByText(editorGroup, 'Project Dependencies'));
const configState = MOCK__editorStore.projectConfigurationEditorState;

// dependency 1
await waitFor(() => getByText(editorGroup, 'PROD-1'));
Expand All @@ -158,30 +143,6 @@ test(integrationTest('Test Project Dependency Editor'), async () => {
await waitFor(() => getByText(editorGroup, 'PROD-2'));
await waitFor(() => getByText(editorGroup, 'org.finos.legend:prod-2'));
await waitFor(() => getByText(editorGroup, '3.0.0'));

const projectDependenciesToAdd =
configState.currentProjectConfiguration.projectDependencies.filter(
(dep) =>
!configState.originalConfig.projectDependencies.find(
(originalProjDep) => originalProjDep.hashCode === dep.hashCode,
),
);
const projectDependenciesToRemove =
configState.originalConfig.projectDependencies.filter(
(originalProjDep) =>
!configState.currentProjectConfiguration.projectDependencies.find(
(dep) => dep.hashCode === originalProjDep.hashCode,
),
);
expect(updateButton.getAttribute('disabled')).toBeNull();
expect(projectDependenciesToAdd).toHaveLength(1);
expect(projectDependenciesToRemove).toHaveLength(1);
expect((projectDependenciesToAdd[0] as ProjectDependency).projectId).toBe(
'org.finos.legend:prod-1',
);
expect((projectDependenciesToRemove[0] as ProjectDependency).projectId).toBe(
'PROD-1',
);
});

test(integrationTest('Test Project Report'), async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,19 +850,17 @@ const ProjectVersionDependencyEditor = observer(
}
};
const viewProject = (): void => {
if (!projectDependency.isLegacyDependency) {
applicationStore.navigationService.navigator.visitAddress(
applicationStore.navigationService.navigator.generateAddress(
generateViewProjectByGAVRoute(
guaranteeNonNullable(projectDependency.groupId),
guaranteeNonNullable(projectDependency.artifactId),
projectDependency.versionId === MASTER_SNAPSHOT_ALIAS
? SNAPSHOT_VERSION_ALIAS
: projectDependency.versionId,
),
applicationStore.navigationService.navigator.visitAddress(
applicationStore.navigationService.navigator.generateAddress(
generateViewProjectByGAVRoute(
guaranteeNonNullable(projectDependency.groupId),
guaranteeNonNullable(projectDependency.artifactId),
projectDependency.versionId === MASTER_SNAPSHOT_ALIAS
? SNAPSHOT_VERSION_ALIAS
: projectDependency.versionId,
),
);
}
),
);
};
// NOTE: This assumes that the dependant project is in the same studio instance as the current project
// In the future, the studio instance may be part of the project data
Expand Down Expand Up @@ -927,11 +925,7 @@ const ProjectVersionDependencyEditor = observer(
content={
<MenuContent>
<MenuContentItem
disabled={
projectDependency.isLegacyDependency ||
!selectedProject ||
!selectedVersionOption
}
disabled={!selectedProject || !selectedVersionOption}
onClick={viewProject}
title="View project"
>
Expand All @@ -940,7 +934,6 @@ const ProjectVersionDependencyEditor = observer(
<MenuContentItem
title="View SDLC project"
disabled={
projectDependency.isLegacyDependency ||
!selectedProject ||
!selectedVersionOption ||
!projectDependencyData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ const setup = async (
...TEST_DATA__DefaultSDLCInfo.availableCodeGenerations,
],
projects: [],
projectData: projectData ?? [],
projectDependency: [],
projectDependencyVersions: projectDependencyVersions ?? [],
projectDependencyReport: TEST_DATA__DefaultDepotReport.dependencyReport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ const ExplorerContextMenu = observer(
editorStore.projectConfigurationEditorState.projectConfiguration?.projectDependencies.find(
(dep) => dep.projectId === node?.packageableElement.name,
);
if (projectDependency && !projectDependency.isLegacyDependency) {
if (projectDependency) {
applicationStore.navigationService.navigator.visitAddress(
applicationStore.navigationService.navigator.generateAddress(
generateViewProjectByGAVRoute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TEST_DATA__ProjectConfiguration = {
artifactId: 'dependency-test',
projectDependencies: [
{
projectId: 'PROD-1',
projectId: 'org.finos.legend:prod-1',
versionId: '2.0.0',
},
{
Expand All @@ -52,17 +52,6 @@ const TEST_DATA__ProjectConfiguration = {
metamodelDependencies: [],
};

const TEST_DATA__ProjectData = [
{
id: 'PROD-1',
projectId: 'PROD-1',
groupId: 'org.finos.legend',
artifactId: 'prod-1',
versions: ['1.0.0', '2.0.0'],
latestVersion: '2.0.0',
},
];

const TEST_DATA__Projects = [
{
id: 'PROD-1',
Expand Down Expand Up @@ -157,7 +146,6 @@ beforeEach(async () => {
projectConfiguration: TEST_DATA__ProjectConfiguration,
latestProjectStructureVersion: TEST_DATA__latestProjectStructure,
projects: TEST_DATA__Projects,
projectData: TEST_DATA__ProjectData,
projectDependency: TEST_DATA__DependencyEntities,
projectDependencyReport: TEST_DATA__ProjectDependencyReport,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ import { ElementEditorState } from './editor-state/element-editor-state/ElementE
import { GraphGenerationState } from './editor-state/GraphGenerationState.js';
import { MODEL_IMPORT_NATIVE_INPUT_TYPE } from './editor-state/ModelImporterState.js';
import type { DSL_LegendStudioApplicationPlugin_Extension } from '../LegendStudioApplicationPlugin.js';
import {
type Entity,
EntitiesWithOrigin,
generateGAVCoordinates,
} from '@finos/legend-storage';
import { type Entity, EntitiesWithOrigin } from '@finos/legend-storage';
import {
type EntityChange,
type ProjectDependency,
Expand All @@ -59,7 +55,6 @@ import {
ProjectDependencyCoordinates,
RawProjectDependencyReport,
buildDependencyReport,
StoreProjectData,
} from '@finos/legend-server-depot';
import {
GRAPH_MANAGER_EVENT,
Expand Down Expand Up @@ -752,53 +747,15 @@ export class EditorGraphState {
projectDependencies: ProjectDependency[],
): Promise<ProjectDependencyCoordinates[]> {
return Promise.all(
projectDependencies.map(async (dep) => {
/**
* We expect current dependency ids to be in the format of {groupId}:{artifactId}.
* For the legacy dependency we must fetch the corresponding coordinates (group, artifact ids) from the depot server
*
* @backwardCompatibility
*/
if (dep.isLegacyDependency) {
return this.editorStore.depotServerClient
.getProjectById(dep.projectId)
.then((projects) => {
const projectsData = projects.map((p) =>
StoreProjectData.serialization.fromJson(p),
);
if (projectsData.length !== 1) {
throw new Error(
`Expected 1 project for project ID '${dep.projectId}'. Got ${
projectsData.length
} projects with coordinates ${projectsData
.map(
(i) =>
`'${generateGAVCoordinates(
i.groupId,
i.artifactId,
undefined,
)}'`,
)
.join(', ')}.`,
);
}
const project = projectsData[0] as StoreProjectData;
return new ProjectDependencyCoordinates(
project.groupId,
project.artifactId,
dep.versionId,
);
});
} else {
return Promise.resolve(
new ProjectDependencyCoordinates(
guaranteeNonNullable(dep.groupId),
guaranteeNonNullable(dep.artifactId),
dep.versionId,
),
);
}
}),
projectDependencies.map(async (dep) =>
Promise.resolve(
new ProjectDependencyCoordinates(
guaranteeNonNullable(dep.groupId),
guaranteeNonNullable(dep.artifactId),
dep.versionId,
),
),
),
);
}

Expand Down
Loading

0 comments on commit 7f4c5c0

Please sign in to comment.