Skip to content

Commit

Permalink
resolve some issues
Browse files Browse the repository at this point in the history
Signed-off-by: Kapian1234 <[email protected]>
  • Loading branch information
Kapian1234 committed Sep 4, 2024
1 parent 2b4362a commit 64363b4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const WorkspaceCreatorForm = (props: WorkspaceCreatorFormProps) => {
savedObjects={savedObjects}
assignedDataSources={formData.selectedDataSources}
data-test-subj={`workspaceForm-dataSourcePanel`}
isDashboardAdmin={true}
showDataSourceManagement={true}
/>
<EuiSpacer size="s" />
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ const dataSourceConnectionsMock = [

describe('WorkspaceDetailConnectionTable', () => {
beforeEach(() => {
const mockPrepend = jest.fn().mockImplementation((path) => path);
const mockHttp = {
basePath: {
serverBasePath: '',
prepend: mockPrepend,
},
};
(useOpenSearchDashboards as jest.Mock).mockImplementation(() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ export const DataSourceConnectionTable = ({
const basePath = http.basePath.serverBasePath;
let url: string;
if (record.connectionType === DataSourceConnectionType.OpenSearchConnection) {
url = `${origin}${basePath}/app/dataSources/${record.id}`;
url = http.basePath.prepend(`/app/dataSources/${record.id}`, {
withoutClientBasePath: true,
});
} else {
url = `${origin}${basePath}/app/dataSources/manage/${name}?dataSourceMDSId=${record.parentId}`;
url = http.basePath.prepend(`/app/dataSources/${record.id}`, {
withoutClientBasePath: true,
});
}
return (
<EuiLink href={url} className="eui-textTruncate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const setup = ({
assignedDataSources = [],
onChange = jest.fn(),
errors = undefined,
isDashboardAdmin = true,
showDataSourceManagement = true,
}: Partial<SelectDataSourcePanelProps>) => {
return render(
<I18nProvider>
Expand All @@ -90,7 +90,7 @@ const setup = ({
savedObjects={savedObjects}
assignedDataSources={assignedDataSources}
errors={errors}
isDashboardAdmin={isDashboardAdmin}
showDataSourceManagement={showDataSourceManagement}
/>
</OpenSearchDashboardsContextProvider>
</I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ export interface SelectDataSourcePanelProps {
savedObjects: SavedObjectsStart;
assignedDataSources: DataSource[];
onChange: (value: DataSource[]) => void;
isDashboardAdmin: boolean;
showDataSourceManagement: boolean;
}

export const SelectDataSourcePanel = ({
errors,
onChange,
assignedDataSources,
savedObjects,
isDashboardAdmin,
showDataSourceManagement,
}: SelectDataSourcePanelProps) => {
const [modalVisible, setModalVisible] = useState(false);
const [selectedItems, setSelectedItems] = useState<DataSourceConnection[]>([]);
Expand Down Expand Up @@ -79,7 +78,7 @@ export const SelectDataSourcePanel = ({
return (
<EuiPanel paddingSize="none" hasBorder={false}>
<DataSourceConnectionTable
isDashboardAdmin={isDashboardAdmin}
isDashboardAdmin={showDataSourceManagement}
items={assignedDataSourceConnections}
onUnlinkDataSource={handleSingleDataSourceUnAssign}
connectionType={AssociationDataSourceModalMode.OpenSearchConnections}
Expand Down Expand Up @@ -138,13 +137,13 @@ export const SelectDataSourcePanel = ({
<div>
<EuiSpacer size="m" />
<EuiFlexGroup alignItems="center" gutterSize="s">
{isDashboardAdmin && selectedItems.length > 0 && assignedDataSources.length > 0 && (
{showDataSourceManagement && selectedItems.length > 0 && assignedDataSources.length > 0 && (
<EuiFlexItem grow={false}>{removeButton}</EuiFlexItem>
)}
{isDashboardAdmin && (
{showDataSourceManagement && (
<EuiFlexItem grow={false}>{addOpenSearchConnectionsButton}</EuiFlexItem>
)}
{isDashboardAdmin && (
{showDataSourceManagement && (
<EuiFlexItem grow={false}>{addDirectQueryConnectionsButton}</EuiFlexItem>
)}
</EuiFlexGroup>
Expand All @@ -161,7 +160,7 @@ export const SelectDataSourcePanel = ({
http={http}
mode={toggleIdSelected as AssociationDataSourceModalMode}
notifications={notifications}
logos={chrome?.logos}
logos={chrome.logos}
/>
)}
</div>
Expand Down

0 comments on commit 64363b4

Please sign in to comment.