Skip to content

Commit

Permalink
fix: [SIG-542]: handle special characters in servicename (#4649)
Browse files Browse the repository at this point in the history
* fix: [SIG-542]: handle special characters in servicename

* feat: handle . operator in the URL

* chore: left files to update
  • Loading branch information
vikrantgupta25 committed Mar 7, 2024
1 parent c842e68 commit 7051831
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 16 deletions.
4 changes: 3 additions & 1 deletion frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import {
} from './util';

function DBCall(): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();

const servicename = decodeURIComponent(encodedServiceName);
const [selectedTimeStamp, setSelectedTimeStamp] = useState<number>(0);
const { queries } = useResourceAttribute();

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/container/MetricsApplication/Tabs/External.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import {
function External(): JSX.Element {
const [selectedTimeStamp, setSelectedTimeStamp] = useState<number>(0);

const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();

const servicename = decodeURIComponent(encodedServiceName);
const { queries } = useResourceAttribute();

const tagFilterItems = useMemo(
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/container/MetricsApplication/Tabs/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ function Application(): JSX.Element {
const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
);
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);
const [selectedTimeStamp, setSelectedTimeStamp] = useState<number>(0);
const { search, pathname } = useLocation();
const { queries } = useResourceAttribute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function ApDexMetrics({
topLevelOperationsRoute,
handleGraphClick,
}: ApDexMetricsProps): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const apDexMetricsWidget = useMemo(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function ApDexMetricsApplication({
thresholdValue,
topLevelOperationsRoute,
}: ApDexDataSwitcherProps): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const { data, isLoading, error } = useGetMetricMeta(metricMeta, servicename);
useErrorNotification(error);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function ApDexTraces({
tagFilterItems,
thresholdValue,
}: ApDexDataSwitcherProps): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const apDexTracesWidget = useMemo(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function ApDexApplication({
topLevelOperationsRoute,
tagFilterItems,
}: ApDexApplicationProps): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const { data, isLoading, error, isRefetching } = useGetApDexSettings(
servicename,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function ServiceOverview({
topLevelOperationsRoute,
topLevelOperationsIsLoading,
}: ServiceOverviewProps): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const isSpanMetricEnable = useFeatureFlag(FeatureKeys.USE_SPAN_METRICS)
?.active;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ function TopOperation(): JSX.Element {
const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
);
const { servicename } = useParams<{ servicename?: string }>();
const { servicename: encodedServiceName } = useParams<{
servicename?: string;
}>();
const servicename = decodeURIComponent(encodedServiceName || '');

const { queries } = useResourceAttribute();
const selectedTags = useMemo(
() => (convertRawQueriesToTraceSelectedTags(queries) as Tags[]) || [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import ColumnWithLink from './TableRenderer/ColumnWithLink';
import { getTableColumnRenderer } from './TableRenderer/TableColumnRenderer';

function TopOperationMetrics(): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const { notifications } = useNotifications();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function TopOperationsTable({
isLoading,
}: TopOperationsTableProps): JSX.Element {
const searchInput = useRef<InputRef>(null);
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();

const servicename = decodeURIComponent(encodedServiceName);
const { minTime, maxTime } = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
);
Expand All @@ -39,7 +41,8 @@ function TopOperationsTable({
const params = useParams<{ servicename: string }>();

const handleOnClick = (operation: string): void => {
const { servicename } = params;
const { servicename: encodedServiceName } = params;
const servicename = decodeURIComponent(encodedServiceName);

navigateToTrace({
servicename,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/container/QueryTable/QueryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export function QueryTable({
...props
}: QueryTableProps): JSX.Element {
const { isDownloadEnabled = false, fileName = '' } = downloadOption || {};
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);
const { loading } = props;
const { columns: newColumns, dataSource: newDataSource } = useMemo(() => {
if (columns && dataSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { Button } from '../styles';
import ApDexSettings from './ApDexSettings';

function ApDexApplication(): JSX.Element {
const { servicename } = useParams<IServiceName>();
const { servicename: encodedServiceName } = useParams<IServiceName>();
const servicename = decodeURIComponent(encodedServiceName);

const {
data,
isLoading,
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/pages/MetricsApplication/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { MetricsApplicationTab, TAB_KEY_VS_LABEL } from './types';
import useMetricsApplicationTabKey from './useMetricsApplicationTabKey';

function MetricsApplication(): JSX.Element {
const { servicename } = useParams<{ servicename: string }>();
const { servicename: encodedServiceName } = useParams<{
servicename: string;
}>();

const servicename = decodeURIComponent(encodedServiceName);

const activeKey = useMetricsApplicationTabKey();

Expand Down
4 changes: 3 additions & 1 deletion frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const config = {
devtool: 'source-map',
entry: resolve(__dirname, './src/index.tsx'),
devServer: {
historyApiFallback: true,
historyApiFallback: {
disableDotRule: true,
},
open: true,
hot: true,
liveReload: true,
Expand Down

0 comments on commit 7051831

Please sign in to comment.