Skip to content

Commit

Permalink
[PC-1511]: Show default export URL placeholder: better label
Browse files Browse the repository at this point in the history
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 <nlanam@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D11379

GitOrigin-RevId: 26e2e7d
  • Loading branch information
NickLanam authored and copybaranaut committed May 6, 2022
1 parent 81f3977 commit 1607651
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/ui/src/containers/admin/plugins/plugin-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ export const PluginConfig = React.memo<{ plugin: GQLPlugin }>(({ plugin }) => {
{schema?.allowCustomExportURL && (
<TextField
variant='outlined'
label='Custom export path'
placeholder='Default path for retention scripts'
helperText={pendingValues.customExportURL ? 'Default path for retention scripts' : ''}
label='Custom export URL'
required={!schema?.defaultExportURL}
placeholder={schema?.defaultExportURL || 'Default URL for retention scripts'}
helperText={pendingValues.customExportURL ? 'Default URL for retention scripts' : ''}
value={pendingValues.customExportURL ?? ''}
onChange={(e) => setPendingValues((prev) => ({ ...prev, customExportURL: e.target.value }))}
InputLabelProps={{ shrink: true }}
Expand Down
1 change: 1 addition & 0 deletions src/ui/src/containers/admin/plugins/plugin-gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const GQL_GET_RETENTION_PLUGIN_INFO = gql`
description
}
allowCustomExportURL
defaultExportURL
allowInsecureTLS
}
}
Expand Down
16 changes: 6 additions & 10 deletions src/ui/src/pages/configure-data-export/data-export-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { AutoSizerContext, withAutoSizerContext } from 'app/utils/autosizer';
import {
ClusterInfoForRetentionScripts,
DEFAULT_RETENTION_PXL,
PartialPlugin,
useClustersForRetentionScripts,
useCreateRetentionScript,
useMutateRetentionScript,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(<K extends keyof RetentionScriptForm>(
field: K,
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 1607651

Please sign in to comment.