diff --git a/pages/attribute-editor/condensed.page.tsx b/pages/attribute-editor/condensed.page.tsx new file mode 100644 index 0000000000..ee6da36be4 --- /dev/null +++ b/pages/attribute-editor/condensed.page.tsx @@ -0,0 +1,217 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import React, { useState } from 'react'; + +import AppLayoutToolbar from '~components/app-layout-toolbar'; +import AttributeEditor from '~components/attribute-editor'; +import Box from '~components/box'; +import BreadcrumbGroup from '~components/breadcrumb-group'; +import Button from '~components/button/internal'; +import Container from '~components/container'; +import Header from '~components/header'; +import Select from '~components/select'; +import SideNavigation from '~components/side-navigation'; +import SpaceBetween from '~components/space-between'; +interface LabelFilter { + label: string; + operator: string; + value: string; +} +const LABEL_OPTIONS = [ + { + value: 'alertname', + }, + { + value: 'alertstate', + }, + { + value: 'job', + }, + { + value: 'namespace', + }, + { + value: 'severity', + }, + { + value: 'instance', + }, +]; +const OPERATOR_OPTIONS = [ + { + label: '=', + value: '=', + }, + { + label: '!=', + value: '!=', + }, + { + label: '=~', + value: '=~', + }, + { + label: '!~', + value: '!~', + }, +]; +const VALUE_OPTIONS = [ + { + value: 'pending', + }, + { + value: 'firing', + }, + { + value: 'resolved', + }, + { + value: 'inactive', + }, +]; +function LabelFilters() { + const [filters, setFilters] = useState([ + { + label: 'alertstate', + operator: '=', + value: 'pending', + }, + ]); + const handleAddFilter = () => { + setFilters([ + ...filters, + { + label: '', + operator: '=', + value: '', + }, + ]); + }; + const handleRemoveFilter = (itemIndex: number) => { + const newFilters = filters.filter((_, index) => index !== itemIndex); + setFilters(newFilters); + }; + const updateFilter = (index: number, field: keyof LabelFilter, value: string) => { + const newFilters = [...filters]; + newFilters[index] = { + ...newFilters[index], + [field]: value, + }; + setFilters(newFilters); + }; + const attributeEditorDefinition = [ + { + // label: 'Label', + control: (item: LabelFilter, itemIndex: number) => ( + opt.value === item.operator) || OPERATOR_OPTIONS[0]} + onChange={({ detail }) => updateFilter(itemIndex, 'operator', detail.selectedOption.value || '=')} + /> + ), + }, + { + control: (item: LabelFilter, itemIndex: number) => ( +