Skip to content

Commit

Permalink
Fix hide inactive environments (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
meniRoy authored Sep 19, 2023
1 parent d2fb0f6 commit 5b2eda3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ApiClient {
const response = await this.instance.get<EnvironmentModel[]>(
`/environments`,
{
params: { organizationId },
params: { organizationId, isActive: true },
}
);

Expand Down
19 changes: 8 additions & 11 deletions src/get-environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,15 @@ export async function getEnvironmentsForBranch() {
} else {
extensionState.setCurrentBranch(currentBranch);
}
environments = environments
.filter(
(environment) =>
repositoriesEqual(
environment?.latestDeploymentLog?.blueprintRepository,
repository
) &&
environment?.latestDeploymentLog?.blueprintRevision === currentBranch
)
.filter((environment) => environment.status !== "INACTIVE");
environments = environments.filter(
(environment) =>
repositoriesEqual(
environment?.latestDeploymentLog?.blueprintRepository,
repository
) &&
environment?.latestDeploymentLog?.blueprintRevision === currentBranch
);
}

return environments;
}

Expand Down
24 changes: 0 additions & 24 deletions src/test/integration/suite/environments.test.it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,6 @@ suite("environments", function () {
});
});

test("should not show inactive environments", async () => {
const activeEnvName = "active env";
const inactiveEnvName = "inactive env";
const environments = [
getEnvironmentMock("main", "https://github.com/user/repo", {
name: activeEnvName,
}),
getEnvironmentMock("main", "https://github.com/user/repo", {
status: "INACTIVE",
name: inactiveEnvName,
}),
];
await initTest(environments);

const environmentsDataProvider =
extension.environmentsDataProvider as Env0EnvironmentsProvider;

await waitFor(() => {
const environments = environmentsDataProvider.getChildren();
expect(environments).toHaveLength(1);
expect(environments[0].label).toBe(activeEnvName);
});
});

test("should show environments only for the current repo", async () => {
const envName = "active env";
const differentRepoEnvName = "different repo env";
Expand Down

0 comments on commit 5b2eda3

Please sign in to comment.