-
Notifications
You must be signed in to change notification settings - Fork 14
feat(entities-plugins): add metering-and-billing-plugin form #3058
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
Draft
TT1228
wants to merge
6
commits into
main
Choose a base branch
from
feat/metering-and-billing-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eae091c
feat(entities-plugins): add metering0and-plugin form
TT1228 d9fa34f
chore: import correction
TT1228 3f771e2
chore: add ArrayField transition mode
TT1228 d03dc71
Merge remote-tracking branch 'origin/main' into feat/metering-and-bil…
TT1228 659a2c6
chore: stylelint fix
TT1228 4042882
chore: css fix and refactor
TT1228 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
343 changes: 343 additions & 0 deletions
343
...s/entities-plugins/src/components/free-form/MeteringAndBilling/MeteringAndBillingForm.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,343 @@ | ||
| <template> | ||
| <StandardLayout | ||
| v-bind="props" | ||
| :plugin-config-description="t('plugins.free-form.metering-and-billing.sections.plugin_config.description')" | ||
| > | ||
| <template #field-renderers> | ||
| <!-- BooleanField label + description overrides --> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.meter_api_requests'" | ||
| > | ||
| <BooleanField | ||
| v-bind="slotProps" | ||
| :description="t('plugins.free-form.metering-and-billing.fields.meter_api_requests.description')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.meter_ai_token_usage'" | ||
| > | ||
| <BooleanField | ||
| v-bind="slotProps" | ||
| :description="t('plugins.free-form.metering-and-billing.fields.meter_ai_token_usage.description')" | ||
| /> | ||
| </FieldRenderer> | ||
| <!-- StringField description overrides --> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.ssl_verify'" | ||
| > | ||
| <BooleanField | ||
| v-bind="slotProps" | ||
| :description="t('plugins.free-form.metering-and-billing.fields.ssl_verify.description')" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.ssl_verify.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.subject.look_up_value_in'" | ||
| > | ||
| <EnumField | ||
| v-bind="slotProps" | ||
| :help="t('plugins.free-form.metering-and-billing.fields.look_up_value_in.help')" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.look_up_value_in.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.subject.field'" | ||
| > | ||
| <StringField | ||
| v-bind="slotProps" | ||
| :help="t('plugins.free-form.metering-and-billing.fields.subject_field.help')" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.subject_field.label')" | ||
| :placeholder="t('plugins.free-form.metering-and-billing.fields.subject_field.placeholder')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.timeout'" | ||
| > | ||
| <NumberField | ||
| v-bind="slotProps" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.timeout.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.keepalive'" | ||
| > | ||
| <NumberField | ||
| v-bind="slotProps" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.keepalive.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.queue.max_coalescing_delay'" | ||
| > | ||
| <NumberField | ||
| v-bind="slotProps" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.queue.max_coalescing_delay.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.queue.initial_retry_delay'" | ||
| > | ||
| <NumberField | ||
| v-bind="slotProps" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.queue.initial_retry_delay.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.queue.max_retry_delay'" | ||
| > | ||
| <NumberField | ||
| v-bind="slotProps" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.queue.max_retry_delay.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.queue.max_retry_time'" | ||
| > | ||
| <NumberField | ||
| v-bind="slotProps" | ||
| :label="t('plugins.free-form.metering-and-billing.fields.queue.max_retry_time.label')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.attributes'" | ||
| > | ||
| <ArrayField | ||
| v-bind="slotProps" | ||
| collapsible | ||
| :label="t('plugins.free-form.metering-and-billing.fields.attributes.title')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.attributes.*.look_up_value_in'" | ||
| > | ||
| <StringField | ||
| v-bind="slotProps" | ||
| :placeholder="t('plugins.free-form.metering-and-billing.fields.attributes.look_up_value_in.placeholder')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path === 'config.attributes.*.event_property_name'" | ||
| > | ||
| <StringField | ||
| v-bind="slotProps" | ||
| :placeholder="t('plugins.free-form.metering-and-billing.fields.attributes.event_property_name.placeholder')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path.startsWith('config.attributes.') && path.endsWith('.look_up_value_in')" | ||
| > | ||
| <StringField | ||
| v-bind="slotProps" | ||
| :placeholder="t('plugins.free-form.metering-and-billing.fields.attributes.look_up_value_in.placeholder')" | ||
| /> | ||
| </FieldRenderer> | ||
| <FieldRenderer | ||
| v-slot="slotProps" | ||
| :match="({ path }) => path.startsWith('config.attributes.') && path.endsWith('.event_property_name')" | ||
| > | ||
| <StringField | ||
| v-bind="slotProps" | ||
| :placeholder="t('plugins.free-form.metering-and-billing.fields.attributes.event_property_name.placeholder')" | ||
| /> | ||
| </FieldRenderer> | ||
| </template> | ||
|
|
||
| <CollapsibleSection | ||
| v-model:expanded="meteringExpanded" | ||
| :label="t('plugins.free-form.metering-and-billing.sections.metering.title')" | ||
| > | ||
| <Field name="config.meter_api_requests" /> | ||
| <Field name="config.meter_ai_token_usage" /> | ||
| </CollapsibleSection> | ||
|
|
||
| <!-- Subject — ObjectField native collapse, 2-column content --> | ||
| <div class="ff-mb-subject"> | ||
| <ObjectField | ||
| :label="t('plugins.free-form.metering-and-billing.sections.subject.title')" | ||
| name="config.subject" | ||
| reset-label-path="reset" | ||
| /> | ||
| </div> | ||
|
|
||
| <!-- Attributes --> | ||
| <Field name="config.attributes" /> | ||
|
|
||
| <CollapsibleSection | ||
| v-model:expanded="ingestionExpanded" | ||
| :label="t('plugins.free-form.metering-and-billing.sections.ingestion.title')" | ||
| > | ||
| <StringField | ||
| :help="t('plugins.free-form.metering-and-billing.fields.ingest_endpoint.help')" | ||
| name="config.ingest_endpoint" | ||
| /> | ||
| <Field name="config.api_token" /> | ||
| <Field name="config.ssl_verify" /> | ||
| <div class="ff-metering-billing-inline-row"> | ||
| <Field name="config.timeout" /> | ||
| <Field name="config.keepalive" /> | ||
| </div> | ||
| </CollapsibleSection> | ||
|
|
||
| <!-- Queue — in AdvancedFields, header-less, 2-column --> | ||
| <AdvancedFields | ||
| class="ff-advanced-fields-container" | ||
| data-testid="ff-advanced-fields-container" | ||
| hide-general-fields | ||
| > | ||
| <div class="ff-mb-queue"> | ||
| <KLabel class="ff-mb-queue-label"> | ||
| {{ t('plugins.free-form.metering-and-billing.sections.queue.title') }} | ||
| </KLabel> | ||
| <ObjectField | ||
| as-child | ||
| name="config.queue" | ||
| reset-label-path="reset" | ||
| /> | ||
| </div> | ||
| </AdvancedFields> | ||
| </StandardLayout> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { AUTOFILL_SLOT, AUTOFILL_SLOT_NAME } from '@kong-ui-public/forms' | ||
| import { provide, ref } from 'vue' | ||
| import { KLabel } from '@kong/kongponents' | ||
| import StandardLayout from '../shared/layout/StandardLayout.vue' | ||
| import FieldRenderer from '../shared/FieldRenderer.vue' | ||
| import Field from '../shared/Field.vue' | ||
| import AdvancedFields from '../shared/AdvancedFields.vue' | ||
| import ObjectField from '../shared/ObjectField.vue' | ||
| import CollapsibleSection from '../shared/CollapsibleSection.vue' | ||
| import BooleanField from '../shared/BooleanField.vue' | ||
| import NumberField from '../shared/NumberField.vue' | ||
| import EnumField from '../shared/EnumField.vue' | ||
| import ArrayField from '../shared/ArrayField.vue' | ||
| import StringField from '../shared/StringField.vue' | ||
| import useI18n from '../../../composables/useI18n' | ||
|
|
||
| import type { Props } from '../shared/layout/StandardLayout.vue' | ||
|
|
||
| const props = defineProps<Props>() | ||
|
|
||
| const slots = defineSlots<{ | ||
| [K in typeof AUTOFILL_SLOT_NAME]: () => any | ||
| }>() | ||
|
|
||
| provide(AUTOFILL_SLOT, slots?.[AUTOFILL_SLOT_NAME]) | ||
|
|
||
| const { i18n: { t } } = useI18n() | ||
|
|
||
| const meteringExpanded = ref(true) | ||
| const ingestionExpanded = ref(true) | ||
|
|
||
|
|
||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .ff-mb-subject :deep(.ff-object-field-content) { | ||
| display: flex; | ||
| flex-direction: row; | ||
| flex-wrap: wrap; | ||
| gap: var(--kui-space-60, $kui-space-60); | ||
|
|
||
| > * { | ||
| flex: 1 1 calc(50% - var(--kui-space-60, $kui-space-60)); | ||
| min-width: 0; | ||
| } | ||
| } | ||
|
|
||
| :deep([data-testid="ff-array-config.attributes"] .ff-object-field-as-child) { | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: var(--kui-space-60, $kui-space-60); | ||
|
|
||
| > * { | ||
| flex: 1 1 0; | ||
| min-width: 0; | ||
| } | ||
| } | ||
|
|
||
| :deep([data-testid="ff-array-config.attributes"] [data-testid^="ff-array-item-config.attributes"] .ff-array-field-item-content) { | ||
| width: 100%; | ||
| } | ||
|
|
||
| :deep([data-testid="ff-array-config.attributes"] [data-testid^="ff-array-item-config.attributes"] .card-content) { | ||
| align-items: flex-start; | ||
| } | ||
|
|
||
| :deep([data-testid="ff-array-config.attributes"] [data-testid^="ff-array-item-config.attributes"] .ff-object-field-as-child) { | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: var(--kui-space-60, $kui-space-60); | ||
|
|
||
| > * { | ||
| flex: 1 1 0; | ||
| min-width: 0; | ||
| } | ||
| } | ||
|
|
||
| :deep([data-testid="ff-array-config.attributes"] .ff-array-field-item-remove-tooltip) { | ||
| align-self: flex-end; | ||
| margin-bottom: var(--kui-space-20, $kui-space-20); | ||
| } | ||
|
|
||
| .ff-metering-billing-inline-row { | ||
| display: flex; | ||
| gap: var(--kui-space-60, $kui-space-60); | ||
|
|
||
| > * { | ||
| flex: 1 1 0; | ||
| } | ||
| } | ||
|
|
||
| .ff-mb-queue { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--kui-space-40, $kui-space-40); | ||
|
|
||
| &-label { | ||
| font-weight: var(--kui-font-weight-bold, $kui-font-weight-bold); | ||
| } | ||
|
|
||
| :deep(.ff-object-field-as-child) { | ||
| display: flex; | ||
| flex-direction: row; | ||
| flex-wrap: wrap; | ||
| gap: var(--kui-space-60, $kui-space-60); | ||
|
|
||
| > * { | ||
| flex: 1 1 calc(50% - var(--kui-space-60, $kui-space-60)); | ||
| min-width: 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .ff-advanced-fields-container { | ||
| border-top: 1px solid var(--kui-color-border, $kui-color-border); | ||
| padding-top: var(--kui-space-70, $kui-space-70); | ||
|
|
||
| :deep(.collapse-heading) { | ||
| margin: 0; | ||
| } | ||
|
|
||
| // Hide the advanced fields container if there are no advanced fields to show | ||
| &:has(> .collapse-hidden-content > .ff-advanced-fields > .ff-object-field:empty:only-child) { | ||
| display: none; | ||
| } | ||
| } | ||
| </style> | ||
1 change: 1 addition & 0 deletions
1
packages/entities/entities-plugins/src/components/free-form/MeteringAndBilling/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './MeteringAndBillingForm.vue' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.