-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cockpit-links) refactor into a common react
- Loading branch information
1 parent
000d3c0
commit f2e5709
Showing
8 changed files
with
153 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
client/src/plugins/camunda-plugin/shared/ui/CockpitDeploymentLink.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
import React, { useMemo } from 'react'; | ||
|
||
import CockpitLink from './CockpitLink'; | ||
|
||
export default function CockpitDeploymentLink(props) { | ||
const { | ||
engineRestUrl, | ||
deployment | ||
} = props; | ||
|
||
const { | ||
id, | ||
deployedProcessDefinition | ||
} = deployment; | ||
|
||
const cockpitPath = useMemo(() => `/repository/?deploymentsQuery=%5B%7B%22type%22:%22id%22,%22operator%22:%22eq%22,%22value%22:%22${id}%22%7D%5D`, [ id ]); | ||
|
||
return ( | ||
<CockpitLink engineRestUrl={ engineRestUrl } cockpitPath={ cockpitPath }> | ||
{ | ||
deployedProcessDefinition | ||
? ( | ||
<div> | ||
Process definition ID: | ||
<code>{deployedProcessDefinition.id} </code> | ||
</div> | ||
) | ||
: null | ||
} | ||
</CockpitLink> | ||
); | ||
} |
54 changes: 54 additions & 0 deletions
54
client/src/plugins/camunda-plugin/shared/ui/CockpitLink.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
import React, { Children, useMemo } from 'react'; | ||
|
||
import * as css from './CockpitLink.less'; | ||
|
||
export default function CockpitLink(props) { | ||
const { | ||
engineRestUrl, | ||
cockpitPath, | ||
children | ||
} = props; | ||
|
||
const cockpitBaseUrl = useMemo(() => { | ||
|
||
// TODO Integrate well known endpoint base url for Camunda Web Apps | ||
const webAppsBaseUrl = getWebAppsBaseUrl(engineRestUrl); | ||
|
||
// TODO ensure a single slash between base url and relative path segment | ||
return webAppsBaseUrl + '/cockpit/default/#'; | ||
}, [ engineRestUrl ]); | ||
|
||
// TODO ensure a single slash between base url and relative path segment | ||
const link = useMemo(() => `${cockpitBaseUrl}${cockpitPath}`); | ||
|
||
return ( | ||
<div className={ css.CockpitLink }> | ||
{ Children.toArray(children) } | ||
<a href={ link }> | ||
Open in Camunda Cockpit | ||
</a> | ||
</div> | ||
); | ||
} | ||
|
||
// helpers ////////// | ||
|
||
function getWebAppsBaseUrl(url) { | ||
const [ protocol,, host, restRoot ] = url.split('/'); | ||
|
||
return isTomcat(restRoot) ? `${protocol}//${host}/camunda/app` : `${protocol}//${host}/app`; | ||
} | ||
|
||
function isTomcat(restRoot) { | ||
return restRoot === 'engine-rest'; | ||
} |
15 changes: 15 additions & 0 deletions
15
client/src/plugins/camunda-plugin/shared/ui/CockpitLink.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
:local(.CockpitLink) { | ||
|
||
& > div { | ||
margin-bottom: 5px; | ||
} | ||
|
||
code { | ||
user-select: text; | ||
padding-right: 8px; | ||
margin-left: 2px; | ||
background-color: var(--color-grey-225-10-90); | ||
word-break: break-all; | ||
border-radius: 3px; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
client/src/plugins/camunda-plugin/shared/ui/CockpitProcessInstanceLink.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. | ||
* | ||
* Camunda licenses this file to you under the MIT; you may not use this file | ||
* except in compliance with the MIT License. | ||
*/ | ||
|
||
import React, { useMemo } from 'react'; | ||
|
||
import CockpitLink from './CockpitLink'; | ||
|
||
export default function CockpitProcessInstanceLink(props) { | ||
const { | ||
engineRestUrl, | ||
processInstance | ||
} = props; | ||
|
||
const { | ||
id | ||
} = processInstance; | ||
|
||
const cockpitPath = useMemo(() => `/process-instance/${id}`, [ id ]); | ||
|
||
return ( | ||
<CockpitLink engineRestUrl={ engineRestUrl } cockpitPath={ cockpitPath }> | ||
<div> | ||
Process instance ID: | ||
<code>{id}</code> | ||
</div> | ||
</CockpitLink> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters