Skip to content

Commit

Permalink
Merge pull request #798 from posit-dev/sagerb-ux-refactor-deployment-…
Browse files Browse the repository at this point in the history
…error

UX: Refactor DeploymentError to DeploymentRecordError
  • Loading branch information
sagerb authored Jan 11, 2024
2 parents 16ba021 + c76572f commit d32a748
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions web/src/api/resources/Deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { AxiosInstance } from 'axios';

import { Deployment, DeploymentError } from 'src/api/types/deployments';
import { Deployment, DeploymentRecordError } from 'src/api/types/deployments';

export class Deployments {
private client: AxiosInstance;
Expand All @@ -15,7 +15,7 @@ export class Deployments {
// 200 - success
// 500 - internal server error
getAll() {
return this.client.get<Array<Deployment | DeploymentError>>(
return this.client.get<Array<Deployment | DeploymentRecordError>>(
'/deployments',
);
}
Expand All @@ -26,7 +26,7 @@ export class Deployments {
// 500 - internal server error
get(id: string) {
const encodedId = encodeURIComponent(id);
return this.client.get<Deployment | DeploymentError>(
return this.client.get<Deployment | DeploymentRecordError>(
`deployments/${encodedId}`,
);
}
Expand Down
10 changes: 5 additions & 5 deletions web/src/api/types/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type DeploymentLocation = {
deploymentPath: string;
}

export type DeploymentError = {
export type DeploymentRecordError = {
error: AgentError,
} & DeploymentLocation

Expand All @@ -24,8 +24,8 @@ export type Deployment = {
saveName: string,
} & DeploymentLocation & Configuration;

export function isDeploymentError(
d: Deployment | DeploymentError
): d is DeploymentError {
return (d as DeploymentError).error !== undefined;
export function isDeploymentRecordError(
d: Deployment | DeploymentRecordError
): d is DeploymentRecordError {
return (d as DeploymentRecordError).error !== undefined;
}
4 changes: 2 additions & 2 deletions web/src/views/add-new-deployment/AddNewDeployment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import { Account, useApi } from 'src/api';
import { computed, ref } from 'vue';
import { RouteLocationRaw, useRouter } from 'vue-router';
import { Deployment, isDeploymentError } from 'src/api/types/deployments';
import { Deployment, isDeploymentRecordError } from 'src/api/types/deployments';

import AccountRadio from 'src/views/add-new-deployment/AccountRadio.vue';
import { newFatalErrorRouteLocation } from 'src/util/errors';
Expand Down Expand Up @@ -95,7 +95,7 @@ async function getDeployments() {
// 500 - internal server error
const response = (await api.deployments.getAll()).data;
deployments.value = response.filter<Deployment>((d): d is Deployment => {
return !isDeploymentError(d);
return !isDeploymentRecordError(d);
});
} catch (error: unknown) {
router.push(newFatalErrorRouteLocation(error, 'ProjectPage::getDeployments()'));
Expand Down
4 changes: 2 additions & 2 deletions web/src/views/existing-deployment/ExistingDeploymentPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { ref, computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';

import { Configuration, ConfigurationError, isConfigurationError, useApi } from 'src/api';
import { Deployment, isDeploymentError } from 'src/api/types/deployments';
import { Deployment, isDeploymentRecordError } from 'src/api/types/deployments';
import {
newFatalErrorRouteLocation,
} from 'src/util/errors';
Expand Down Expand Up @@ -88,7 +88,7 @@ const getDeployment = async() => {
// 500 - internal server error
const response = await api.deployments.get(deploymentName.value);
const d = response.data;
if (isDeploymentError(d)) {
if (isDeploymentRecordError(d)) {
// let the fatal error page handle this deployment error.
// we're in a header, they can't fix it here.
throw new Error(d.error.msg);
Expand Down
6 changes: 3 additions & 3 deletions web/src/views/project-page/DeploymentsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<script setup lang="ts">
import { computed, ref } from 'vue';

import { Deployment, DeploymentError, isDeploymentError, useApi } from 'src/api';
import { Deployment, DeploymentRecordError, isDeploymentRecordError, useApi } from 'src/api';
import { ErrorMessages, buildErrorBannerMessage, newFatalErrorRouteLocation } from 'src/util/errors';
import { sortByDateString } from 'src/utils/date';
import { router } from 'src/router';
Expand Down Expand Up @@ -99,9 +99,9 @@ async function getDeployments() {
// 500 - internal server error
const response = (await api.deployments.getAll()).data;
deployments.value = response.filter<Deployment>((d): d is Deployment => {
return !isDeploymentError(d);
return !isDeploymentRecordError(d);
});
const deploymentErrors: DeploymentError[] = response.filter(isDeploymentError);
const deploymentErrors: DeploymentRecordError[] = response.filter(isDeploymentRecordError);
if (deploymentErrors) {
// We will show deployment errors on this page, while all other pages
// route these towards the fatal error page. This is because the user
Expand Down

0 comments on commit d32a748

Please sign in to comment.