mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-2783 show description when only one possible project (#1356)
This commit is contained in:
@@ -142,6 +142,7 @@ type BaseProps<TKey, TValue> = Omit<React.InputHTMLAttributes<HTMLInputElement>,
|
||||
searchable?: boolean;
|
||||
defaultValue?: TKey;
|
||||
loading?: boolean;
|
||||
description?: string;
|
||||
keySelector?: (item: TValue, index: number) => TKey;
|
||||
valueSelector?: (item: TValue) => string;
|
||||
titleSelector?: (item: TValue) => string | undefined;
|
||||
@@ -187,6 +188,7 @@ export const Combobox: ComboboxType = observer(function Combobox({
|
||||
readOnly,
|
||||
disabled,
|
||||
inline,
|
||||
description,
|
||||
keySelector = v => v,
|
||||
valueSelector = v => v,
|
||||
iconSelector,
|
||||
@@ -421,6 +423,11 @@ export const Combobox: ComboboxType = observer(function Combobox({
|
||||
}))}
|
||||
</Menu>
|
||||
</input-box>
|
||||
{description && (
|
||||
<field-description>
|
||||
{description}
|
||||
</field-description>
|
||||
)}
|
||||
</field>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -14,12 +14,13 @@ import { CachedMapAllKey } from '@cloudbeaver/core-sdk';
|
||||
|
||||
interface Props {
|
||||
value: string | null;
|
||||
filter?: (project: ProjectInfo) => boolean;
|
||||
onChange: (value: string) => void;
|
||||
autoHide?: boolean;
|
||||
readOnly?: boolean;
|
||||
disabled?: boolean;
|
||||
inline?: boolean;
|
||||
onChange: (value: string) => void;
|
||||
filter?: (project: ProjectInfo) => boolean;
|
||||
descriptionGetter?: (projects: ProjectInfo[], possibleOptions: string[]) => string | undefined;
|
||||
}
|
||||
|
||||
export const ProjectSelect = observer(function ProjectSelect({
|
||||
@@ -30,6 +31,7 @@ export const ProjectSelect = observer(function ProjectSelect({
|
||||
disabled,
|
||||
inline,
|
||||
onChange,
|
||||
descriptionGetter,
|
||||
}: Props) {
|
||||
const translate = useTranslate();
|
||||
|
||||
@@ -64,6 +66,8 @@ export const ProjectSelect = observer(function ProjectSelect({
|
||||
return null;
|
||||
}
|
||||
|
||||
const description = descriptionGetter?.(projects, possibleOptions);
|
||||
|
||||
return (
|
||||
<Combobox
|
||||
name='projectId'
|
||||
@@ -78,6 +82,7 @@ export const ProjectSelect = observer(function ProjectSelect({
|
||||
disabled={disabled}
|
||||
loading={projectsLoader.isLoading()}
|
||||
inline={inline}
|
||||
description={description}
|
||||
tiny
|
||||
fill
|
||||
onSelect={handleProjectSelect}
|
||||
|
||||
@@ -118,8 +118,9 @@ export const SaveScriptDialog: DialogComponent<Payload, ISaveScriptDialogResult>
|
||||
<ProjectSelect
|
||||
value={state.projectId}
|
||||
filter={p => (p.canEditResources && p.id === (payload.projectId ?? p.id))}
|
||||
descriptionGetter={(_, options) => options.length <= 1 ? translate('plugin_resource_manager_save_script_project_restriction_descripion') : undefined}
|
||||
autoHide
|
||||
onChange={projectId => {state.projectId = projectId;}}
|
||||
onChange={projectId => { state.projectId = projectId; }}
|
||||
/>
|
||||
</Container>
|
||||
</SubmittingForm>
|
||||
|
||||
@@ -19,4 +19,5 @@ export default [
|
||||
['plugin_resource_manager_script_delete_confirmation', 'You are going to delete "{arg:name}". Are you sure?'],
|
||||
['plugin_resource_manager_script_not_found_message', 'The script was probably removed or renamed. The last known value will be used'],
|
||||
['plugin_resource_manager_script_name_invalid_characters_message', 'Script\'s name may contain the following symbols "_-$.()@" and can\'t start with a dot'],
|
||||
['plugin_resource_manager_save_script_project_restriction_descripion', "The script's project can't be different from the connection's project"],
|
||||
];
|
||||
@@ -19,4 +19,5 @@ export default [
|
||||
['plugin_resource_manager_script_delete_confirmation', 'You are going to delete "{arg:name}". Are you sure?'],
|
||||
['plugin_resource_manager_script_not_found_message', 'The script was probably removed or renamed. The last known value will be used'],
|
||||
['plugin_resource_manager_script_name_invalid_characters_message', 'Script\'s name may contain the following symbols "_-$.()@" and can\'t start with a dot'],
|
||||
['plugin_resource_manager_save_script_project_restriction_descripion', "The script's project can't be different from the connection's project"],
|
||||
];
|
||||
@@ -19,4 +19,5 @@ export default [
|
||||
['plugin_resource_manager_script_delete_confirmation', 'Вы удаляете "{arg:name}". Удалить?'],
|
||||
['plugin_resource_manager_script_not_found_message', 'Возможно скрипт был удален или переименован. Будет использовано последнее известное значение'],
|
||||
['plugin_resource_manager_script_name_invalid_characters_message', 'Имя скрипта может содержать следующие символы "_-$.()@" и не может начинаться с точки'],
|
||||
['plugin_resource_manager_save_script_project_restriction_descripion', 'Проект скрипта не может отличаться от проекта подключения'],
|
||||
];
|
||||
@@ -19,4 +19,5 @@ export default [
|
||||
['plugin_resource_manager_script_delete_confirmation', '你确定要删除"{arg:name}"吗?'],
|
||||
['plugin_resource_manager_script_not_found_message', '脚本可能被删除或重命名,将使用最后的有效值'],
|
||||
['plugin_resource_manager_script_name_invalid_characters_message', '脚本名称中可以使用字符"_-$.()@" 但不能以"."开头'],
|
||||
['plugin_resource_manager_save_script_project_restriction_descripion', "The script's project can't be different from the connection's project"],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user