Skip to content

Commit

Permalink
[frontend] fix missing base path in publicdashboard link
Browse files Browse the repository at this point in the history
  • Loading branch information
marieflorescontact committed Nov 19, 2024
1 parent d3a85de commit b31435a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { ContentCopy, Delete, DoNotDisturbAlt, Done, ReportGmailerrorred } from
import { useTheme } from '@mui/styles';
import { useFormatter } from '../../../components/i18n';
import type { Theme } from '../../../components/Theme';
import { copyToClipboard } from '../../../utils/utils';
import ItemMarkings from '../../../components/ItemMarkings';
import ItemBoolean from '../../../components/ItemBoolean';
import useAuth from '../../../utils/hooks/useAuth';
import { copyPublicLinkUrl } from '../../../utils/dashboard';

export const workspaceShareListQuery = graphql`
query WorkspaceShareListQuery($filters: FilterGroup) {
Expand Down Expand Up @@ -57,13 +57,6 @@ const WorkspaceShareList = ({ queryRef, onDelete, onToggleEnabled }: WorkspaceSh
.map((edge) => edge.node)
.sort((a, b) => a.created_at.localeCompare(b.created_at));

const copyLinkUrl = (uriKey: string) => {
copyToClipboard(
t_i18n,
`${window.location.origin}/public/dashboard/${uriKey.toLowerCase()}`,
);
};

if (!dashboards || dashboards.length === 0) {
return <p>{t_i18n('No public dashboard created yet')}</p>;
}
Expand Down Expand Up @@ -114,7 +107,7 @@ const WorkspaceShareList = ({ queryRef, onDelete, onToggleEnabled }: WorkspaceSh
aria-label="Label"
size="small"
value="copy-link"
onClick={() => copyLinkUrl(dashboard.uri_key)}
onClick={() => copyPublicLinkUrl(t_i18n, dashboard.uri_key)}
>
<ContentCopy fontSize="small" color="primary" />
</ToggleButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { useNavigate } from 'react-router-dom';
import { graphql } from 'react-relay';
import { PublicDashboardsListQuery$variables } from '@components/workspaces/dashboards/public_dashboards/__generated__/PublicDashboardsListQuery.graphql';
import { useFormatter } from '../../../../../components/i18n';
import { copyToClipboard } from '../../../../../utils/utils';
import useApiMutation from '../../../../../utils/hooks/useApiMutation';
import useDeletion from '../../../../../utils/hooks/useDeletion';
import DeleteDialog from '../../../../../components/DeleteDialog';
import { EXPLORE_EXUPDATE_PUBLISH } from '../../../../../utils/hooks/useGranted';
import Security from '../../../../../utils/Security';
import { useGetCurrentUserAccessRight } from '../../../../../utils/authorizedMembers';
import { deleteNode } from '../../../../../utils/store';
import { copyPublicLinkUrl } from '../../../../../utils/dashboard';

interface PublicDashboardLineActionsProps {
publicDashboard: PublicDashboards_PublicDashboard$data
Expand Down Expand Up @@ -47,10 +47,7 @@ const PublicDashboardLineActions = ({ publicDashboard, paginationOptions }: Publ
const { canManage } = useGetCurrentUserAccessRight(publicDashboard.dashboard.currentUserAccessRight);

const copyLinkUrl = () => {
copyToClipboard(
t_i18n,
`${window.location.origin}/public/dashboard/${publicDashboard.uri_key.toLowerCase()}`,
);
copyPublicLinkUrl(t_i18n, publicDashboard.uri_key);
setAnchor(undefined);
};

Expand Down
9 changes: 9 additions & 0 deletions opencti-platform/opencti-front/src/utils/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { FilterGroup } from './filters/filtersHelpers-types';
import { copyToClipboard } from './utils';
import { APP_BASE_PATH } from '../relay/environment';

export interface DashboardWidgetDataSelection {
label?: string
Expand All @@ -19,3 +21,10 @@ export interface DashboardWidgetParameters {
legend?: boolean
distributed?: boolean
}

export const copyPublicLinkUrl = (t: (text: string) => string, uriKey: string) => {
copyToClipboard(
t,
`${window.location.origin}${APP_BASE_PATH}/public/dashboard/${uriKey.toLowerCase()}`,
);
};

0 comments on commit b31435a

Please sign in to comment.