@oneuptime/common 12.0.9 → 12.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/NetworkDevice.ts +44 -0
- package/Models/DatabaseModels/NetworkDeviceLink.ts +116 -0
- package/Models/DatabaseModels/RunnerJob.ts +17 -2
- package/Server/API/LlmProviderAPI.ts +8 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787400000000-AddDeviceRoleAndDeclaredLinkParent.ts +52 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/NetworkDeviceLabelRuleEngineService.ts +240 -0
- package/Server/Services/NetworkDeviceLinkService.ts +338 -2
- package/Server/Services/NetworkDeviceService.ts +265 -12
- package/Server/Services/RunnerJobService.ts +24 -1
- package/Server/Types/Billing/MeteredPlan/AllMeteredPlans.ts +19 -5
- package/Server/Types/Database/JSONColumnQuery.ts +42 -4
- package/Server/Utils/LLM/LLMService.ts +108 -19
- package/Server/Utils/Monitor/MonitorAlert.ts +22 -115
- package/Server/Utils/Monitor/MonitorIncident.ts +7 -337
- package/Server/Utils/Monitor/MonitorMaintenanceSuppression.ts +27 -2
- package/Server/Utils/Monitor/SeriesResourceLabels.ts +32 -0
- package/Server/Utils/Monitor/SeriesResourceLinker.ts +469 -0
- package/Server/Utils/SSRFProtection.ts +5 -4
- package/Server/Utils/Telemetry/InventoryEntityRegistry.ts +186 -38
- package/Tests/App/AdminDashboard/AdminUsersBulkAddToProject.test.tsx +955 -0
- package/Tests/App/AdminDashboard/BulkAddUsersToProject.test.ts +778 -0
- package/Tests/App/AdminDashboard/BulkAddUsersToProjectModal.test.tsx +1051 -0
- package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +420 -112
- package/Tests/App/Dashboard/OnCallReadinessSurfaces.test.tsx +81 -6
- package/Tests/App/Dashboard/PayAsYouGoConsentGate.test.tsx +543 -0
- package/Tests/App/Dashboard/PayAsYouGoFreePlan.test.ts +125 -0
- package/Tests/App/Dashboard/PayAsYouGoNotices.test.tsx +612 -0
- package/Tests/App/Dashboard/SloWidgetChartRendering.test.tsx +536 -0
- package/Tests/App/Dashboard/UserElementEmail.test.tsx +447 -0
- package/Tests/App/Dashboard/UserEmailCallSites.test.tsx +284 -0
- package/Tests/Models/AnalyticsModels/CommonModel.test.ts +312 -0
- package/Tests/Server/Infrastructure/Postgres/DeviceRoleAndDeclaredLinkParentMigration.test.ts +250 -0
- package/Tests/Server/Infrastructure/Postgres/EpisodeMemberNotifyIndexesMigration.test.ts +46 -18
- package/Tests/Server/Services/NetworkDeviceLabelRuleRun.test.ts +618 -0
- package/Tests/Server/Services/NetworkDeviceLinkParentValidation.test.ts +1043 -0
- package/Tests/Server/Services/NetworkSiteAssignmentRuleRun.test.ts +706 -0
- package/Tests/Server/Services/RunnerJobEnqueue.test.ts +412 -0
- package/Tests/Server/Types/Billing/PayAsYouGoMeteredPricing.test.ts +125 -0
- package/Tests/Server/Types/Database/JSONColumnQuery.test.ts +508 -0
- package/Tests/Server/Utils/AI/LLMServiceRequestPolicy.test.ts +2 -2
- package/Tests/Server/Utils/AI/LLMServiceRetryPolicy.test.ts +450 -0
- package/Tests/Server/Utils/Monitor/MonitorAlertResourceLinking.test.ts +556 -0
- package/Tests/Server/Utils/Monitor/MonitorIncidentResourceLinking.test.ts +547 -0
- package/Tests/Server/Utils/Monitor/MonitorMaintenanceSuppression.test.ts +30 -0
- package/Tests/Server/Utils/Monitor/SeriesResourceLinker.test.ts +699 -0
- package/Tests/Server/Utils/SeriesResourceLabels.test.ts +55 -0
- package/Tests/Server/Utils/Telemetry/InventoryEntityRegistry.test.ts +668 -0
- package/Tests/Types/API/URLMalformedTolerance.test.ts +301 -0
- package/Tests/Types/API/URLTelScheme.test.ts +261 -0
- package/Tests/Types/API/URLUnsupportedScheme.test.ts +148 -0
- package/Tests/Types/Billing/PayAsYouGoPricing.test.ts +64 -0
- package/Tests/Types/CustomField/CustomFieldTypeCorrespondence.test.ts +107 -0
- package/Tests/Types/Monitor/MonitorType.test.ts +62 -0
- package/Tests/Types/NetworkAutomation/RuleRunResult.test.ts +184 -0
- package/Tests/Types/Runbook/RunbookStepType.test.ts +124 -0
- package/Tests/Types/Workflow/BaseModelComponents.test.ts +17 -0
- package/Tests/UI/Components/Button.test.tsx +279 -0
- package/Tests/UI/Components/Charts/ChartXAxisDataKey.test.tsx +256 -0
- package/Tests/UI/Components/Charts/DataPointUtil.test.ts +323 -0
- package/Tests/UI/Components/DictionaryValuePlaceholderAndSuggestions.test.tsx +595 -0
- package/Tests/UI/Components/Icon.test.tsx +57 -0
- package/Tests/UI/Components/List.test.tsx +20 -3
- package/Tests/UI/Components/LogsSavedViewsDropdown.test.tsx +304 -0
- package/Tests/UI/Components/LogsViewerClearSavedView.test.tsx +179 -0
- package/Tests/UI/Components/ModelTable/CustomFieldColumns.test.tsx +349 -1
- package/Tests/UI/Components/Pagination.test.tsx +721 -146
- package/Tests/UI/Components/PaginationIntegration.test.tsx +386 -0
- package/Tests/UI/Components/PaginationUtil.test.ts +417 -0
- package/Tests/UI/Components/TelemetrySavedViewsDropdown.test.tsx +343 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnControl.test.ts +289 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnOperators.test.ts +271 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnRow.test.ts +119 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.test.ts +968 -0
- package/Tests/UI/Components/Workflow/ModelColumnEditor.render.test.tsx +766 -0
- package/Tests/UI/Utils/RunNetworkRule.test.ts +320 -0
- package/Tests/Utils/APIRetryPolicy.test.ts +823 -0
- package/Tests/Utils/Monitor/NetworkDeviceRoleUtil.test.ts +502 -0
- package/Tests/Utils/Monitor/NetworkTopologyDeclaredHierarchy.test.ts +759 -0
- package/Tests/Utils/NetworkAutomation/RuleRunSummary.test.ts +286 -0
- package/Tests/Utils/Schema/BaseSchema.test.ts +651 -0
- package/Types/API/Protocol.ts +9 -0
- package/Types/API/URL.ts +286 -20
- package/Types/Billing/PayAsYouGoPricing.ts +47 -0
- package/Types/CustomField/CustomFieldType.ts +28 -0
- package/Types/Monitor/MonitorType.ts +11 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +13 -0
- package/Types/NetworkAutomation/RuleRunResult.ts +121 -0
- package/Types/Runbook/RunbookStepType.ts +23 -0
- package/UI/Components/AutocompleteTextInput/AutocompleteTextInput.tsx +7 -0
- package/UI/Components/Button/Button.tsx +14 -22
- package/UI/Components/Charts/Area/AreaChart.tsx +4 -2
- package/UI/Components/Charts/Bar/BarChart.tsx +4 -2
- package/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.ts +13 -0
- package/UI/Components/Charts/Line/LineChart.tsx +4 -2
- package/UI/Components/Charts/Types/XAxis/XAxis.ts +6 -0
- package/UI/Components/Charts/Utils/DataPoint.ts +15 -12
- package/UI/Components/Dictionary/Dictionary.tsx +4 -39
- package/UI/Components/Icon/Icon.tsx +1 -1
- package/UI/Components/LogsViewer/LogsViewer.tsx +5 -1
- package/UI/Components/LogsViewer/components/LogsFacetSidebar.tsx +8 -0
- package/UI/Components/LogsViewer/components/LogsPagination.tsx +29 -91
- package/UI/Components/LogsViewer/components/LogsViewerToolbar.tsx +2 -0
- package/UI/Components/LogsViewer/components/SavedViewsDropdown.tsx +66 -1
- package/UI/Components/ModelTable/CustomFieldColumns.tsx +55 -0
- package/UI/Components/Pagination/Pagination.tsx +373 -328
- package/UI/Components/Pagination/PaginationUtil.ts +263 -0
- package/UI/Components/Pagination/Screenshots/README.md +15 -0
- package/UI/Components/Pagination/Screenshots/pagination-before-after.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-go-to-page-modal.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-long-list.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-mobile.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-telemetry.png +0 -0
- package/UI/Components/TelemetryViewer/components/SavedViewsDropdown.tsx +66 -1
- package/UI/Components/TelemetryViewer/components/TelemetryPagination.tsx +38 -92
- package/UI/Components/TextArea/TextArea.tsx +3 -0
- package/UI/Components/Workflow/ArgumentsForm.tsx +18 -1
- package/UI/Components/Workflow/ColumnEditor/AddColumnDropdown.tsx +177 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnConditionRow.tsx +243 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnControl.ts +255 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnFieldRow.tsx +178 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnOperators.ts +206 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnRow.ts +157 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.ts +517 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnValueInput.tsx +482 -0
- package/UI/Components/Workflow/ColumnEditor/ModelQueryBuilder.tsx +131 -0
- package/UI/Components/Workflow/ColumnEditor/ModelRecordForm.tsx +163 -0
- package/UI/Components/Workflow/ModelColumnEditor.tsx +284 -100
- package/UI/Utils/NetworkAutomation/RunNetworkRule.ts +122 -0
- package/Utils/API.ts +243 -36
- package/Utils/Monitor/NetworkDeviceRoleUtil.ts +45 -0
- package/Utils/Monitor/NetworkTopologyUtil.ts +42 -2
- package/Utils/NetworkAutomation/RuleRunSummary.ts +147 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js +45 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDeviceLink.js +115 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceLink.js.map +1 -1
- package/build/dist/Models/DatabaseModels/RunnerJob.js +17 -2
- package/build/dist/Models/DatabaseModels/RunnerJob.js.map +1 -1
- package/build/dist/Server/API/LlmProviderAPI.js +9 -1
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787400000000-AddDeviceRoleAndDeclaredLinkParent.js +33 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787400000000-AddDeviceRoleAndDeclaredLinkParent.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js +202 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceLinkService.js +253 -1
- package/build/dist/Server/Services/NetworkDeviceLinkService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceService.js +223 -12
- package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -1
- package/build/dist/Server/Services/RunnerJobService.js +20 -2
- package/build/dist/Server/Services/RunnerJobService.js.map +1 -1
- package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js +12 -5
- package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js.map +1 -1
- package/build/dist/Server/Types/Database/JSONColumnQuery.js +40 -4
- package/build/dist/Server/Types/Database/JSONColumnQuery.js.map +1 -1
- package/build/dist/Server/Utils/LLM/LLMService.js +78 -22
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +22 -98
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +7 -254
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorMaintenanceSuppression.js +14 -2
- package/build/dist/Server/Utils/Monitor/MonitorMaintenanceSuppression.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js +27 -0
- package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js +285 -0
- package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js.map +1 -0
- package/build/dist/Server/Utils/SSRFProtection.js +5 -4
- package/build/dist/Server/Utils/SSRFProtection.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/InventoryEntityRegistry.js +128 -35
- package/build/dist/Server/Utils/Telemetry/InventoryEntityRegistry.js.map +1 -1
- package/build/dist/Types/API/Protocol.js +9 -0
- package/build/dist/Types/API/Protocol.js.map +1 -1
- package/build/dist/Types/API/URL.js +241 -18
- package/build/dist/Types/API/URL.js.map +1 -1
- package/build/dist/Types/Billing/PayAsYouGoPricing.js +41 -0
- package/build/dist/Types/Billing/PayAsYouGoPricing.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldType.js +26 -0
- package/build/dist/Types/CustomField/CustomFieldType.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorType.js +10 -0
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/NetworkAutomation/RuleRunResult.js +39 -0
- package/build/dist/Types/NetworkAutomation/RuleRunResult.js.map +1 -0
- package/build/dist/Types/Runbook/RunbookStepType.js +21 -0
- package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
- package/build/dist/UI/Components/AutocompleteTextInput/AutocompleteTextInput.js +1 -1
- package/build/dist/UI/Components/AutocompleteTextInput/AutocompleteTextInput.js.map +1 -1
- package/build/dist/UI/Components/Button/Button.js +10 -16
- package/build/dist/UI/Components/Button/Button.js.map +1 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js +2 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js +2 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js +12 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js.map +1 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js +2 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js +17 -10
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -1
- package/build/dist/UI/Components/Dictionary/Dictionary.js +4 -18
- package/build/dist/UI/Components/Dictionary/Dictionary.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +1 -1
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +3 -3
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js +5 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsPagination.js +14 -44
- package/build/dist/UI/Components/LogsViewer/components/LogsPagination.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsViewerToolbar.js +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsViewerToolbar.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/SavedViewsDropdown.js +20 -2
- package/build/dist/UI/Components/LogsViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js +42 -0
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js.map +1 -1
- package/build/dist/UI/Components/Pagination/Pagination.js +174 -199
- package/build/dist/UI/Components/Pagination/Pagination.js.map +1 -1
- package/build/dist/UI/Components/Pagination/PaginationUtil.js +160 -0
- package/build/dist/UI/Components/Pagination/PaginationUtil.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js +20 -2
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryPagination.js +23 -47
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryPagination.js.map +1 -1
- package/build/dist/UI/Components/TextArea/TextArea.js +1 -1
- package/build/dist/UI/Components/TextArea/TextArea.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ArgumentsForm.js +14 -2
- package/build/dist/UI/Components/Workflow/ArgumentsForm.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ColumnEditor/AddColumnDropdown.js +86 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/AddColumnDropdown.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnConditionRow.js +119 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnConditionRow.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnControl.js +206 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnControl.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnFieldRow.js +57 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnFieldRow.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnOperators.js +150 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnOperators.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRow.js +67 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRow.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.js +309 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnValueInput.js +204 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnValueInput.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelQueryBuilder.js +66 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelQueryBuilder.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelRecordForm.js +83 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelRecordForm.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ModelColumnEditor.js +187 -68
- package/build/dist/UI/Components/Workflow/ModelColumnEditor.js.map +1 -1
- package/build/dist/UI/Utils/NetworkAutomation/RunNetworkRule.js +75 -0
- package/build/dist/UI/Utils/NetworkAutomation/RunNetworkRule.js.map +1 -0
- package/build/dist/Utils/API.js +175 -34
- package/build/dist/Utils/API.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkDeviceRoleUtil.js +37 -0
- package/build/dist/Utils/Monitor/NetworkDeviceRoleUtil.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +25 -3
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
- package/build/dist/Utils/NetworkAutomation/RuleRunSummary.js +78 -0
- package/build/dist/Utils/NetworkAutomation/RuleRunSummary.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The "add a field" picker.
|
|
3
|
+
*
|
|
4
|
+
* This is the part that answers the complaint directly: the columns are already
|
|
5
|
+
* known, so they are offered by name and description rather than typed from
|
|
6
|
+
* memory into a box labelled "Key". Required columns are grouped first, because
|
|
7
|
+
* on a create those are the ones that decide whether the step works at all.
|
|
8
|
+
*/
|
|
9
|
+
import IconProp from "../../../../Types/Icon/IconProp";
|
|
10
|
+
import Button, { ButtonSize, ButtonStyleType } from "../../Button/Button";
|
|
11
|
+
import Dropdown from "../../Dropdown/Dropdown";
|
|
12
|
+
import Icon from "../../Icon/Icon";
|
|
13
|
+
import Input from "../../Input/Input";
|
|
14
|
+
import { columnTypeLabel } from "./ColumnControl";
|
|
15
|
+
import React, { useState } from "react";
|
|
16
|
+
const toOption = (column) => {
|
|
17
|
+
return {
|
|
18
|
+
value: column.id,
|
|
19
|
+
label: `${column.title} · ${column.id}`,
|
|
20
|
+
/*
|
|
21
|
+
* The model's own description, shown as the option's second line. It is the
|
|
22
|
+
* sentence that was previously nowhere on this screen, and it is the whole
|
|
23
|
+
* reason the picker beats a text box.
|
|
24
|
+
*/
|
|
25
|
+
description: column.description || columnTypeLabel(column),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const AddColumnDropdown = (props) => {
|
|
29
|
+
const [customColumnId, setCustomColumnId] = useState("");
|
|
30
|
+
const [isNamingCustomColumn, setIsNamingCustomColumn] = useState(false);
|
|
31
|
+
/*
|
|
32
|
+
* Bumped after every pick to remount the dropdown. It keeps its selection in
|
|
33
|
+
* state of its own and only re-reads props.value when that prop changes, so
|
|
34
|
+
* without this the picker would go on displaying the field it just added -
|
|
35
|
+
* as though it were a filter rather than an action.
|
|
36
|
+
*/
|
|
37
|
+
const [pickerNonce, setPickerNonce] = useState(0);
|
|
38
|
+
const addCustomColumn = () => {
|
|
39
|
+
const columnId = customColumnId.trim();
|
|
40
|
+
if (columnId === "") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
props.onAdd(columnId);
|
|
44
|
+
setCustomColumnId("");
|
|
45
|
+
setIsNamingCustomColumn(false);
|
|
46
|
+
};
|
|
47
|
+
const hasOptions = props.columns.length > 0;
|
|
48
|
+
if (isNamingCustomColumn || !hasOptions) {
|
|
49
|
+
return (React.createElement("div", { className: "flex items-start gap-2" },
|
|
50
|
+
React.createElement("div", { className: "w-64" },
|
|
51
|
+
React.createElement(Input, { value: customColumnId, placeholder: "Column name", outerDivClassName: "relative w-full", dataTestId: `${props.dataTestId || "model-column-add"}-custom`, onChange: setCustomColumnId, onEnterPress: addCustomColumn })),
|
|
52
|
+
React.createElement(Button, { title: "Add", buttonSize: ButtonSize.Small, buttonStyle: ButtonStyleType.OUTLINE, onClick: addCustomColumn }),
|
|
53
|
+
hasOptions && (React.createElement(Button, { title: "Cancel", buttonSize: ButtonSize.Small, buttonStyle: ButtonStyleType.SECONDARY_LINK, onClick: () => {
|
|
54
|
+
setIsNamingCustomColumn(false);
|
|
55
|
+
setCustomColumnId("");
|
|
56
|
+
} }))));
|
|
57
|
+
}
|
|
58
|
+
const requiredColumns = props.columns.filter((column) => {
|
|
59
|
+
return props.requiredColumnIds.includes(column.id);
|
|
60
|
+
});
|
|
61
|
+
const otherColumns = props.columns.filter((column) => {
|
|
62
|
+
return !props.requiredColumnIds.includes(column.id);
|
|
63
|
+
});
|
|
64
|
+
const options = requiredColumns.length > 0
|
|
65
|
+
? [
|
|
66
|
+
{ label: "Required", options: requiredColumns.map(toOption) },
|
|
67
|
+
{ label: "All fields", options: otherColumns.map(toOption) },
|
|
68
|
+
]
|
|
69
|
+
: props.columns.map(toOption);
|
|
70
|
+
return (React.createElement("div", { className: "flex items-center gap-3" },
|
|
71
|
+
React.createElement("div", { className: "w-72" },
|
|
72
|
+
React.createElement(Dropdown, { key: pickerNonce, options: options, placeholder: props.placeholder, className: "relative w-full overflow-visible rounded-md", isMultiSelect: false, dataTestId: props.dataTestId || "model-column-add", ariaLabel: props.placeholder, onChange: (value) => {
|
|
73
|
+
if (value === null || Array.isArray(value)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setPickerNonce(pickerNonce + 1);
|
|
77
|
+
props.onAdd(String(value));
|
|
78
|
+
} })),
|
|
79
|
+
props.allowCustomColumn && (React.createElement("button", { type: "button", className: "inline-flex items-center gap-1 text-xs text-gray-500 hover:text-gray-700", onClick: () => {
|
|
80
|
+
setIsNamingCustomColumn(true);
|
|
81
|
+
} },
|
|
82
|
+
React.createElement(Icon, { icon: IconProp.Add, className: "h-3 w-3" }),
|
|
83
|
+
"Add a column by name"))));
|
|
84
|
+
};
|
|
85
|
+
export default AddColumnDropdown;
|
|
86
|
+
//# sourceMappingURL=AddColumnDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddColumnDropdown.js","sourceRoot":"","sources":["../../../../../../UI/Components/Workflow/ColumnEditor/AddColumnDropdown.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,QAAQ,MAAM,iCAAiC,CAAC;A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ACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* One condition of a query: column, comparison, value.
|
|
3
|
+
*
|
|
4
|
+
* A condition genuinely picks its subject, so this row keeps a column picker -
|
|
5
|
+
* but a picker of real columns, not a text box. The comparison list is filtered
|
|
6
|
+
* by the column's type, so a Boolean column no longer offers "starts with" and
|
|
7
|
+
* an ID column no longer offers "greater than".
|
|
8
|
+
*/
|
|
9
|
+
import IconProp from "../../../../Types/Icon/IconProp";
|
|
10
|
+
import Button, { ButtonStyleType } from "../../Button/Button";
|
|
11
|
+
import { getOperatorOption, } from "../../Dictionary/DictionaryFilterOperator";
|
|
12
|
+
import Dropdown from "../../Dropdown/Dropdown";
|
|
13
|
+
import AutocompleteTextInput from "../../AutocompleteTextInput/AutocompleteTextInput";
|
|
14
|
+
import { columnTypeLabel, controlForColumn } from "./ColumnControl";
|
|
15
|
+
import { operatorLabelFor, operatorsForControl } from "./ColumnOperators";
|
|
16
|
+
import { ColumnValueMode, changeColumnRow, } from "./ColumnRow";
|
|
17
|
+
import { rowIssue } from "./ColumnRowSerialization";
|
|
18
|
+
import ColumnValueInput from "./ColumnValueInput";
|
|
19
|
+
import React from "react";
|
|
20
|
+
const ColumnConditionRow = (props) => {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const control = controlForColumn(props.column);
|
|
23
|
+
const operatorOption = getOperatorOption(props.row.operator);
|
|
24
|
+
const issue = rowIssue(props.row, props.column);
|
|
25
|
+
const isUnknownColumn = !props.column && props.row.columnId !== "";
|
|
26
|
+
/*
|
|
27
|
+
* The title alone is the label, with the column name carried in the option's
|
|
28
|
+
* second line and repeated as a chip under the picker once it is chosen.
|
|
29
|
+
* Putting both in the label - "Created At · createdAt" - is what a select
|
|
30
|
+
* ellipsizes first, and the name is exactly the half that gets cut.
|
|
31
|
+
*/
|
|
32
|
+
const columnOptions = props.columns.map((column) => {
|
|
33
|
+
return {
|
|
34
|
+
value: column.id,
|
|
35
|
+
label: column.title,
|
|
36
|
+
description: `${column.id} · ${column.description || columnTypeLabel(column)}`,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
/*
|
|
40
|
+
* Whatever this condition already filters on is always in the list, even when
|
|
41
|
+
* the picker would not offer it: a name the endpoint does not describe at all,
|
|
42
|
+
* and equally a column it describes but does not offer - a relation, the
|
|
43
|
+
* project column, a JSON blob. Keyed on "is it in the options" rather than on
|
|
44
|
+
* "is it unknown", because the second misses the whole middle case and leaves
|
|
45
|
+
* the row showing an empty picker over a condition that is really there.
|
|
46
|
+
*/
|
|
47
|
+
if (props.row.columnId !== "" &&
|
|
48
|
+
!columnOptions.some((option) => {
|
|
49
|
+
return option.value === props.row.columnId;
|
|
50
|
+
})) {
|
|
51
|
+
columnOptions.unshift({
|
|
52
|
+
value: props.row.columnId,
|
|
53
|
+
label: ((_a = props.column) === null || _a === void 0 ? void 0 : _a.title) || props.row.columnId,
|
|
54
|
+
description: isUnknownColumn
|
|
55
|
+
? "Not a column on this model"
|
|
56
|
+
: `${props.row.columnId} · can't be picked from the list`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const operatorOptions = operatorsForControl(control, props.row.operator).map((operator) => {
|
|
60
|
+
return {
|
|
61
|
+
value: operator,
|
|
62
|
+
label: operatorLabelFor(operator, control),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
/*
|
|
66
|
+
* Proportional column widths rather than fixed ones. A picker showing
|
|
67
|
+
* "Created At · createdAt" and a comparison reading "is on or before" both
|
|
68
|
+
* outgrow any rem figure that also leaves room for the value, and the settings
|
|
69
|
+
* panel is a different width on every screen. ModelQueryBuilder's header row
|
|
70
|
+
* repeats this template and has to stay in step with it.
|
|
71
|
+
*/
|
|
72
|
+
const rowGridClass = "group grid grid-cols-1 items-start gap-2 px-3 py-2.5 transition-colors hover:bg-gray-50/60 sm:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)_minmax(0,1.3fr)_auto]";
|
|
73
|
+
return (React.createElement("div", { className: rowGridClass, "data-testid": "model-column-row" },
|
|
74
|
+
React.createElement("div", { className: "min-w-0" },
|
|
75
|
+
props.columns.length === 0 ? (React.createElement(AutocompleteTextInput, { value: props.row.columnId, placeholder: "Column name", outerDivClassName: "relative w-full", disableSpellCheck: true, onChange: (value) => {
|
|
76
|
+
props.onChange(changeColumnRow(props.row, { columnId: value }));
|
|
77
|
+
} })) : (React.createElement(Dropdown, { options: columnOptions, placeholder: "Column", className: "relative w-full overflow-visible rounded-md", isMultiSelect: false, ariaLabel: "Column", dataTestId: `model-column-picker-${props.row.columnId}`, value: columnOptions.find((option) => {
|
|
78
|
+
return option.value === props.row.columnId;
|
|
79
|
+
}), onChange: (value) => {
|
|
80
|
+
/*
|
|
81
|
+
* The dropdown is always clearable and hands back null. The row
|
|
82
|
+
* stays - a condition being retargeted is not a condition being
|
|
83
|
+
* deleted - and an empty column is dropped on serialization.
|
|
84
|
+
*/
|
|
85
|
+
props.onChange(changeColumnRow(props.row, {
|
|
86
|
+
columnId: value === null || Array.isArray(value) ? "" : String(value),
|
|
87
|
+
}));
|
|
88
|
+
} })),
|
|
89
|
+
isUnknownColumn ? (React.createElement("span", { className: "mt-1 inline-block rounded bg-amber-50 px-1.5 py-0.5 text-[11px] text-amber-700" }, "Not a column on this model")) : (props.column && (React.createElement("span", { className: "mt-1 inline-block truncate rounded bg-gray-100 px-1.5 py-0.5 font-mono text-[11px] text-gray-500" }, props.row.columnId)))),
|
|
90
|
+
React.createElement(Dropdown, { options: operatorOptions, className: "relative w-full overflow-visible rounded-md", isMultiSelect: false, ariaLabel: "Comparison", dataTestId: `model-column-operator-${props.row.columnId}`, value: operatorOptions.find((option) => {
|
|
91
|
+
return option.value === props.row.operator;
|
|
92
|
+
}), onChange: (value) => {
|
|
93
|
+
if (value === null || Array.isArray(value)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const nextOperator = value;
|
|
97
|
+
const nextOption = getOperatorOption(nextOperator);
|
|
98
|
+
/*
|
|
99
|
+
* The value is cleared when the shape of the input changes, so a
|
|
100
|
+
* scalar is never shipped where a list is expected, or the other way
|
|
101
|
+
* round.
|
|
102
|
+
*/
|
|
103
|
+
props.onChange(changeColumnRow(props.row, {
|
|
104
|
+
operator: nextOperator,
|
|
105
|
+
text: nextOption.hidesValueInput ? "" : props.row.text,
|
|
106
|
+
values: nextOption.expectsMultiValue ? props.row.values : [],
|
|
107
|
+
}));
|
|
108
|
+
} }),
|
|
109
|
+
React.createElement("div", { className: "min-w-0" },
|
|
110
|
+
React.createElement(ColumnValueInput, { control: control, valueMode: props.row.valueMode, text: props.row.text, values: props.row.values, operatorOption: operatorOption, placeholder: ((_b = props.column) === null || _b === void 0 ? void 0 : _b.example) || ((_c = props.column) === null || _c === void 0 ? void 0 : _c.placeholder), suggestions: props.suggestions, autoFocus: props.autoFocus, dataTestId: `model-column-value-${props.row.columnId}`, onChange: (change) => {
|
|
111
|
+
props.onChange(changeColumnRow(props.row, change));
|
|
112
|
+
} }),
|
|
113
|
+
props.row.valueMode === ColumnValueMode.Raw && (React.createElement("p", { className: "mt-1 text-[11px] text-amber-600" }, "Kept exactly as it was saved.")),
|
|
114
|
+
issue && React.createElement("p", { className: "mt-1 text-[11px] text-red-500" }, issue)),
|
|
115
|
+
React.createElement("div", { className: "flex items-center pt-1" },
|
|
116
|
+
React.createElement(Button, { buttonStyle: ButtonStyleType.ICON, icon: IconProp.Trash, title: "Remove", dataTestId: `model-column-remove-${props.row.columnId}`, className: "opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100", onClick: props.onRemove }))));
|
|
117
|
+
};
|
|
118
|
+
export default ColumnConditionRow;
|
|
119
|
+
//# sourceMappingURL=ColumnConditionRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnConditionRow.js","sourceRoot":"","sources":["../../../../../../UI/Components/Workflow/ColumnEditor/ColumnConditionRow.ts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M,0CAAE,WAAW,CAAA,EAC/D,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,UAAU,EAAE,sBAAsB,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EACtD,QAAQ,EAAE,CAAC,MAA+B,EAAE,EAAE;oBAC5C,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;gBACrD,CAAC,GACD;YAED,KAAK,CAAC,GAAG,CAAC,SAAS,KAAK,eAAe,CAAC,GAAG,IAAI,CAC9C,2BAAG,SAAS,EAAC,iCAAiC,oCAE1C,CACL;YAEA,KAAK,IAAI,2BAAG,SAAS,EAAC,+BAA+B,IAAE,KAAK,CAAK,CAC9D;QAEN,6BAAK,SAAS,EAAC,wBAAwB;YACrC,oBAAC,MAAM,IACL,WAAW,EAAE,eAAe,CAAC,IAAI,EACjC,IAAI,EAAE,QAAQ,CAAC,KAAK,EACpB,KAAK,EAAC,QAAQ,EACd,UAAU,EAAE,uBAAuB,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EACvD,SAAS,EAAC,gFAAgF,EAC1F,OAAO,EAAE,KAAK,CAAC,QAAQ,GACvB,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Which control a column gets, decided from the model's own schema.
|
|
3
|
+
*
|
|
4
|
+
* This is the answer to "you already know the schema, why are you asking me?".
|
|
5
|
+
* The editor used to show a Type dropdown next to every row — Text, Number,
|
|
6
|
+
* Boolean — even though /model-schema/:tableName had already said that `color`
|
|
7
|
+
* is a Color and `name` is a Name. Nothing good could come of that dropdown:
|
|
8
|
+
* the builder could only agree with the schema or be wrong.
|
|
9
|
+
*/
|
|
10
|
+
import TableColumnType from "../../../../Types/Database/TableColumnType";
|
|
11
|
+
import { ModelColumnControl } from "./ColumnRow";
|
|
12
|
+
/*
|
|
13
|
+
* Spelled with the enum, never with string literals. The wire carries the
|
|
14
|
+
* enum's *values* and several of them differ from the member name that reads
|
|
15
|
+
* like the obvious literal: ShortText is "Text", ObjectID is "Object ID",
|
|
16
|
+
* LongURL is "URL", PositiveNumber is "Positive Number" — and JavaScript is
|
|
17
|
+
* "JavaSCript", capital S and all. ModelSchema.ts:160 documents the same trap;
|
|
18
|
+
* a hand-written list here would classify the two most-declared column types
|
|
19
|
+
* as unsupported and quietly send every one of them to a plain text box.
|
|
20
|
+
*/
|
|
21
|
+
const TEXT_COLUMN_TYPES = [
|
|
22
|
+
TableColumnType.ShortText,
|
|
23
|
+
TableColumnType.Slug,
|
|
24
|
+
TableColumnType.Name,
|
|
25
|
+
TableColumnType.Email,
|
|
26
|
+
TableColumnType.Phone,
|
|
27
|
+
TableColumnType.Domain,
|
|
28
|
+
TableColumnType.IP,
|
|
29
|
+
TableColumnType.Version,
|
|
30
|
+
TableColumnType.LongURL,
|
|
31
|
+
TableColumnType.ShortURL,
|
|
32
|
+
TableColumnType.HashedString,
|
|
33
|
+
TableColumnType.Password,
|
|
34
|
+
TableColumnType.OTP,
|
|
35
|
+
TableColumnType.MonitorType,
|
|
36
|
+
TableColumnType.WorkflowStatus,
|
|
37
|
+
TableColumnType.CustomFieldType,
|
|
38
|
+
TableColumnType.Permission,
|
|
39
|
+
];
|
|
40
|
+
const LONG_TEXT_COLUMN_TYPES = [
|
|
41
|
+
TableColumnType.LongText,
|
|
42
|
+
TableColumnType.VeryLongText,
|
|
43
|
+
TableColumnType.Description,
|
|
44
|
+
TableColumnType.Markdown,
|
|
45
|
+
TableColumnType.HTML,
|
|
46
|
+
TableColumnType.CSS,
|
|
47
|
+
TableColumnType.JavaScript,
|
|
48
|
+
];
|
|
49
|
+
const NUMBER_COLUMN_TYPES = [
|
|
50
|
+
TableColumnType.Number,
|
|
51
|
+
TableColumnType.SmallNumber,
|
|
52
|
+
TableColumnType.BigNumber,
|
|
53
|
+
TableColumnType.PositiveNumber,
|
|
54
|
+
TableColumnType.SmallPositiveNumber,
|
|
55
|
+
TableColumnType.BigPositiveNumber,
|
|
56
|
+
TableColumnType.Port,
|
|
57
|
+
];
|
|
58
|
+
/*
|
|
59
|
+
* Everything a row cannot hold. Entity/EntityArray are relations - pointing a
|
|
60
|
+
* record at a related row means naming an existing record, which is what the
|
|
61
|
+
* scalar foreign-key column next to it (currentIncidentStateId, and every other
|
|
62
|
+
* "... ID" column) is for, and that column is offered normally.
|
|
63
|
+
*/
|
|
64
|
+
const UNSUPPORTED_COLUMN_TYPES = [
|
|
65
|
+
TableColumnType.Entity,
|
|
66
|
+
TableColumnType.EntityArray,
|
|
67
|
+
TableColumnType.JSON,
|
|
68
|
+
TableColumnType.Array,
|
|
69
|
+
TableColumnType.Buffer,
|
|
70
|
+
TableColumnType.File,
|
|
71
|
+
TableColumnType.MonitorSteps,
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* The control for a column, or Text when the schema has nothing to say.
|
|
75
|
+
*
|
|
76
|
+
* An unknown column — one the endpoint did not describe, or a key typed before
|
|
77
|
+
* the schema loaded — gets Text rather than Unsupported, because the runner
|
|
78
|
+
* accepts column names this endpoint does not surface and locking those rows
|
|
79
|
+
* would be worse than letting them be typed.
|
|
80
|
+
*/
|
|
81
|
+
export const controlForColumn = (column) => {
|
|
82
|
+
if (!column) {
|
|
83
|
+
return ModelColumnControl.Text;
|
|
84
|
+
}
|
|
85
|
+
if (column.isRelation) {
|
|
86
|
+
return ModelColumnControl.Unsupported;
|
|
87
|
+
}
|
|
88
|
+
if (UNSUPPORTED_COLUMN_TYPES.includes(column.type)) {
|
|
89
|
+
return ModelColumnControl.Unsupported;
|
|
90
|
+
}
|
|
91
|
+
if (column.type === TableColumnType.Boolean) {
|
|
92
|
+
return ModelColumnControl.Boolean;
|
|
93
|
+
}
|
|
94
|
+
if (column.type === TableColumnType.Date) {
|
|
95
|
+
return ModelColumnControl.Date;
|
|
96
|
+
}
|
|
97
|
+
if (column.type === TableColumnType.ObjectID) {
|
|
98
|
+
return ModelColumnControl.ObjectId;
|
|
99
|
+
}
|
|
100
|
+
if (column.type === TableColumnType.Color) {
|
|
101
|
+
return ModelColumnControl.Color;
|
|
102
|
+
}
|
|
103
|
+
if (NUMBER_COLUMN_TYPES.includes(column.type)) {
|
|
104
|
+
return ModelColumnControl.Number;
|
|
105
|
+
}
|
|
106
|
+
if (LONG_TEXT_COLUMN_TYPES.includes(column.type)) {
|
|
107
|
+
return ModelColumnControl.LongText;
|
|
108
|
+
}
|
|
109
|
+
if (TEXT_COLUMN_TYPES.includes(column.type)) {
|
|
110
|
+
return ModelColumnControl.Text;
|
|
111
|
+
}
|
|
112
|
+
return ModelColumnControl.Text;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* The one-word type shown under a field's name, so the builder can see what
|
|
116
|
+
* kind of value is expected without opening the model's documentation.
|
|
117
|
+
*/
|
|
118
|
+
export const columnTypeLabel = (column) => {
|
|
119
|
+
if (!column) {
|
|
120
|
+
return "Unknown";
|
|
121
|
+
}
|
|
122
|
+
if (column.isRelation) {
|
|
123
|
+
return "Relation";
|
|
124
|
+
}
|
|
125
|
+
switch (controlForColumn(column)) {
|
|
126
|
+
case ModelColumnControl.Number:
|
|
127
|
+
return "Number";
|
|
128
|
+
case ModelColumnControl.Boolean:
|
|
129
|
+
return "True or false";
|
|
130
|
+
case ModelColumnControl.Date:
|
|
131
|
+
return "Date and time";
|
|
132
|
+
case ModelColumnControl.ObjectId:
|
|
133
|
+
return "ID";
|
|
134
|
+
case ModelColumnControl.Color:
|
|
135
|
+
return "Color";
|
|
136
|
+
case ModelColumnControl.LongText:
|
|
137
|
+
return "Long text";
|
|
138
|
+
case ModelColumnControl.Unsupported:
|
|
139
|
+
/*
|
|
140
|
+
* The raw column type is more use than the word "unsupported" here: it is
|
|
141
|
+
* what the builder will have to write by hand in the JSON editor.
|
|
142
|
+
*/
|
|
143
|
+
return column.type;
|
|
144
|
+
default:
|
|
145
|
+
return "Text";
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Can this stored value be shown in the typed control without changing it?
|
|
150
|
+
*
|
|
151
|
+
* A `false` here is not an error — it sends the row to ColumnValueMode.Raw,
|
|
152
|
+
* where it is shown as text and re-emitted exactly as it was read. That is what
|
|
153
|
+
* stops opening a workflow and saving it again from rewriting `{"port":"8080"}`
|
|
154
|
+
* into `{"port":8080}` behind the builder's back.
|
|
155
|
+
*/
|
|
156
|
+
export const literalFitsControl = (control, value) => {
|
|
157
|
+
/*
|
|
158
|
+
* An empty control holds "" and nothing else. undefined and "" are what an
|
|
159
|
+
* untouched row is, so they fit; null does not, because an empty control
|
|
160
|
+
* cannot say "null" - it emits "", which a record drops entirely. A stored
|
|
161
|
+
* null therefore keeps its own value rather than being flattened into a
|
|
162
|
+
* missing field.
|
|
163
|
+
*/
|
|
164
|
+
if (value === undefined || value === "") {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (value === null) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
switch (control) {
|
|
171
|
+
case ModelColumnControl.Number:
|
|
172
|
+
return typeof value === "number" && !isNaN(value);
|
|
173
|
+
case ModelColumnControl.Boolean:
|
|
174
|
+
return typeof value === "boolean";
|
|
175
|
+
case ModelColumnControl.Date:
|
|
176
|
+
/*
|
|
177
|
+
* Dates travel as ISO strings. Anything else - a number of milliseconds,
|
|
178
|
+
* an operator wrapper - is shown raw rather than reinterpreted.
|
|
179
|
+
*/
|
|
180
|
+
return typeof value === "string" && !isNaN(Date.parse(value));
|
|
181
|
+
default:
|
|
182
|
+
return typeof value === "string";
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Should this column appear in the "add a field" picker?
|
|
187
|
+
*
|
|
188
|
+
* Note this only gates what is *offered*. A column already stored on the
|
|
189
|
+
* argument always gets its row, tenant column and all, because hiding a value
|
|
190
|
+
* that is really there is how an editor loses someone's work.
|
|
191
|
+
*/
|
|
192
|
+
export const isOfferableColumn = (column) => {
|
|
193
|
+
if (column.isRelation) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
/*
|
|
197
|
+
* The workflow runner stamps the project column itself
|
|
198
|
+
* (ModelArguments.applyTenantColumn) and overwrites whatever was typed, so
|
|
199
|
+
* offering it would be offering a field that cannot work.
|
|
200
|
+
*/
|
|
201
|
+
if (column.isTenantColumn) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
return controlForColumn(column) !== ModelColumnControl.Unsupported;
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=ColumnControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnControl.js","sourceRoot":"","sources":["../../../../../../UI/Components/Workflow/ColumnEditor/ColumnControl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,eAAe,MAAM,4CAA4C,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAkB;IACvC,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,IAAI;IACpB,eAAe,CAAC,IAAI;IACpB,eAAe,CAAC,KAAK;IACrB,eAAe,CAAC,KAAK;IACrB,eAAe,CAAC,MAAM;IACtB,eAAe,CAAC,EAAE;IAClB,eAAe,CAAC,OAAO;IACvB,eAAe,CAAC,OAAO;IACvB,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,GAAG;IACnB,eAAe,CAAC,WAAW;IAC3B,eAAe,CAAC,cAAc;IAC9B,eAAe,CAAC,eAAe;IAC/B,eAAe,CAAC,UAAU;CAC3B,CAAC;AAEF,MAAM,sBAAsB,GAAkB;IAC5C,eAAe,CAAC,QAAQ;IACxB,eAA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WAAW,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* One field of a record: the column's real name and description on the left,
|
|
3
|
+
* the value on the right.
|
|
4
|
+
*
|
|
5
|
+
* This is a settings form, not a table of key/value pairs, because the keys are
|
|
6
|
+
* not the builder's to invent - they are the model's columns, and the model has
|
|
7
|
+
* already said what each one is called and what it means.
|
|
8
|
+
*/
|
|
9
|
+
import IconProp from "../../../../Types/Icon/IconProp";
|
|
10
|
+
import AutocompleteTextInput from "../../AutocompleteTextInput/AutocompleteTextInput";
|
|
11
|
+
import Button, { ButtonStyleType } from "../../Button/Button";
|
|
12
|
+
import { columnTypeLabel, controlForColumn } from "./ColumnControl";
|
|
13
|
+
import { ColumnValueMode, changeColumnRow, } from "./ColumnRow";
|
|
14
|
+
import { rowIssue } from "./ColumnRowSerialization";
|
|
15
|
+
import ColumnValueInput from "./ColumnValueInput";
|
|
16
|
+
import React, { useId } from "react";
|
|
17
|
+
const ColumnFieldRow = (props) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
|
+
const labelId = useId();
|
|
20
|
+
const control = controlForColumn(props.column);
|
|
21
|
+
const issue = rowIssue(props.row, props.column);
|
|
22
|
+
const isUnknownColumn = !props.column;
|
|
23
|
+
const typeLabel = columnTypeLabel(props.column);
|
|
24
|
+
/*
|
|
25
|
+
* An empty required field is worth pointing at, but only quietly: the step
|
|
26
|
+
* cannot be saved without it anyway (form validation reads the whole value),
|
|
27
|
+
* and a red row for something the builder has not reached yet reads as an
|
|
28
|
+
* error they made.
|
|
29
|
+
*/
|
|
30
|
+
const isEmptyRequired = props.isRequired && props.row.text === "" && props.row.values.length === 0;
|
|
31
|
+
return (React.createElement("div", { className: "group relative grid grid-cols-1 items-start gap-x-4 gap-y-2 px-3 py-3 transition-colors hover:bg-gray-50/60 sm:grid-cols-[minmax(0,14rem)_minmax(0,1fr)_auto]", "data-testid": "model-column-row" },
|
|
32
|
+
isEmptyRequired && (React.createElement("span", { className: "absolute left-0 top-2 bottom-2 w-0.5 rounded-r bg-amber-400", "aria-hidden": "true" })),
|
|
33
|
+
React.createElement("div", { className: "min-w-0" }, isUnknownColumn ? (React.createElement("div", null,
|
|
34
|
+
React.createElement(AutocompleteTextInput, { value: props.row.columnId, placeholder: "Column name", suggestions: props.knownColumnIds, outerDivClassName: "relative w-full", className: "block w-full rounded-md border border-amber-300 bg-white py-1.5 pl-2 pr-2 font-mono text-xs text-gray-900 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500", disableSpellCheck: true, onChange: (value) => {
|
|
35
|
+
props.onChange(changeColumnRow(props.row, { columnId: value }));
|
|
36
|
+
} }),
|
|
37
|
+
React.createElement("span", { className: "mt-1 inline-block rounded bg-amber-50 px-1.5 py-0.5 text-[11px] text-amber-700" }, "Not a column on this model"))) : (React.createElement(React.Fragment, null,
|
|
38
|
+
React.createElement("label", { id: labelId, className: "block truncate text-sm font-medium text-gray-900" }, (_a = props.column) === null || _a === void 0 ? void 0 :
|
|
39
|
+
_a.title,
|
|
40
|
+
props.isRequired && (React.createElement("span", { className: "ml-0.5 text-red-500", "aria-hidden": "true" }, "*"))),
|
|
41
|
+
React.createElement("span", { className: "mt-1 flex items-center gap-1.5 text-[11px] text-gray-500" },
|
|
42
|
+
React.createElement("span", { className: "truncate rounded bg-gray-100 px-1.5 py-0.5 font-mono" }, props.row.columnId),
|
|
43
|
+
typeLabel.toLowerCase() !==
|
|
44
|
+
(((_b = props.column) === null || _b === void 0 ? void 0 : _b.title) || "").toLowerCase() && (React.createElement("span", { className: "truncate text-gray-400" }, typeLabel))),
|
|
45
|
+
((_c = props.column) === null || _c === void 0 ? void 0 : _c.description) && (React.createElement("span", { className: "mt-1 block text-xs leading-snug text-gray-500" }, props.column.description))))),
|
|
46
|
+
React.createElement("div", { className: "min-w-0" },
|
|
47
|
+
React.createElement(ColumnValueInput, { control: control, valueMode: props.row.valueMode, text: props.row.text, values: props.row.values, placeholder: ((_d = props.column) === null || _d === void 0 ? void 0 : _d.example) || ((_e = props.column) === null || _e === void 0 ? void 0 : _e.placeholder), suggestions: props.suggestions, ariaLabelledby: isUnknownColumn ? undefined : labelId, autoFocus: props.autoFocus, dataTestId: `model-column-value-${props.row.columnId}`, onChange: (change) => {
|
|
48
|
+
props.onChange(changeColumnRow(props.row, change));
|
|
49
|
+
} }),
|
|
50
|
+
props.row.valueMode === ColumnValueMode.Raw && (React.createElement("p", { className: "mt-1 text-[11px] text-amber-600" }, "Kept exactly as it was saved. Editing it rewrites it in this column's own type.")),
|
|
51
|
+
issue && React.createElement("p", { className: "mt-1 text-[11px] text-red-500" }, issue),
|
|
52
|
+
((_f = props.column) === null || _f === void 0 ? void 0 : _f.isTenantColumn) && (React.createElement("p", { className: "mt-1 text-[11px] text-gray-500" }, "The workflow sets this itself and ignores what you type here."))),
|
|
53
|
+
React.createElement("div", { className: "flex items-center pt-1" },
|
|
54
|
+
React.createElement(Button, { buttonStyle: ButtonStyleType.ICON, icon: IconProp.Trash, title: "Remove", dataTestId: `model-column-remove-${props.row.columnId}`, className: "opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100", onClick: props.onRemove }))));
|
|
55
|
+
};
|
|
56
|
+
export default ColumnFieldRow;
|
|
57
|
+
//# sourceMappingURL=ColumnFieldRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnFieldRow.js","sourceRoot":"","sources":["../../../../../../UI/Components/Workflow/ColumnEditor/ColumnFieldRow.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,qBAAqB,MAAM,mDAAmD,CAAC;AACtF,OAAO,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACL,eAAe,EAGf,eA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