Skip to content

Commit

Permalink
Merge pull request #821 from posit-dev/dotnomad/pre-deployment-details
Browse files Browse the repository at this point in the history
Add `PreDeployment` to details page types and fix compile
  • Loading branch information
dotNomad authored Jan 16, 2024
2 parents b68bc65 + 301268e commit 0d523f7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 30 deletions.
74 changes: 50 additions & 24 deletions web/src/views/existing-deployment/ExistingDeploymentHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@
{{ deployment.serverUrl }}
</a>
</p>
<p>
{{ deployment.id }}
</p>
<p>
Last Deployed on {{ formatDateString(deployment.deployedAt) }}
</p>
<template v-if="isDeployment(deployment)">
<p>
{{ deployment.id }}
</p>
<p>
Last Deployed on {{ formatDateString(deployment.deployedAt) }}
</p>
</template>
<template v-else>
<p>
An ID will be created on first deployment.
</p>
<p>
Never Deployed
</p>
</template>
</div>

<div
Expand Down Expand Up @@ -73,12 +83,13 @@
<div class="row justify-left">
<div class="col-11">
<DeployProgressSummary
v-if="isDeployment(deployment)"
:id="deployment.id"
:current-tense="showDeployStatusAsCurrent"
/>
<PLink
v-if="showLogsLink"
:to="routerLocation"
v-if="progressLink"
:to="progressLink"
>
View summarized deployment logs
</PLink>
Expand All @@ -94,7 +105,15 @@

import { ref, watch, PropType, computed } from 'vue';

import { Account, ConfigurationError, Deployment, useApi } from 'src/api';
import {
Account,
ConfigurationError,
Deployment,
PreDeployment,
useApi,
isDeployment,
isPreDeployment
} from 'src/api';
import PLink from 'src/components/PLink.vue';
import SelectAccount from 'src/components/SelectAccount.vue';
import PButton from 'src/components/PButton.vue';
Expand All @@ -117,7 +136,7 @@ const numSuccessfulDeploys = ref(0);
const emit = defineEmits(['deploy']);

const props = defineProps({
deployment: { type: Object as PropType<Deployment>, required: true },
deployment: { type: Object as PropType<Deployment | PreDeployment>, required: true },
configError: {
type: Object as PropType<ConfigurationError>,
required: false,
Expand All @@ -129,19 +148,23 @@ const onChange = (account: Account) => {
selectedAccount.value = account;
};

const showLogsLink = computed(() => {
return eventStore.doesPublishStatusApply(props.deployment.id);
});
const progressLink = computed(() => {
if (isPreDeployment(props.deployment)) {
return undefined;
}

if (eventStore.doesPublishStatusApply(props.deployment.id)) {
return {
name: 'progress',
query: {
name: props.deployment.saveName,
operation: operationStr.value,
id: props.deployment.id,
},
};
}

const routerLocation = computed(() => {
return {
name: 'progress',
query: {
name: props.deployment.saveName,
operation: operationStr.value,
id: props.deployment.id,
},
};
return undefined;
});

const redeployDisableTitle = computed(() => {
Expand Down Expand Up @@ -185,7 +208,7 @@ const initiateRedeploy = async() => {
accountName,
props.deployment.saveName,
destinationURL,
props.deployment.id,
isDeployment(props.deployment) ? props.deployment.id : undefined,
);
deployingLocalId.value = result;
} catch (error: unknown) {
Expand Down Expand Up @@ -239,7 +262,10 @@ watch(
// and last publishing run was ours
(
eventStore.doesPublishStatusApply(deployingLocalId.value) ||
eventStore.doesPublishStatusApply(props.deployment.id)
(
isDeployment(props.deployment) &&
eventStore.doesPublishStatusApply(props.deployment.id)
)
) &&
// and it was successful enough to get a content id assigned
eventStore.currentPublishStatus.contentId
Expand Down
8 changes: 2 additions & 6 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, isDeploymentRecordError, isPreDeployment } from 'src/api/types/deployments';
import { Deployment, PreDeployment, isDeploymentRecordError } from 'src/api/types/deployments';
import {
newFatalErrorRouteLocation,
} from 'src/utils/errors';
Expand All @@ -45,7 +45,7 @@ const route = useRoute();
const router = useRouter();
const api = useApi();

const deployment = ref<Deployment>();
const deployment = ref<Deployment | PreDeployment>();

const configurations = ref<Array<Configuration | ConfigurationError>>([]);

Expand Down Expand Up @@ -92,10 +92,6 @@ const getDeployment = async() => {
// 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);
} else if (isPreDeployment(d)) {
// let the fatal error page handle this deployment error.
// we're in a header, they can't fix it here.
throw new Error('This page doesn\'t support pre-deployments yet.');
} else {
deployment.value = d;
}
Expand Down

0 comments on commit 0d523f7

Please sign in to comment.