mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-24 23:05:29 +08:00
Merge remote-tracking branch 'origin/devel' into CB-2344-projects-administration
This commit is contained in:
@@ -98,13 +98,14 @@ export class UsersResource extends CachedMapResource<string, AdminUser, UserReso
|
||||
}: UserCreateOptions): Promise<AdminUser> {
|
||||
const { user } = await this.graphQLService.sdk.createUser({
|
||||
userId,
|
||||
enabled,
|
||||
...this.getDefaultIncludes(),
|
||||
...this.getIncludesMap(userId),
|
||||
});
|
||||
|
||||
try {
|
||||
await this.updateCredentials(userId, credentials);
|
||||
await this.enableUser(userId, enabled, true);
|
||||
|
||||
for (const roleId of roles) {
|
||||
await this.grantRole(userId, roleId, true);
|
||||
}
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { computed } from 'mobx';
|
||||
import { computed, toJS } from 'mobx';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import styled from 'reshadow';
|
||||
|
||||
import { useTranslate } from '@cloudbeaver/core-localization';
|
||||
import { useStyles } from '@cloudbeaver/core-theming';
|
||||
|
||||
import { Button } from '../Button';
|
||||
import { ShadowInput } from '../FormControls/ShadowInput';
|
||||
import { useObjectRef } from '../useObjectRef';
|
||||
import type { IProperty } from './IProperty';
|
||||
import { PropertyItem } from './PropertyItem';
|
||||
@@ -31,6 +32,7 @@ interface Props {
|
||||
onAdd?: () => void;
|
||||
onRemove?: (property: IProperty) => void;
|
||||
className?: string;
|
||||
filterable?: boolean;
|
||||
}
|
||||
|
||||
export const PropertiesTable = observer<Props>(function PropertiesTable(props) {
|
||||
@@ -38,8 +40,13 @@ export const PropertiesTable = observer<Props>(function PropertiesTable(props) {
|
||||
const translate = useTranslate();
|
||||
const propsRef = useObjectRef({ ...props });
|
||||
|
||||
const sortedProperties = useMemo(() => computed(() => propsRef.properties.slice().sort(
|
||||
(a, b) => (a?.displayName ?? '').localeCompare(b?.displayName ?? ''))), [propsRef.properties]);
|
||||
const [filterValue, setFilterValue] = useState('');
|
||||
|
||||
const sortedProperties = useMemo(() => computed(() => propsRef.properties
|
||||
.slice()
|
||||
.sort((a, b) => (a.displayName ?? '').localeCompare(b.displayName ?? ''))
|
||||
.filter(p => p.key.toLocaleLowerCase().includes(filterValue.toLocaleLowerCase()))
|
||||
), [propsRef.properties, filterValue]);
|
||||
|
||||
const changeName = useCallback((id: string, key: string) => {
|
||||
const { properties, propertiesState, onKeyChange } = propsRef;
|
||||
@@ -109,7 +116,16 @@ export const PropertiesTable = observer<Props>(function PropertiesTable(props) {
|
||||
<properties className={className}>
|
||||
<properties-header>
|
||||
<properties-header-name>
|
||||
{translate('block_properties_table_name')}
|
||||
<div>
|
||||
{translate('block_properties_table_name')}
|
||||
</div>
|
||||
{props.filterable ? (
|
||||
<ShadowInput
|
||||
value={filterValue}
|
||||
placeholder={translate('block_properties_table_filter_name')}
|
||||
onChange={setFilterValue}
|
||||
/>
|
||||
) : null}
|
||||
</properties-header-name>
|
||||
<properties-header-value>
|
||||
{translate('block_properties_table_value')}
|
||||
|
||||
@@ -139,7 +139,12 @@ export const PropertyItem = observer<Props>(function PropertyItem({
|
||||
const handleRemove = useCallback(() => onRemove(property.id), [property]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (keyInputRef.current && isDeletable && property.new) {
|
||||
if (
|
||||
keyInputRef.current
|
||||
&& isDeletable
|
||||
&& property.new
|
||||
&& !(document.activeElement instanceof HTMLInputElement)
|
||||
) {
|
||||
keyInputRef.current.focus();
|
||||
}
|
||||
}, [property]);
|
||||
|
||||
@@ -19,6 +19,7 @@ export const PROPERTIES_TABLE_STYLES = css`
|
||||
box-sizing: border-box;
|
||||
display: inline-flex;
|
||||
border-bottom: solid 1px;
|
||||
align-items: center;
|
||||
}
|
||||
properties-header-name, properties-header-value {
|
||||
composes: theme-typography--caption from global;
|
||||
@@ -30,6 +31,8 @@ export const PROPERTIES_TABLE_STYLES = css`
|
||||
properties-header-name {
|
||||
flex: 0 0 auto;
|
||||
width: 300px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
properties-header-add {
|
||||
flex: 0 0 auto;
|
||||
@@ -54,6 +57,14 @@ export const PROPERTIES_TABLE_STYLES = css`
|
||||
height: 24px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
ShadowInput {
|
||||
composes: theme-background-surface from global;
|
||||
box-sizing: border-box;
|
||||
height: 24px;
|
||||
flex: 1;
|
||||
margin-left: 8px;
|
||||
}
|
||||
`;
|
||||
|
||||
export const PROPERTIES_TABLE_ADD_STYLES = css`
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export default [
|
||||
['block_properties_table_name', 'Name'],
|
||||
['block_properties_table_value', 'Value'],
|
||||
['block_properties_table_filter_name', 'Filter'],
|
||||
['block_properties_table_add', 'Add property'],
|
||||
['combobox_no_results_placeholder', 'No results'],
|
||||
];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export default [
|
||||
['block_properties_table_name', 'Название'],
|
||||
['block_properties_table_value', 'Значение'],
|
||||
['block_properties_table_filter_name', 'Фильтр'],
|
||||
['block_properties_table_add', 'Добавить параметр'],
|
||||
['combobox_no_results_placeholder', 'Нет совпадений'],
|
||||
];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
query createUser($userId: ID!, $includeMetaParameters: Boolean!, $customIncludeOriginDetails: Boolean!) {
|
||||
user: createUser(userId: $userId) {
|
||||
query createUser($userId: ID!, $enabled: Boolean!, $includeMetaParameters: Boolean!, $customIncludeOriginDetails: Boolean!) {
|
||||
user: createUser(userId: $userId, enabled: $enabled) {
|
||||
...AdminUserInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -961,6 +961,7 @@ export interface QueryCreateRoleArgs {
|
||||
|
||||
|
||||
export interface QueryCreateUserArgs {
|
||||
enabled: Scalars['Boolean'];
|
||||
userId: Scalars['ID'];
|
||||
}
|
||||
|
||||
@@ -1704,6 +1705,7 @@ export type SaveUserMetaParametersQuery = { setUserMetaParameterValues: boolean
|
||||
|
||||
export type CreateUserQueryVariables = Exact<{
|
||||
userId: Scalars['ID'];
|
||||
enabled: Scalars['Boolean'];
|
||||
includeMetaParameters: Scalars['Boolean'];
|
||||
customIncludeOriginDetails: Scalars['Boolean'];
|
||||
}>;
|
||||
@@ -3147,8 +3149,8 @@ export const SaveUserMetaParametersDocument = `
|
||||
}
|
||||
`;
|
||||
export const CreateUserDocument = `
|
||||
query createUser($userId: ID!, $includeMetaParameters: Boolean!, $customIncludeOriginDetails: Boolean!) {
|
||||
user: createUser(userId: $userId) {
|
||||
query createUser($userId: ID!, $enabled: Boolean!, $includeMetaParameters: Boolean!, $customIncludeOriginDetails: Boolean!) {
|
||||
user: createUser(userId: $userId, enabled: $enabled) {
|
||||
...AdminUserInfo
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -105,6 +105,7 @@ export const DriverProperties: TabContainerPanelComponent<IConnectionFormProps>
|
||||
properties={joinedProperties.get()}
|
||||
propertiesState={formState.config.properties}
|
||||
readOnly={formState.readonly}
|
||||
filterable
|
||||
onAdd={state.add}
|
||||
onRemove={state.remove}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user