diff --git a/src/components/constraints/ConstraintListItem.svelte b/src/components/constraints/ConstraintListItem.svelte
index 8907e2ae8d..3caae58d58 100644
--- a/src/components/constraints/ConstraintListItem.svelte
+++ b/src/components/constraints/ConstraintListItem.svelte
@@ -8,7 +8,6 @@
import VisibleShowIcon from '@nasa-jpl/stellar/icons/visible_show.svg?component';
import WarningIcon from '@nasa-jpl/stellar/icons/warning.svg?component';
import { createEventDispatcher } from 'svelte';
- import { PlanStatusMessages } from '../../enums/planStatusMessages';
import { SearchParameters } from '../../enums/searchParameters';
import { Status } from '../../enums/status';
import type {
@@ -31,10 +30,11 @@
export let constraint: ConstraintMetadata;
export let constraintPlanSpec: ConstraintPlanSpecification;
export let constraintResponse: ConstraintResponse;
+ export let editPermissionError: string = 'You do not have permission to edit constraints for this plan.';
export let modelId: number | undefined;
export let hasReadPermission: boolean = false;
export let hasEditPermission: boolean = false;
- export let readOnly: boolean = false;
+ export let readPermissionError: string = 'You do not have permission to view this constraint.';
export let totalViolationCount: number = 0;
export let visible: boolean = true;
@@ -117,9 +117,7 @@
on:click|stopPropagation
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError: readOnly
- ? PlanStatusMessages.READ_ONLY
- : 'You do not have permission to edit plan constraints',
+ permissionError: editPermissionError,
}}
use:tooltip={{
content: `${constraintPlanSpec.enabled ? 'Disable constraint' : 'Enable constraint'} on plan`,
@@ -173,9 +171,7 @@
on:click|stopPropagation
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError: readOnly
- ? PlanStatusMessages.READ_ONLY
- : 'You do not have permission to edit plan constraints',
+ permissionError: editPermissionError,
}}
>
@@ -206,7 +202,7 @@
permissionHandler,
{
hasPermission: hasReadPermission,
- permissionError: 'You do not have permission to edit this constraint',
+ permissionError: readPermissionError,
},
],
]}
@@ -214,8 +210,34 @@
View Constraint
{#if version?.type === 'JAR'}
- Duplicate Invocation
- Delete Invocation
+
+ Duplicate Invocation
+
+
+ Delete Invocation
+
{/if}
diff --git a/src/components/constraints/ConstraintsPanel.svelte b/src/components/constraints/ConstraintsPanel.svelte
index 2f0c3d438e..87ed771e7b 100644
--- a/src/components/constraints/ConstraintsPanel.svelte
+++ b/src/components/constraints/ConstraintsPanel.svelte
@@ -55,6 +55,7 @@
let showAll: boolean = true;
let filterText: string = '';
let filteredConstraints: ConstraintPlanSpecification[] = [];
+ let hasSpecEditPermission: boolean;
let endTime: string;
let endTimeField: FieldStore;
let numOfPrivateConstraints: number = 0;
@@ -72,6 +73,7 @@
} else {
endTime = '';
}
+ hasSpecEditPermission = featurePermissions.constraintsPlanSpec.canUpdate(user, $plan) && !$planReadOnly;
}
$: startTimeField = field(startTime, [required, $plugins.time.primary.validate]);
@@ -377,8 +379,11 @@
constraint={$constraintsMap[constraint.constraint_id]}
constraintPlanSpec={$allowedConstraintPlanSpecMap[constraint.constraint_id]}
constraintResponse={constraintToConstraintResponseMap[constraint.constraint_id]}
+ editPermissionError={$planReadOnly
+ ? PlanStatusMessages.READ_ONLY
+ : 'You do not have permission to edit constraints for this plan.'}
+ hasEditPermission={hasSpecEditPermission}
hasReadPermission={featurePermissions.constraints.canRead(user)}
- hasEditPermission={$plan ? featurePermissions.constraintsPlanSpec.canUpdate(user, $plan) : false}
modelId={$plan?.model.id}
totalViolationCount={$constraintResponseMap[constraint.constraint_id]?.results.violations?.length || 0}
visible={$constraintVisibilityMap[constraint.constraint_id]}
diff --git a/src/components/scheduling/SchedulingConditionsPanel.svelte b/src/components/scheduling/SchedulingConditionsPanel.svelte
index 2ac5c0a438..b5a7f44ba6 100644
--- a/src/components/scheduling/SchedulingConditionsPanel.svelte
+++ b/src/components/scheduling/SchedulingConditionsPanel.svelte
@@ -25,10 +25,14 @@
let activeElement: HTMLElement;
let conditionsFilterText: string = '';
+ let hasSpecEditPermission: boolean;
let filteredSchedulingConditionSpecs: SchedulingConditionPlanSpecification[] = [];
let numOfPrivateConditions: number = 0;
let visibleSchedulingConditionSpecs: SchedulingConditionPlanSpecification[] = [];
+ $: if ($plan) {
+ hasSpecEditPermission = featurePermissions.schedulingConditionsPlanSpec.canUpdate(user, $plan) && !$planReadOnly;
+ }
// TODO: remove this after db merge as it becomes redundant
$: visibleSchedulingConditionSpecs = $allowedSchedulingConditionSpecs.filter(
({ condition_metadata: conditionMetadata }) => {
@@ -132,9 +136,10 @@
import { base } from '$app/paths';
import { createEventDispatcher } from 'svelte';
- import { PlanStatusMessages } from '../../../enums/planStatusMessages';
import { SearchParameters } from '../../../enums/searchParameters';
import type { SchedulingConditionMetadata, SchedulingConditionPlanSpecification } from '../../../types/scheduling';
import { getTarget } from '../../../utilities/generic';
@@ -14,10 +13,11 @@
export let condition: SchedulingConditionMetadata;
export let conditionPlanSpec: SchedulingConditionPlanSpecification;
+ export let editPermissionError: string = 'You do not have permission to edit scheduling conditions for this plan.';
export let hasEditPermission: boolean = false;
+ export let hasReadPermission: boolean = false;
export let modelId: number | undefined;
- export let permissionError: string = '';
- export let readOnly: boolean = false;
+ export let readPermissionError: string = 'You do not have permission to view this scheduling condition.';
const dispatch = createEventDispatcher<{
updateConditionPlanSpec: SchedulingConditionPlanSpecification;
@@ -56,7 +56,7 @@
on:click|stopPropagation
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError,
+ permissionError: editPermissionError,
}}
use:tooltip={{
content: `${conditionPlanSpec.enabled ? 'Disable condition' : 'Enable condition'} on plan`,
@@ -75,9 +75,7 @@
on:click|stopPropagation
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError: readOnly
- ? PlanStatusMessages.READ_ONLY
- : 'You do not have permission to edit plan conditions',
+ permissionError: editPermissionError,
}}
>
@@ -103,8 +101,8 @@
[
permissionHandler,
{
- hasPermission: hasEditPermission,
- permissionError,
+ hasPermission: hasReadPermission,
+ permissionError: readPermissionError,
},
],
]}
diff --git a/src/components/scheduling/goals/SchedulingGoal.svelte b/src/components/scheduling/goals/SchedulingGoal.svelte
index fff5d2697e..005a2d888f 100644
--- a/src/components/scheduling/goals/SchedulingGoal.svelte
+++ b/src/components/scheduling/goals/SchedulingGoal.svelte
@@ -5,7 +5,6 @@
import CaretDownFillIcon from 'bootstrap-icons/icons/caret-down-fill.svg?component';
import CaretUpFillIcon from 'bootstrap-icons/icons/caret-up-fill.svg?component';
import { createEventDispatcher } from 'svelte';
- import { PlanStatusMessages } from '../../../enums/planStatusMessages';
import { SearchParameters } from '../../../enums/searchParameters';
import type { FormParameter } from '../../../types/parameter';
import type {
@@ -22,12 +21,13 @@
import SchedulingGoalAnalysesActivities from './SchedulingGoalAnalysesActivities.svelte';
import SchedulingGoalAnalysesBadge from './SchedulingGoalAnalysesBadge.svelte';
+ export let editPermissionError: string = 'You do not have permission to edit scheduling goals for this plan.';
export let goal: SchedulingGoalMetadata;
export let goalPlanSpec: SchedulingGoalPlanSpecification;
export let hasEditPermission: boolean = false;
+ export let hasReadPermission: boolean = false;
export let modelId: number | undefined;
- export let permissionError: string = '';
- export let readOnly: boolean = false;
+ export let readPermissionError: string = 'You do not have permission to view this scheduling goal.';
const dispatch = createEventDispatcher<{
deleteGoalInvocation: SchedulingGoalPlanSpecification;
@@ -157,7 +157,7 @@
on:click|stopPropagation
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError,
+ permissionError: editPermissionError,
}}
use:tooltip={{
content: `${enabled ? 'Disable goal' : 'Enable goal'} on plan`,
@@ -183,7 +183,7 @@
on:keydown={onKeyDown}
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError,
+ permissionError: editPermissionError,
}}
/>
{#if hasEditPermission}
@@ -214,7 +214,7 @@
on:click|stopPropagation
use:permissionHandler={{
hasPermission: hasEditPermission,
- permissionError: readOnly ? PlanStatusMessages.READ_ONLY : 'You do not have permission to edit plan goals',
+ permissionError: editPermissionError,
}}
>
@@ -246,8 +246,8 @@
[
permissionHandler,
{
- hasPermission: hasEditPermission,
- permissionError,
+ hasPermission: hasReadPermission,
+ permissionError: readPermissionError,
},
],
]}
@@ -260,7 +260,7 @@
permissionHandler,
{
hasPermission: hasEditPermission,
- permissionError,
+ permissionError: editPermissionError,
},
],
]}
@@ -277,8 +277,34 @@
{#if version?.type === 'JAR'}
- Duplicate Invocation
- Delete Invocation
+
+ Duplicate Invocation
+
+
+ Delete Invocation
+
{/if}