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

Fix: Make deployment toggles visible but disabled for deployments when a user does not have update deployment permissions #2692

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
5 changes: 4 additions & 1 deletion src/components/DeploymentDisableToggle.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<p-tooltip :text="tooltipText" side="left">
<p-toggle v-if="deployment.can.update" v-model="internalValue" :state :disabled="deployment.deprecated" />
<p-toggle v-model="internalValue" :state :disabled="deployment.deprecated || !deployment.can.update" />
</p-tooltip>
</template>

Expand Down Expand Up @@ -36,6 +36,9 @@
})

const tooltipText = computed(() => {
if (!props.deployment.can.update) {
return localization.info.deploymentUpdateDisabled
}
return props.deployment.disabled ? localization.info.deploymentDisabled : localization.info.deploymentEnabled
})

Expand Down
11 changes: 9 additions & 2 deletions src/components/DeploymentScheduleToggle.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<p-tooltip text="Pause or resume this schedule" side="left">
<p-toggle v-if="deployment.can.update" v-model="internalValue" :disabled="loading || deployment.paused || deployment.disabled" />
<p-tooltip :text="tooltipText" side="left">
<p-toggle v-model="internalValue" :disabled="loading || deployment.paused || deployment.disabled || !deployment.can.update" />
</p-tooltip>
</template>

Expand Down Expand Up @@ -34,6 +34,13 @@

const loading = ref(false)

const tooltipText = computed(() => {
if (!props.deployment.can.update) {
return localization.info.deploymentUpdateDisabled
}
return 'Pause or resume this schedule'
})

const updateSchedule = async (value: boolean): Promise<void> => {
loading.value = true
try {
Expand Down
11 changes: 9 additions & 2 deletions src/components/DeploymentToggle.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<p-tooltip text="Pause or resume all schedules" side="left">
<p-toggle v-if="deployment.can.update" v-model="internalValue" :state :disabled="deployment.deprecated || deployment.disabled" />
<p-tooltip :text="tooltipText" side="left">
<p-toggle v-model="internalValue" :state :disabled="deployment.deprecated || deployment.disabled || !deployment.can.update" />
</p-tooltip>
</template>

Expand Down Expand Up @@ -33,6 +33,13 @@

const state = reactive<State>({ pending: false, valid: true, validated: false })

const tooltipText = computed(() => {
if (!props.deployment.can.update) {
return localization.info.deploymentUpdateDisabled
}
return 'Pause or resume all schedules'
})

const toggleDeploymentSchedule = async (value: boolean): Promise<void> => {
state.pending = true
const message = value ? localization.success.activateDeployment : localization.success.pauseDeployment
Expand Down
1 change: 1 addition & 0 deletions src/localization/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const en = {
deploymentName: 'Deployment name',
deploymentDisabled: 'Deployment disabled, click to enable',
deploymentEnabled: 'Deployment enabled, click to disable',
deploymentUpdateDisabled: 'You do not have the right permissions to update this deployment',
searchByDeploymentName: 'Search by deployment name',
workPools: 'Work Pools',
all: 'All',
Expand Down
Loading