Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/containers/Tenant/Tenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {useTypedSelector} from '../../utils/hooks';
import routes, {CLUSTER_PAGES, createHref} from '../../routes';
import {setHeader} from '../../store/reducers/header';
import {disableAutorefresh, getSchema, resetLoadingState} from '../../store/reducers/schema';
import {getSchemaAcl} from '../../store/reducers/schemaAcl';
import {getSchemaAcl} from '../../store/reducers/schemaAcl/schemaAcl';
import {getTenantInfo, clearTenant} from '../../store/reducers/tenant/tenant';

import SplitPane from '../../components/SplitPane';
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import settings from './settings/settings';
import preview from './preview';
import nodesList from './nodesList';
import describe from './describe';
import schemaAcl from './schemaAcl';
import schemaAcl from './schemaAcl/schemaAcl';
import executeTopQueries from './executeTopQueries';
import healthcheckInfo from './healthcheckInfo';
import shardsWorkload from './shardsWorkload';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import {createRequestActionTypes, createApiRequest} from '../utils';
import '../../services/api';
import _ from 'lodash';
import type {Reducer} from 'redux';

const FETCH_SCHEMA_ACL = createRequestActionTypes('schemaAcl', 'FETCH_SCHEMA_ACL');
import '../../../services/api';
import {createRequestActionTypes, createApiRequest} from '../../utils';

const schemaAcl = function z(state = {loading: false, wasLoaded: false, acl: undefined}, action) {
import type {SchemaAclAction, SchemaAclState} from './types';

export const FETCH_SCHEMA_ACL = createRequestActionTypes('schemaAcl', 'FETCH_SCHEMA_ACL');

const initialState = {
loading: false,
wasLoaded: false,
};

const schemaAcl: Reducer<SchemaAclState, SchemaAclAction> = (state = initialState, action) => {
switch (action.type) {
case FETCH_SCHEMA_ACL.REQUEST: {
return {
Expand All @@ -13,13 +21,16 @@ const schemaAcl = function z(state = {loading: false, wasLoaded: false, acl: und
};
}
case FETCH_SCHEMA_ACL.SUCCESS: {
const acl = action.data.Common?.ACL;
const owner = action.data.Common?.Owner;

return {
...state,
error: undefined,
acl: _.get(action.data, 'Common.ACL'),
owner: _.get(action.data, 'Common.Owner'),
acl,
owner,
loading: false,
wasLoaded: true,
error: undefined,
};
}
case FETCH_SCHEMA_ACL.FAILURE: {
Expand All @@ -34,7 +45,7 @@ const schemaAcl = function z(state = {loading: false, wasLoaded: false, acl: und
}
};

export function getSchemaAcl({path}) {
export function getSchemaAcl({path}: {path: string}) {
return createApiRequest({
request: window.api.getSchemaAcl({path}),
actions: FETCH_SCHEMA_ACL,
Expand Down
15 changes: 15 additions & 0 deletions src/store/reducers/schemaAcl/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type {TACE, TMetaInfo} from '../../../types/api/acl';
import type {IResponseError} from '../../../types/api/error';
import type {ApiRequestAction} from '../../utils';

import {FETCH_SCHEMA_ACL} from './schemaAcl';

export interface SchemaAclState {
loading: boolean
wasLoaded: boolean
acl?: TACE[]
owner?: string
error?: IResponseError
}

export type SchemaAclAction = ApiRequestAction<typeof FETCH_SCHEMA_ACL, TMetaInfo, IResponseError>;
2 changes: 1 addition & 1 deletion src/types/api/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface TMetaCommonInfo {
ACL?: TACE[];
}

interface TACE {
export interface TACE {
AccessType: string;
AccessRights?: string[];
Subject: string;
Expand Down