diff --git a/common/index.ts b/common/index.ts index 9b038a581..333ccd9e3 100644 --- a/common/index.ts +++ b/common/index.ts @@ -64,6 +64,17 @@ export enum AuthType { ANONYMOUS = 'anonymous', } +export enum ResourceType { + roles = 'roles', + users = 'users', + permissions = 'permissions', + tenants = 'tenants', + tenantsManageTab = 'tenantsManageTab', + tenantsConfigureTab = 'tenantsConfigureTab', + auth = 'auth', + auditLogging = 'auditLogging', +} + /** * A valid resource name should not containing percent sign (%) as they raise url injection issue. * And also should not be empty. diff --git a/public/apps/configuration/app-router.tsx b/public/apps/configuration/app-router.tsx index 6cb97ec0e..013e2dd2b 100644 --- a/public/apps/configuration/app-router.tsx +++ b/public/apps/configuration/app-router.tsx @@ -35,7 +35,8 @@ import { RoleEditMappedUser } from './panels/role-mapping/role-edit-mapped-user' import { RoleView } from './panels/role-view/role-view'; import { TenantList } from './panels/tenant-list/tenant-list'; import { UserList } from './panels/user-list'; -import { Action, ResourceType, RouteItem, SubAction } from './types'; +import { Action, RouteItem, SubAction } from './types'; +import { ResourceType } from '../../../common'; import { buildHashUrl, buildUrl } from './utils/url-builder'; import { CrossPageToast } from './cross-page-toast'; diff --git a/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx b/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx index 972442978..de5d0086f 100644 --- a/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx +++ b/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx @@ -31,7 +31,7 @@ import { SETTING_GROUPS, SettingMapItem } from './constants'; import { EditSettingGroup } from './edit-setting-group'; import { AuditLoggingSettings } from './types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ResourceType } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getAuditLogging, updateAuditLogging } from '../../utils/audit-logging-utils'; import { useToastState } from '../../utils/toast-utils'; import { setCrossPageToast } from '../../utils/storage-utils'; diff --git a/public/apps/configuration/panels/audit-logging/audit-logging.tsx b/public/apps/configuration/panels/audit-logging/audit-logging.tsx index e920c32e0..5ca10c84c 100644 --- a/public/apps/configuration/panels/audit-logging/audit-logging.tsx +++ b/public/apps/configuration/panels/audit-logging/audit-logging.tsx @@ -31,7 +31,7 @@ import { import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; import { AppDependencies } from '../../../types'; -import { ResourceType } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getAuditLogging, updateAuditLogging } from '../../utils/audit-logging-utils'; import { displayBoolean, ExternalLink } from '../../utils/display-utils'; import { buildHashUrl } from '../../utils/url-builder'; diff --git a/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx b/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx index 038b0c5c8..a7b52d428 100644 --- a/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx +++ b/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx @@ -18,7 +18,7 @@ import { AuditLoggingEditSettings } from '../audit-logging-edit-settings'; import React from 'react'; import { ComplianceSettings, GeneralSettings } from '../types'; import { buildHashUrl } from '../../../utils/url-builder'; -import { ResourceType } from '../../../types'; +import { ResourceType } from '../../../../../../common'; jest.mock('../../../utils/audit-logging-utils'); diff --git a/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx b/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx index 35e6d0273..2bc5d4881 100644 --- a/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx +++ b/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx @@ -18,7 +18,7 @@ import { AuditLogging, renderComplianceSettings, renderGeneralSettings } from '. import React from 'react'; import { EuiSwitch } from '@elastic/eui'; import { buildHashUrl } from '../../../utils/url-builder'; -import { ResourceType } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { SUB_URL_FOR_COMPLIANCE_SETTINGS_EDIT, SUB_URL_FOR_GENERAL_SETTINGS_EDIT, diff --git a/public/apps/configuration/panels/get-started.tsx b/public/apps/configuration/panels/get-started.tsx index b2c562e35..dcf4fed41 100644 --- a/public/apps/configuration/panels/get-started.tsx +++ b/public/apps/configuration/panels/get-started.tsx @@ -27,17 +27,12 @@ import { } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; -import { flow } from 'lodash'; -import { HashRouter as Router, Route } from 'react-router-dom'; import { AppDependencies } from '../../types'; -import { buildHashUrl, buildUrl } from '../utils/url-builder'; -import { Action, ResourceType, RouteItem } from '../types'; +import { buildHashUrl } from '../utils/url-builder'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { API_ENDPOINT_CACHE, DocLinks } from '../constants'; import { ExternalLink, ExternalLinkButton } from '../utils/display-utils'; -import { TenantList } from './tenant-list/tenant-list'; -import { getBreadcrumbs } from '../app-router'; - -import { CrossPageToast } from '../cross-page-toast'; const addBackendStep = { title: 'Add backends', diff --git a/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx b/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx index f93ef0407..1237ef9f3 100644 --- a/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx +++ b/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx @@ -26,7 +26,8 @@ import { } from '@elastic/eui'; import React, { useState } from 'react'; import { BreadcrumbsPageDependencies } from '../../../types'; -import { InternalUserUpdate, ResourceType } from '../../types'; +import { InternalUserUpdate } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getUserDetail, updateUser } from '../../utils/internal-user-detail-utils'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { PasswordEditPanel } from '../../utils/password-edit-panel'; diff --git a/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx b/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx index e80d0d0e1..3ac52f6d3 100644 --- a/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx @@ -15,7 +15,8 @@ import React, { Dispatch, SetStateAction } from 'react'; import { EuiForm, EuiFlexGroup, EuiFlexItem, EuiComboBox } from '@elastic/eui'; -import { ComboBoxOptions, ResourceType } from '../../types'; +import { ComboBoxOptions } from '../../types'; +import { ResourceType } from '../../../../../common'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { FormRow } from '../../utils/form-row'; import { LIMIT_WIDTH_INPUT_CLASS } from '../../constants'; diff --git a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx index 75e2856e4..e52cb9128 100644 --- a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx @@ -25,7 +25,8 @@ import { } from '@elastic/eui'; import React, { Dispatch, Fragment, SetStateAction } from 'react'; import { isEmpty } from 'lodash'; -import { RoleIndexPermission, ResourceType } from '../../types'; +import { RoleIndexPermission } from '../../types'; +import { ResourceType } from '../../../../../common'; import { appendElementToArray, removeElementFromArray, @@ -141,9 +142,9 @@ export function IndexPermissionRow(props: { return ( diff --git a/public/apps/configuration/panels/role-edit/role-edit.tsx b/public/apps/configuration/panels/role-edit/role-edit.tsx index e5b3c832a..c237eaefd 100644 --- a/public/apps/configuration/panels/role-edit/role-edit.tsx +++ b/public/apps/configuration/panels/role-edit/role-edit.tsx @@ -46,7 +46,8 @@ import { } from './tenant-panel'; import { RoleIndexPermissionStateClass, RoleTenantPermissionStateClass } from './types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ComboBoxOptions, ResourceType, Action, ActionGroupItem } from '../../types'; +import { ComboBoxOptions, Action, ActionGroupItem } from '../../types'; +import { ResourceType } from '../../../../../common'; import { useToastState, createUnknownErrorToast, diff --git a/public/apps/configuration/panels/role-list.tsx b/public/apps/configuration/panels/role-list.tsx index 118491563..38b6ca2e1 100644 --- a/public/apps/configuration/panels/role-list.tsx +++ b/public/apps/configuration/panels/role-list.tsx @@ -41,7 +41,8 @@ import { fetchRoleMapping, buildSearchFilterOptions, } from '../utils/role-list-utils'; -import { ResourceType, Action } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { buildHashUrl } from '../utils/url-builder'; import { ExternalLink, diff --git a/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx b/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx index 9b2a859da..44909bef5 100644 --- a/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx +++ b/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx @@ -35,7 +35,8 @@ import { ExternalIdentityStateClass } from './types'; import { ComboBoxOptions } from '../../types'; import { stringToComboBoxOption, comboBoxOptionToString } from '../../utils/combo-box-utils'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ResourceType, RoleMappingDetail, SubAction, Action } from '../../types'; +import { RoleMappingDetail, SubAction, Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { fetchUserNameList } from '../../utils/internal-user-list-utils'; import { updateRoleMapping, getRoleMappingData } from '../../utils/role-mapping-utils'; import { createErrorToast, createUnknownErrorToast, useToastState } from '../../utils/toast-utils'; diff --git a/public/apps/configuration/panels/role-mapping/users-panel.tsx b/public/apps/configuration/panels/role-mapping/users-panel.tsx index 39cec7538..6c65a152b 100644 --- a/public/apps/configuration/panels/role-mapping/users-panel.tsx +++ b/public/apps/configuration/panels/role-mapping/users-panel.tsx @@ -19,7 +19,8 @@ import { ComboBoxOptions } from '../../types'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { FormRow } from '../../utils/form-row'; import { buildHashUrl } from '../../utils/url-builder'; -import { ResourceType, Action } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { ExternalLinkButton } from '../../utils/display-utils'; import { DocLinks } from '../../constants'; import { appendOptionToComboBoxHandler } from '../../utils/combo-box-utils'; diff --git a/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx b/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx index 3d4a02df5..659f98c13 100644 --- a/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx +++ b/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx @@ -17,7 +17,8 @@ import React from 'react'; import { EuiEmptyPrompt, EuiButton } from '@elastic/eui'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { PermissionTree } from '../permission-tree'; -import { ActionGroupItem, DataObject, ResourceType, Action } from '../../types'; +import { ActionGroupItem, DataObject, Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { buildHashUrl } from '../../utils/url-builder'; import { loadingSpinner } from '../../utils/loading-spinner-utils'; import { DocLinks } from '../../constants'; diff --git a/public/apps/configuration/panels/role-view/index-permission-panel.tsx b/public/apps/configuration/panels/role-view/index-permission-panel.tsx index b04583522..8c622afd3 100644 --- a/public/apps/configuration/panels/role-view/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-view/index-permission-panel.tsx @@ -30,9 +30,9 @@ import { ActionGroupItem, ExpandedRowMapInterface, RoleIndexPermissionView, - ResourceType, Action, } from '../../types'; +import { ResourceType } from '../../../../../common'; import { truncatedListView, displayArray, tableItemsUIProps } from '../../utils/display-utils'; import { PermissionTree } from '../permission-tree'; import { getFieldLevelSecurityMethod } from '../../utils/index-permission-utils'; diff --git a/public/apps/configuration/panels/role-view/role-view.tsx b/public/apps/configuration/panels/role-view/role-view.tsx index 04e5d1f99..723d546da 100644 --- a/public/apps/configuration/panels/role-view/role-view.tsx +++ b/public/apps/configuration/panels/role-view/role-view.tsx @@ -39,7 +39,6 @@ import { difference } from 'lodash'; import { BreadcrumbsPageDependencies } from '../../../types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; import { - ResourceType, Action, SubAction, RoleMappingDetail, @@ -48,6 +47,7 @@ import { RoleIndexPermissionView, RoleTenantPermissionView, } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getRoleMappingData, MappedUsersListing, diff --git a/public/apps/configuration/panels/role-view/tenants-panel.tsx b/public/apps/configuration/panels/role-view/tenants-panel.tsx index 667b34f45..45d19bb2b 100644 --- a/public/apps/configuration/panels/role-view/tenants-panel.tsx +++ b/public/apps/configuration/panels/role-view/tenants-panel.tsx @@ -26,12 +26,8 @@ import { import { CoreStart } from 'opensearch-dashboards/public'; import { getCurrentUser } from '../../../../utils/auth-info-utils'; import { PanelWithHeader } from '../../utils/panel-with-header'; -import { - RoleTenantPermissionView, - RoleTenantPermissionDetail, - ResourceType, - Action, -} from '../../types'; +import { RoleTenantPermissionView, RoleTenantPermissionDetail, Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { truncatedListView, tableItemsUIProps } from '../../utils/display-utils'; import { fetchTenants, diff --git a/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx b/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx index 5891ac502..8e7d5be0c 100644 --- a/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx @@ -18,7 +18,8 @@ import { shallow } from 'enzyme'; import { ClusterPermissionPanel } from '../cluster-permission-panel'; import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui'; import { PermissionTree } from '../../permission-tree'; -import { Action, ResourceType } from '../../../types'; +import { Action } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { buildHashUrl } from '../../../utils/url-builder'; describe('Role view - cluster permission panel', () => { diff --git a/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx b/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx index 4c2f25555..dc9632eb2 100644 --- a/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx @@ -15,7 +15,8 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Action, ResourceType, RoleIndexPermissionView } from '../../../types'; +import { Action, RoleIndexPermissionView } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { renderFieldLevelSecurity, renderRowExpanstionArrow, diff --git a/public/apps/configuration/panels/role-view/test/role-view.test.tsx b/public/apps/configuration/panels/role-view/test/role-view.test.tsx index d793172ca..424154348 100644 --- a/public/apps/configuration/panels/role-view/test/role-view.test.tsx +++ b/public/apps/configuration/panels/role-view/test/role-view.test.tsx @@ -30,7 +30,8 @@ import { getRoleDetail } from '../../../utils/role-detail-utils'; import { transformRoleIndexPermissions } from '../../../utils/index-permission-utils'; import { useDeleteConfirmState } from '../../../utils/delete-confirm-modal-utils'; import { requestDeleteRoles } from '../../../utils/role-list-utils'; -import { Action, ResourceType, SubAction } from '../../../types'; +import { Action, SubAction } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { buildHashUrl } from '../../../utils/url-builder'; import { createUnknownErrorToast } from '../../../utils/toast-utils'; diff --git a/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx b/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx index 75cd9452e..5f5bb933d 100644 --- a/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx @@ -18,7 +18,8 @@ import { mount, shallow } from 'enzyme'; import { TenantsPanel } from '../tenants-panel'; import { EuiEmptyPrompt, EuiInMemoryTable, EuiTableFieldDataColumnType } from '@elastic/eui'; import { buildHashUrl } from '../../../utils/url-builder'; -import { Action, ResourceType, RoleTenantPermissionDetail } from '../../../types'; +import { Action, RoleTenantPermissionDetail } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { RoleViewTenantInvalidText } from '../../../constants'; jest.mock('../../../utils/tenant-utils'); diff --git a/public/apps/configuration/panels/tenant-list/manage_tab.tsx b/public/apps/configuration/panels/tenant-list/manage_tab.tsx index 8f813f82b..b235bd3ba 100644 --- a/public/apps/configuration/panels/tenant-list/manage_tab.tsx +++ b/public/apps/configuration/panels/tenant-list/manage_tab.tsx @@ -39,10 +39,10 @@ import React, { ReactNode, useState, useCallback } from 'react'; import { difference } from 'lodash'; import { HashRouter as Router, Route } from 'react-router-dom'; import { flow } from 'lodash'; -import { TenancyConfigSettings } from '../tenancy-config/types'; import { getCurrentUser } from '../../../../utils/auth-info-utils'; import { AppDependencies } from '../../../types'; -import { Action, ResourceType, Tenant } from '../../types'; +import { Action, Tenant } from '../../types'; +import { ResourceType } from '../../../../../common'; import { ExternalLink, renderCustomization, tableItemsUIProps } from '../../utils/display-utils'; import { fetchTenants, @@ -481,8 +481,7 @@ export function ManageTab(props: AppDependencies) { return ( <> {/*{tenancyDisabledWarning}*/} - - + diff --git a/public/apps/configuration/panels/test/get-started.test.tsx b/public/apps/configuration/panels/test/get-started.test.tsx index a3eb65bf1..e51af78f0 100644 --- a/public/apps/configuration/panels/test/get-started.test.tsx +++ b/public/apps/configuration/panels/test/get-started.test.tsx @@ -16,7 +16,8 @@ import { shallow } from 'enzyme'; import React from 'react'; import { EuiSteps } from '@elastic/eui'; -import { Action, ResourceType } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { buildHashUrl } from '../../utils/url-builder'; import { GetStarted } from '../get-started'; diff --git a/public/apps/configuration/panels/test/role-list.test.tsx b/public/apps/configuration/panels/test/role-list.test.tsx index 445cdac43..a70dac666 100644 --- a/public/apps/configuration/panels/test/role-list.test.tsx +++ b/public/apps/configuration/panels/test/role-list.test.tsx @@ -18,7 +18,8 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; import { EuiInMemoryTable, EuiTableFieldDataColumnType } from '@elastic/eui'; import { buildHashUrl } from '../../utils/url-builder'; -import { Action, ResourceType } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { RoleListing } from '../../utils/role-list-utils'; import { useDeleteConfirmState } from '../../utils/delete-confirm-modal-utils'; diff --git a/public/apps/configuration/panels/test/user-list.test.tsx b/public/apps/configuration/panels/test/user-list.test.tsx index fd28e74cf..32455fa53 100644 --- a/public/apps/configuration/panels/test/user-list.test.tsx +++ b/public/apps/configuration/panels/test/user-list.test.tsx @@ -40,7 +40,8 @@ jest.mock('../../utils/context-menu', () => ({ import { getAuthInfo } from '../../../../utils/auth-info-utils'; import { buildHashUrl } from '../../utils/url-builder'; -import { ResourceType, Action } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; describe('User list', () => { describe('dictView', () => { diff --git a/public/apps/configuration/panels/user-list.tsx b/public/apps/configuration/panels/user-list.tsx index 8cb627f8b..b75f5c1ff 100644 --- a/public/apps/configuration/panels/user-list.tsx +++ b/public/apps/configuration/panels/user-list.tsx @@ -35,7 +35,8 @@ import React, { useState } from 'react'; import { getAuthInfo } from '../../../utils/auth-info-utils'; import { AppDependencies } from '../../types'; import { API_ENDPOINT_INTERNALUSERS, DocLinks } from '../constants'; -import { Action, ResourceType } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { EMPTY_FIELD_VALUE } from '../ui-constants'; import { useContextMenuState } from '../utils/context-menu'; import { useDeleteConfirmState } from '../utils/delete-confirm-modal-utils'; diff --git a/public/apps/configuration/types.ts b/public/apps/configuration/types.ts index 06ef44369..967072d18 100644 --- a/public/apps/configuration/types.ts +++ b/public/apps/configuration/types.ts @@ -19,17 +19,6 @@ export type ComboBoxOptions = EuiComboBoxOptionOption[]; export type FieldLevelSecurityMethod = 'exclude' | 'include'; -export enum ResourceType { - roles = 'roles', - users = 'users', - permissions = 'permissions', - tenants = 'tenants', - tenantsManageTab = 'tenantsManageTab', - tenantsConfigureTab = 'tenantsConfigureTab', - auth = 'auth', - auditLogging = 'auditLogging', -} - export enum Action { view = 'view', create = 'create', diff --git a/public/apps/configuration/utils/url-builder.tsx b/public/apps/configuration/utils/url-builder.tsx index 5337f627d..e15aa7975 100644 --- a/public/apps/configuration/utils/url-builder.tsx +++ b/public/apps/configuration/utils/url-builder.tsx @@ -13,7 +13,8 @@ * permissions and limitations under the License. */ -import { ResourceType, Action } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; /** * Build hash based url, encode the resourceId part