-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Workspace]Remove collaborators in workspace creation page and refactor with getDisplayedType #8520
Changes from 7 commits
60ea375
c9bb7f6
2d601c7
b8b979e
00b8a77
de863cb
1b4a08b
69c9794
9f96825
4750e3e
f858f71
8255e82
471c2a6
8e852af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- [Workspace]Remove collaborators in workspace creation page ([#8520](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8520)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,18 +10,15 @@ import { BehaviorSubject } from 'rxjs'; | |
|
||
import { useLocation } from 'react-router-dom'; | ||
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public'; | ||
import { WorkspaceFormSubmitData, WorkspaceOperationType } from '../workspace_form'; | ||
import { WORKSPACE_DETAIL_APP_ID } from '../../../common/constants'; | ||
import { WorkspaceFormSubmitData, WorkspaceOperationType, DetailTab } from '../workspace_form'; | ||
import { getUseCaseFeatureConfig } from '../../../common/utils'; | ||
import { formatUrlWithWorkspaceId } from '../../../../../core/public/utils'; | ||
import { WorkspaceClient } from '../../workspace_client'; | ||
import { convertPermissionSettingsToPermissions } from '../workspace_form'; | ||
import { DataSourceManagementPluginSetup } from '../../../../../plugins/data_source_management/public'; | ||
import { WorkspaceUseCase } from '../../types'; | ||
import { getFirstUseCaseOfFeatureConfigs } from '../../utils'; | ||
import { useFormAvailableUseCases } from '../workspace_form/use_form_available_use_cases'; | ||
import { NavigationPublicPluginStart } from '../../../../../plugins/navigation/public'; | ||
import { DataSourceConnectionType } from '../../../common/types'; | ||
import { navigateToWorkspaceDetail } from '../utils/workspace'; | ||
import { WorkspaceCreatorForm } from './workspace_creator_form'; | ||
|
||
export interface WorkspaceCreatorProps { | ||
|
@@ -47,7 +44,6 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { | |
}>(); | ||
const [isFormSubmitting, setIsFormSubmitting] = useState(false); | ||
|
||
const isPermissionEnabled = application?.capabilities.workspaces.permissionEnabled; | ||
const { isOnlyAllowEssential, availableUseCases } = useFormAvailableUseCases({ | ||
savedObjects, | ||
registeredUseCases$, | ||
|
@@ -102,7 +98,6 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { | |
result = await workspaceClient.create(attributes, { | ||
dataSources: selectedDataSourceIds, | ||
dataConnections: selectedDataConnectionIds, | ||
permissions: convertPermissionSettingsToPermissions(permissionSettings), | ||
}); | ||
if (result?.success) { | ||
notifications?.toasts.addSuccess({ | ||
|
@@ -112,17 +107,12 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { | |
}); | ||
if (application && http) { | ||
const newWorkspaceId = result.result.id; | ||
const useCaseId = getFirstUseCaseOfFeatureConfigs(attributes.features); | ||
const useCaseLandingAppId = availableUseCases?.find(({ id }) => useCaseId === id) | ||
?.features[0].id; | ||
// Redirect page after one second, leave one second time to show create successful toast. | ||
window.setTimeout(() => { | ||
window.location.href = formatUrlWithWorkspaceId( | ||
application.getUrlForApp(useCaseLandingAppId || WORKSPACE_DETAIL_APP_ID, { | ||
absolute: true, | ||
}), | ||
navigateToWorkspaceDetail( | ||
{ application, http }, | ||
newWorkspaceId, | ||
http.basePath | ||
DetailTab.Collaborators | ||
); | ||
}, 1000); | ||
} | ||
|
@@ -142,7 +132,7 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { | |
setIsFormSubmitting(false); | ||
} | ||
}, | ||
[notifications?.toasts, http, application, workspaceClient, isFormSubmitting, availableUseCases] | ||
[notifications?.toasts, http, application, workspaceClient, isFormSubmitting] | ||
); | ||
|
||
const isFormReadyToRender = | ||
|
@@ -177,7 +167,7 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { | |
savedObjects={savedObjects} | ||
onSubmit={handleWorkspaceFormSubmit} | ||
operationType={WorkspaceOperationType.Create} | ||
permissionEnabled={isPermissionEnabled} | ||
permissionEnabled={false} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this props instead of giving false. I think this permissionEnabled props is not needed any more right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, let's remove the permissionEnabled property. I met a unit tests failed without this property before. But seems all the unit tests can be passed now. Let me remove this property. |
||
dataSourceManagement={dataSourceManagement} | ||
availableUseCases={availableUseCases} | ||
defaultValues={defaultWorkspaceFormValues} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to check permission enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I think we should check this. Let me add a fallback logic here.