Skip to content

Commit

Permalink
1905 | Added reason field to subscription and topic constratints on f…
Browse files Browse the repository at this point in the history
…rontend.
  • Loading branch information
adriansobolewski committed Oct 16, 2024
1 parent bc06c4f commit 43cb994
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions hermes-console/src/api/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ConstraintsConfig {

export interface Constraint {
consumersNumber: number;
reason: string;
}

export interface SubscriptionConstraint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ describe('useConstraints', () => {
expect(topicConstraints.value?.['pl.group.Topic1'].consumersNumber).toBe(
2,
);
expect(topicConstraints.value?.['pl.group.Topic1'].reason).toBe(
'Some reason',
);
expect(
subscriptionConstraints.value?.['pl.group.Topic$subscription2']
.consumersNumber,
Expand Down
1 change: 1 addition & 0 deletions hermes-console/src/dummy/constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const dummyConstraints: ConstraintsConfig = {
topicConstraints: {
'pl.group.Topic1': {
consumersNumber: 2,
reason: 'Some reason',
},
'pl.group.Topic2': {
consumersNumber: 4,
Expand Down
2 changes: 2 additions & 0 deletions hermes-console/src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ const en_US = {
topicName: 'Topic name',
subscriptionName: 'Subscription name',
consumersNumber: 'Consumers count',
reason: 'Reason',
save: 'Save',
cancel: 'Cancel',
},
editForm: {
title: 'Edit constraints for: “{resourceId}”',
consumersNumber: 'Consumers count',
reason: 'Reason',
save: 'Save',
remove: 'Remove',
cancel: 'Cancel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}>();
const consumersNumber: Ref<number> = ref(1);
const reason: Ref<string> = ref('');
const topicName: Ref<string> = ref('');
const subscriptionName: Ref<string> = ref('');
Expand All @@ -17,7 +18,10 @@
}>();
const onCreated = async () => {
const constraint: Constraint = { consumersNumber: consumersNumber.value };
const constraint: Constraint = {
consumersNumber: consumersNumber.value,
reason: reason.value,
};
let resourceId = '';
if (props.isSubscription) {
resourceId = subscriptionFqn(topicName.value, subscriptionName.value);
Expand Down Expand Up @@ -65,6 +69,15 @@
>
</v-text-field>
</v-card-item>
<v-card-item>
<v-text-field
:label="$t('constraints.createForm.reason')"
type="text"
v-model="reason"
data-testid="createConstraintReasonInput"
>
</v-text-field>
</v-card-item>
<v-card-item class="text-right">
<v-btn
color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
}>();
const consumersNumber: Ref<number> = ref(props.constraint.consumersNumber);
const reason: Ref<number> = ref(props.constraint.reason);
const onUpdated = () => {
const constraint: Constraint = { consumersNumber: consumersNumber.value };
const constraint: Constraint = {
consumersNumber: consumersNumber.value,
reason: reason.value,
};
emit('update', props.resourceId, constraint);
};
Expand All @@ -43,6 +47,15 @@
>
</v-text-field>
</v-card-item>
<v-card-item>
<v-text-field
:label="$t('constraints.editForm.reason')"
type="text"
v-model="reason"
data-testid="editConstraintReasonInput"
>
</v-text-field>
</v-card-item>
<v-card-item class="text-right">
<v-btn
color="primary"
Expand Down

0 comments on commit 43cb994

Please sign in to comment.