Skip to content

Commit

Permalink
Use formatUrlWithWorkspaceId to foramt inAppURL for saved objects page
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Oct 17, 2023
1 parent 2308c6d commit d5d3d4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('Table', () => {
const table = component.find('EuiBasicTable');
const columns = table.prop('columns') as any[];
const content = columns[1].render('My-Dashboard-test', item);
expect(content.props.href).toEqual('/w/ws-1/app/dashboards#/view/dashboard-1');
expect(content.props.href).toEqual('http://localhost/w/ws-1/app/dashboards#/view/dashboard-1');
});

it('should handle query parse error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
SavedObjectsManagementAction,
SavedObjectsManagementColumnServiceStart,
} from '../../../services';
import { WORKSPACE_PATH_PREFIX } from '../../../../../../core/public/utils';
import { formatUrlWithWorkspaceId } from '../../../../../../core/public/utils';

export interface TableProps {
basePath: IBasePath;
Expand Down Expand Up @@ -231,21 +231,20 @@ export class Table extends PureComponent<TableProps, TableState> {
sortable: false,
'data-test-subj': 'savedObjectsTableRowTitle',
render: (title: string, object: SavedObjectWithMetadata) => {
let { path = '' } = object.meta.inAppUrl || {};
const { path = '' } = object.meta.inAppUrl || {};
const canGoInApp = this.props.canGoInApp(object);
if (!canGoInApp) {
return <EuiText size="s">{title || getDefaultTitle(object)}</EuiText>;
}
let inAppUrl = basePath.prepend(path);
if (object.workspaces?.length) {
// first workspace login user have permission
const [workspaceId] = object.workspaces.filter((wsId) => visibleWsIds.includes(wsId));
path = workspaceId ? `${WORKSPACE_PATH_PREFIX}/${workspaceId}${path}` : path;
if (workspaceId) {
inAppUrl = formatUrlWithWorkspaceId(path, workspaceId, basePath);
}
}
return (
<EuiLink href={basePath.prepend(path, { withoutWorkspace: true })}>
{title || getDefaultTitle(object)}
</EuiLink>
);
return <EuiLink href={inAppUrl}>{title || getDefaultTitle(object)}</EuiLink>;
},
} as EuiTableFieldDataColumnType<SavedObjectWithMetadata<any>>,
{
Expand Down

0 comments on commit d5d3d4f

Please sign in to comment.