From 160765131d378141b3e5af1b1f30b65cbd8e5f49 Mon Sep 17 00:00:00 2001 From: Nick Lanam Date: Thu, 5 May 2022 16:45:16 -0700 Subject: [PATCH] [PC-1511]: Show default export URL placeholder: better label Summary: Better labeling. Consistently call it `Export URL` rather than path; show the default value as the placeholder when available. When editing a retention script, if the plugin has customExportURL defined, that takes precedence over the top-level default. Test Plan: Visit both plugin configs and data retention script configs. The label and placeholder for export URLs should now consistently call it a URL, and placeholders will show the value that will be used if not overridden there. Reviewers: michelle, vihang Reviewed By: michelle JIRA Issues: PC-1511 Signed-off-by: Nick Lanam Differential Revision: https://phab.corp.pixielabs.ai/D11379 GitOrigin-RevId: 26e2e7d78f5b9a7ba09aecefa3770873b4b4a2c8 --- .../containers/admin/plugins/plugin-config.tsx | 7 ++++--- .../src/containers/admin/plugins/plugin-gql.ts | 1 + .../configure-data-export/data-export-detail.tsx | 16 ++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/ui/src/containers/admin/plugins/plugin-config.tsx b/src/ui/src/containers/admin/plugins/plugin-config.tsx index 4c2a8a11b48..21115fd18a1 100644 --- a/src/ui/src/containers/admin/plugins/plugin-config.tsx +++ b/src/ui/src/containers/admin/plugins/plugin-config.tsx @@ -122,9 +122,10 @@ export const PluginConfig = React.memo<{ plugin: GQLPlugin }>(({ plugin }) => { {schema?.allowCustomExportURL && ( setPendingValues((prev) => ({ ...prev, customExportURL: e.target.value }))} InputLabelProps={{ shrink: true }} diff --git a/src/ui/src/containers/admin/plugins/plugin-gql.ts b/src/ui/src/containers/admin/plugins/plugin-gql.ts index 49d70d8ecd1..2cc1bceb0cc 100644 --- a/src/ui/src/containers/admin/plugins/plugin-gql.ts +++ b/src/ui/src/containers/admin/plugins/plugin-gql.ts @@ -54,6 +54,7 @@ export const GQL_GET_RETENTION_PLUGIN_INFO = gql` description } allowCustomExportURL + defaultExportURL allowInsecureTLS } } diff --git a/src/ui/src/pages/configure-data-export/data-export-detail.tsx b/src/ui/src/pages/configure-data-export/data-export-detail.tsx index d028abe3557..4338e2d45ef 100644 --- a/src/ui/src/pages/configure-data-export/data-export-detail.tsx +++ b/src/ui/src/pages/configure-data-export/data-export-detail.tsx @@ -45,7 +45,6 @@ import { AutoSizerContext, withAutoSizerContext } from 'app/utils/autosizer'; import { ClusterInfoForRetentionScripts, DEFAULT_RETENTION_PXL, - PartialPlugin, useClustersForRetentionScripts, useCreateRetentionScript, useMutateRetentionScript, @@ -170,11 +169,6 @@ function useCreateOrUpdateScript(scriptId: string, isCreate: boolean) { ), [scriptId, isCreate, create, update]); } -function useAllowCustomExportURL(plugin: PartialPlugin | null) { - const { loading, schema } = usePluginConfig(plugin ?? { id: '', latestVersion: '' }); - return !loading && schema?.allowCustomExportURL === true; -} - export const EditDataExportScript = React.memo<{ scriptId: string, isCreate: boolean }>(({ scriptId, isCreate }) => { const classes = useStyles(); const showSnackbar = useSnackbar(); @@ -208,9 +202,11 @@ export const EditDataExportScript = React.memo<{ scriptId: string, isCreate: boo exportPath: '', }); - const allowCustomExportURL = useAllowCustomExportURL( - enabledPlugins.find(p => p.id === pendingValues.pluginID), + const { schema, values } = usePluginConfig( + enabledPlugins.find(p => p.id === pendingValues.pluginID) ?? { id: '', enabledVersion: '', latestVersion: '' }, ); + const allowCustomExportURL = schema?.allowCustomExportURL === true; + const defaultExportURL = values?.customExportURL || schema?.defaultExportURL || ''; const setPendingField = React.useCallback(( field: K, @@ -390,9 +386,9 @@ export const EditDataExportScript = React.memo<{ scriptId: string, isCreate: boo disabled={!allowCustomExportURL} sx={{ width: '25ch' }} variant='standard' - label='Export Path' + label='Export URL' placeholder={allowCustomExportURL - ? 'Optional. Plugin-dependent.' + ? (defaultExportURL || 'Optional. Plugin-dependent.') : 'Not available with this plugin.' } value={pendingValues.exportPath}