Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Jun 16, 2021
1 parent 4d921ff commit 412082a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,26 @@ interface AllCasesProps {
export const AllCases = React.memo<AllCasesProps>(({ userCanCrud }) => {
const {
cases: casesUi,
application: { navigateToApp },
application: { getUrlForApp, navigateToUrl },
} = useKibana().services;
const { formatUrl } = useFormatUrl(CASES_APP_ID);

const casesUrl = getUrlForApp(CASES_APP_ID);
return casesUi.getAllCases({
caseDetailsNavigation: {
href: ({ detailName, subCaseId }: AllCasesNavProps) => {
return formatUrl(getCaseDetailsUrl({ id: detailName, subCaseId }));
},
onClick: async ({ detailName, subCaseId, search }: AllCasesNavProps) =>
navigateToApp(`${CASES_APP_ID}`, {
path: getCaseDetailsUrl({ id: detailName, subCaseId }),
}),
navigateToUrl(`${casesUrl}${getCaseDetailsUrl({ id: detailName, subCaseId })}`),
},
configureCasesNavigation: {
href: formatUrl(getConfigureCasesUrl()),
onClick: async (ev) => {
if (ev != null) {
ev.preventDefault();
}
return navigateToApp(`${CASES_APP_ID}`, {
path: getConfigureCasesUrl(),
});
return navigateToUrl(`${casesUrl}${getConfigureCasesUrl()}`);
},
},
createCaseNavigation: {
Expand All @@ -59,9 +56,7 @@ export const AllCases = React.memo<AllCasesProps>(({ userCanCrud }) => {
if (ev != null) {
ev.preventDefault();
}
return navigateToApp(`${CASES_APP_ID}`, {
path: getCreateCaseUrl(),
});
return navigateToUrl(`${casesUrl}${getCreateCaseUrl()}`);
},
},
disableAlerts: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export interface CaseProps extends Props {
export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {
const [caseTitle, setCaseTitle] = useState<string | null>(null);

const { cases: casesUi, application } = useKibana().services;
const { navigateToApp } = application;
const {
cases: casesUi,
application: { getUrlForApp, navigateToUrl },
} = useKibana().services;
const allCasesLink = getCaseUrl();
const { formatUrl } = useFormatUrl(CASES_APP_ID);
const href = formatUrl(allCasesLink);
Expand Down Expand Up @@ -78,16 +80,15 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) =
[caseId, formatUrl, subCaseId]
);

const casesUrl = getUrlForApp(CASES_APP_ID);
return casesUi.getCaseView({
allCasesNavigation: {
href: allCasesHref,
onClick: async (ev) => {
if (ev != null) {
ev.preventDefault();
}
return navigateToApp(`${CASES_APP_ID}`, {
path: allCasesLink,
});
return navigateToUrl(casesUrl);
},
},
caseDetailsNavigation: {
Expand All @@ -96,9 +97,7 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) =
if (ev != null) {
ev.preventDefault();
}
return navigateToApp(`${CASES_APP_ID}`, {
path: getCaseDetailsUrl({ id: caseId }),
});
return navigateToUrl(`${casesUrl}${getCaseDetailsUrl({ id: caseId })}`);
},
},
caseId,
Expand All @@ -108,9 +107,7 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) =
if (ev != null) {
ev.preventDefault();
}
return navigateToApp(`${CASES_APP_ID}`, {
path: configureCasesLink,
});
return navigateToUrl(`${casesUrl}${configureCasesLink}`);
},
},
getCaseDetailHrefWithCommentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ import { CASES_APP_ID, CASES_OWNER } from '../constants';
export const Create = React.memo(() => {
const {
cases,
application: { navigateToApp },
application: { getUrlForApp, navigateToUrl },
} = useKibana().services;
const casesUrl = getUrlForApp(CASES_APP_ID);
const onSuccess = useCallback(
async ({ id }) =>
navigateToApp(`${CASES_APP_ID}`, {
path: getCaseDetailsUrl({ id }),
}),
[navigateToApp]
async ({ id }) => navigateToUrl(`${casesUrl}${getCaseDetailsUrl({ id })}`),
[casesUrl, navigateToUrl]
);

const handleSetIsCancel = useCallback(() => navigateToApp(`${CASES_APP_ID}`), [navigateToApp]);
const handleSetIsCancel = useCallback(() => navigateToUrl(`${casesUrl}`), [
casesUrl,
navigateToUrl,
]);

return (
<EuiPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import { CaseCallOut, permissionsReadOnlyErrorMessage } from '../../components/a

export const CaseDetailsPage = React.memo(() => {
const {
application: { navigateToApp },
application: { getUrlForApp, navigateToUrl },
} = useKibana().services;
const userPermissions = useGetUserCasesPermissions();
const { detailName: caseId, subCaseId } = useParams<{
detailName?: string;
subCaseId?: string;
}>();

const casesUrl = getUrlForApp(CASES_APP_ID);
if (userPermissions != null && !userPermissions.read) {
navigateToApp(`${CASES_APP_ID}`);
navigateToUrl(casesUrl);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@ const ButtonEmpty = styled(EuiButtonEmpty)`
function ConfigureCasesPageComponent() {
const {
cases,
application: { navigateToApp },
application: { getUrlForApp, navigateToUrl },
} = useKibana().services;
const casesUrl = getUrlForApp(CASES_APP_ID);
const userPermissions = useGetUserCasesPermissions();
const { ObservabilityPageTemplate } = usePluginContext();
const onClickGoToCases = useCallback(
async (ev) => {
ev.preventDefault();
return navigateToApp(`${CASES_APP_ID}`);
return navigateToUrl(casesUrl);
},
[navigateToApp]
[casesUrl, navigateToUrl]
);
const { formatUrl } = useFormatUrl(CASES_APP_ID);
const href = formatUrl(getCaseUrl());
useBreadcrumbs([{ ...casesBreadcrumbs.cases, href }, casesBreadcrumbs.configure]);
if (userPermissions != null && !userPermissions.read) {
navigateToApp(`${CASES_APP_ID}`);
navigateToUrl(casesUrl);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ export const CreateCasePage = React.memo(() => {
const userPermissions = useGetUserCasesPermissions();
const { ObservabilityPageTemplate } = usePluginContext();
const {
application: { navigateToApp },
application: { getUrlForApp, navigateToUrl },
} = useKibana().services;

const casesUrl = getUrlForApp(CASES_APP_ID);
const goTo = useCallback(
async (ev) => {
ev.preventDefault();
return navigateToApp(CASES_APP_ID);
return navigateToUrl(casesUrl);
},
[navigateToApp]
[casesUrl, navigateToUrl]
);

const { formatUrl } = useFormatUrl(CASES_APP_ID);
const href = formatUrl(getCaseUrl());
useBreadcrumbs([{ ...casesBreadcrumbs.cases, href }, casesBreadcrumbs.create]);
if (userPermissions != null && !userPermissions.crud) {
navigateToApp(`${CASES_APP_ID}`);
navigateToUrl(casesUrl);
return null;
}

Expand Down

0 comments on commit 412082a

Please sign in to comment.