Skip to content
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

Refactor association table in create page #4

Draft
wants to merge 3 commits into
base: 2.17/support-DQC
Choose a base branch
from

Conversation

Kapian1234
Copy link

@Kapian1234 Kapian1234 commented Aug 28, 2024

Description

Issues Resolved

Screenshot

Testing the changes

Changelog

  • skip

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Kapian1234 <wanjinch@amazon.com>
@Kapian1234 Kapian1234 marked this pull request as draft August 28, 2024 08:52
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
@Kapian1234 Kapian1234 marked this pull request as ready for review August 29, 2024 05:46
@Kapian1234 Kapian1234 marked this pull request as draft August 29, 2024 05:57
@@ -81,7 +81,7 @@ export interface AssociationDataSourceModalProps {
savedObjects: SavedObjectsStart;
assignedConnections: DataSourceConnection[];
closeModal: () => void;
handleAssignDataSourceConnections: (connections: DataSourceConnection[]) => Promise<void>;
handleAssignDataSourceConnections: (connections: DataSourceConnection[]) => Promise<void> | void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my perspective, can remove Promise<void>?

Copy link
Author

@Kapian1234 Kapian1234 Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const handleAssignDataSourceConnections = async ( in detail page may need this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try to remove it. The type should work fine. Because we doesn't await handleAssignDataSourceConnections inside modal component.

@@ -48,7 +48,7 @@ export const WorkspaceForm = (props: WorkspaceFormProps) => {
const disabledUserOrGroupInputIdsRef = useRef(
defaultValues?.permissionSettings?.map((item) => item.id) ?? []
);
const isDashboardAdmin = application?.capabilities?.dashboards?.isDashboardAdmin ?? false;
const isDashboardAdmin = !!application?.capabilities?.dashboards?.isDashboardAdmin;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to change this?

Copy link
Author

@Kapian1234 Kapian1234 Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will throw an error "Type 'true | Readonly<{ [x: string]: boolean; }>' is not assignable to type 'boolean'.
Type 'Readonly<{ [x: string]: boolean; }>' is not assignable to type 'boolean'. " if we don't change this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to pass it to other component anymore. So I think we can remove this change.

data-test-subj={`workspaceForm-dataSourcePanel`}
isDashboardAdmin={isDashboardAdmin}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDashboardAdmin will always be true here, why we need to pass it from outside?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! it should be true

@@ -49,7 +49,7 @@ export const useWorkspaceForm = ({
Array<Pick<WorkspacePermissionSetting, 'id'> & Partial<WorkspacePermissionSetting>>
>(initialPermissionSettingsRef.current);

const [selectedDataSources, setSelectedDataSources] = useState<DataSource[]>(
const [selectedDataSources, setSelectedDataSources] = useState<DataSourceConnection[]>(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep using DataSource[] as data type here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't find related changes in that branch, can you paste me the code line by URL?

Copy link
Author

@Kapian1234 Kapian1234 Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies, I made a mistake.
WorkspaceForm would get selectedDataSources and setSelectedDataSources, then pass them to SelectDataSourcePanel. SelectDataSourcePanel would need them
https://github.com/Kapian1234/OpenSearch-Dashboards/blob/f22c7ac958ec5835c44a45e3447bd32d6b29b45b/src/plugins/workspace/public/components/workspace_form/select_data_source_panel.tsx#L28

handleUnassignDataSources: (dataSources: DataSourceConnection[]) => Promise<void>;
inCreatePage?: boolean;
handleUnassignDataSources: (dataSources: DataSourceConnection[]) => Promise<void> | void;
getSelectedItems?: (dataSources: DataSourceConnection[]) => void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer rename to onSelectedItemsChange

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

{isDashboardAdmin && <EuiFlexItem grow={false}>{associationButton}</EuiFlexItem>}
</EuiFlexGroup>
<EuiSpacer size="xs" />
<EuiFlexItem style={{ maxWidth: 800 }}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the maxWidth was 768 in design.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

const handleAssignDataSources = (dataSources: DataSourceConnection[]) => {
setModalVisible(false);
const savedDataSources: DataSourceConnection[] = [...assignedDataSources, ...dataSources];
onChange(savedDataSources);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this onChange, the selected DQC won't be displayed. How do we support this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the table already supported it by getting relatedConnections from datasources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants