@@ -16,6 +16,7 @@ import { CommonHelpers, SchemaHelpers } from '../../helpers';
1616import { EXTERAL_DOCUMENTATION_TEXT } from '../../constants' ;
1717import { PayloadType , PluginSlot } from '../../types' ;
1818import { PluginManager } from '../../helpers/pluginManager' ;
19+ import { ServersList } from './ServersList' ;
1920import { SlotRenderer } from '../../components/PluginSlotRenderer' ;
2021import { usePlugin } from '../../contexts/usePlugin' ;
2122
@@ -26,6 +27,13 @@ interface Props {
2627 channel : ChannelInterface ;
2728}
2829
30+ // Construct the full relative URL, including path, query parameters to avoid path overwrite when
31+ // location.hash is included
32+ const location = globalThis . location ;
33+ const relativePathname = location
34+ ? `${ location . pathname } ${ location . search } `
35+ : '' ;
36+
2937export const Operation : React . FunctionComponent < Props > = ( props ) => {
3038 const { type = PayloadType . SEND , operation, channelName, channel } = props ;
3139 const config = useConfig ( ) ;
@@ -43,31 +51,16 @@ export const Operation: React.FunctionComponent<Props> = (props) => {
4351 channel . parameters ( ) !== undefined
4452 ? SchemaHelpers . parametersToSchema ( channel . parameters ( ) )
4553 : undefined ;
46-
4754 return (
4855 < div >
4956 < div className = "panel-item--center px-8" >
5057 < OperationInfo { ...props } />
51- { servers && servers . length > 0 ? (
52- < div className = "mt-2 text-sm" >
53- < p > Available only on servers:</ p >
54- < ul className = "flex flex-wrap leading-normal" >
55- { servers . map ( ( server ) => (
56- < li className = "inline-block mt-2 mr-2" key = { server . id ( ) } >
57- < a
58- href = { `${ window . location . pathname } #${ CommonHelpers . getIdentifier (
59- 'server-' + server . id ( ) ,
60- config ,
61- ) } `}
62- className = "border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer"
63- >
64- < span className = "underline" > { server . id ( ) } </ span >
65- </ a >
66- </ li >
67- ) ) }
68- </ ul >
69- </ div >
70- ) : null }
58+
59+ < ServersList
60+ servers = { servers || [ ] }
61+ config = { config }
62+ relativePathname = { relativePathname }
63+ />
7164
7265 { parameters && (
7366 < div
@@ -411,26 +404,11 @@ export const OperationReplyChannelInfo: React.FunctionComponent<Props> = ({
411404 < Markdown > { channel . description ( ) } </ Markdown >
412405 </ div >
413406 ) }
414- { servers && servers . length > 0 ? (
415- < div className = "mt-2 text-sm" >
416- < p > Available only on servers:</ p >
417- < ul className = "flex flex-wrap leading-normal" >
418- { servers . map ( ( server ) => (
419- < li className = "inline-block mt-2 mr-2" key = { server . id ( ) } >
420- < a
421- href = { `${ window . location . pathname } #${ CommonHelpers . getIdentifier (
422- 'server-' + server . id ( ) ,
423- config ,
424- ) } `}
425- className = "border border-solid border-blue-300 hover:bg-blue-300 hover:text-blue-600 text-blue-500 font-bold no-underline text-xs rounded px-3 py-1 cursor-pointer"
426- >
427- < span className = "underline" > { server . id ( ) } </ span >
428- </ a >
429- </ li >
430- ) ) }
431- </ ul >
432- </ div >
433- ) : null }
407+ < ServersList
408+ servers = { servers || [ ] }
409+ config = { config }
410+ relativePathname = { relativePathname }
411+ />
434412 { channel . messages ( ) . all ( ) . length > 1 ? (
435413 < div className = "mt-2" >
436414 < span className = "text-xs text-gray-700" > Messages:</ span >
0 commit comments