Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show Configuration diff for PreDeployments #879

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions web/src/components/config/ConfigSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<dt class="config-label text-weight-medium space-between-x-sm">
<span>{{ label }}</span>
<span
v-if="previousValue !== value"
v-if="showDiff"
class="text-low-contrast text-weight-regular"
>
Changed since last deploy
Expand All @@ -17,7 +17,7 @@
class="flex gap-sm"
>
<template
v-if="previousValue !== value"
v-if="showDiff"
>
<DiffTag
v-if="previousValue !== undefined"
Expand All @@ -37,9 +37,13 @@
</template>

<script setup lang="ts">
import { computed, inject } from 'vue';

import { isPreDeployment } from 'src/api';
import DiffTag from 'src/components/DiffTag.vue';
import { deploymentKey } from 'src/utils/provide';

defineProps({
const props = defineProps({
label: {
type: String,
required: true,
Expand All @@ -55,6 +59,13 @@ defineProps({
default: undefined,
},
});

const deployment = inject(deploymentKey);

const showDiff = computed((): boolean => {
const isPre = deployment ? isPreDeployment(deployment) : false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't guaranteed to get a deployment. There is no way in Vue to tell it we are for sure provided a key value, but we can easily default to the previous behavior of comparing just the values if we aren't provided a deployment.

return !isPre && props.previousValue !== props.value;
});
</script>

<style scoped lang="scss">
Expand Down
11 changes: 11 additions & 0 deletions web/src/utils/provide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (C) 2023 by Posit Software, PBC.

import { InjectionKey } from 'vue';

import { Deployment, DeploymentError, PreDeployment } from 'src/api';

export const deploymentKey = Symbol('deployment') as InjectionKey<
PreDeployment |
Deployment |
DeploymentError
>;
Comment on lines +7 to +11
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This methodology is describe in Vue's docs under Typing Provide / Inject.

4 changes: 4 additions & 0 deletions web/src/views/deployment/DeploymentPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import ConfigSettings from 'src/components/config/ConfigSettings.vue';
import FileTree from 'src/components/FileTree.vue';
import DeploymentHeader from './DeploymentHeader.vue';
import DeploymentSection from 'src/components/DeploymentSection.vue';
import { provide } from 'vue';
import { deploymentKey } from 'src/utils/provide';

const router = useRouter();
const api = useApi();
Expand All @@ -63,6 +65,8 @@ const props = defineProps({

const deployment = deployments.getDeploymentRef(props.name);

provide(deploymentKey, deployment.value);

watch(
() => deployment.value,
() => {
Expand Down
Loading