Skip to content

Commit 49bba07

Browse files
Merge pull request #27 from microsoft/psl-raju-dev
fix: UI - feedback issues and code clean up
2 parents 08cbd5e + 61dc660 commit 49bba07

File tree

26 files changed

+652
-1730
lines changed

26 files changed

+652
-1730
lines changed

src/ContentProcessorWeb/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from "react";
22
import { useEffect } from "react";
33
import Header from "./Components/Header/Header.tsx"; // Import Header
44
import "./Styles/App.css";
5-
import "./Components/Content/Content.css";
65
import HomePage from "./Pages/HomePage.tsx";
76
import DefaultPage from "./Pages/DefaultPage";
87
//import AuxiliaryPage from "./Pages/AuxiliaryPage/AuxiliaryPage.tsx";

src/ContentProcessorWeb/src/Components/Content/Content.css

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/ContentProcessorWeb/src/Components/Content/Content.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/ContentProcessorWeb/src/Components/DialogComponent/DialogComponent.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,8 @@ import {
1010
useId,
1111
} from "@fluentui/react-components";
1212

13-
interface FooterButton {
14-
text: string;
15-
appearance: "primary" | "secondary";
16-
onClick: () => void;
17-
}
13+
import { ConfirmationProps } from './DialogComponentTypes'
1814

19-
interface ConfirmationProps {
20-
title: string;
21-
content: string;
22-
isDialogOpen: boolean; // Controlled state for dialog visibility
23-
onDialogClose: () => void; // Function to close the dialog
24-
footerButtons: FooterButton[]; // Array of footer buttons
25-
}
2615

2716
export const Confirmation: React.FC<ConfirmationProps> = ({
2817
title,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
import { ReactNode } from 'react';
3+
4+
interface FooterButton {
5+
text: string;
6+
appearance: "primary" | "secondary";
7+
onClick: () => void;
8+
}
9+
10+
export interface ConfirmationProps {
11+
title: string;
12+
content: string | ReactNode;
13+
isDialogOpen: boolean; // Controlled state for dialog visibility
14+
onDialogClose: () => void; // Function to close the dialog
15+
footerButtons: FooterButton[]; // Array of footer buttons
16+
}

src/ContentProcessorWeb/src/Components/DocumentViewer/DocumentViewer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useEffect, useState } from "react";
22
import { useTranslation } from "react-i18next";
3-
import { Document } from "./DocumentViewer.types";
43
import { TIFFViewer } from 'react-tiff';
54
import './DocumentViewer.styles.scss';
65

@@ -107,7 +106,7 @@ const DocumentViewer = ({ className, metadata, urlWithSasToken, iframeKey }: IIF
107106
<div className={"invalidImagePopup"}>
108107
<span className="imgEH">We can't open this file</span>
109108
<p className="imgCtn">Something went wrong.</p>
110-
</div>
109+
</div>
111110
: getContentComponent()
112111
}
113112
</div>

src/ContentProcessorWeb/src/Components/DocumentViewer/DocumentViewer.types.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/ContentProcessorWeb/src/Components/Header/Header.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ import {
2626
} from "../../Imports/bundleIcons.tsx";
2727
import MainLogo from "../../Imports/MainLogo.svg";
2828
import "./Header.css";
29-
import { DocumentBulletListCubeRegular, InfoRegular} from "@fluentui/react-icons"
29+
import { DocumentBulletListCubeRegular, InfoRegular, DocumentData16Regular } from "@fluentui/react-icons"
3030

3131
import useAuth from "../../msal-auth/useAuth.ts";
32+
import { useSelector, shallowEqual } from 'react-redux';
33+
import { RootState } from '../../store/index.ts';
34+
import useSwaggerPreview from "../../Hooks/useSwaggerPreview.ts";
3235

3336
interface HeaderPageProps {
3437
toggleTheme: () => void;
@@ -41,13 +44,23 @@ const tabConfigs = [
4144
value: "default", // Route path defined in App.tsx
4245
label: "Content", // Visible label on UI
4346
},
47+
48+
{
49+
icon: <DocumentBulletListCubeRegular />, // Import bundle icon
50+
value: "api", // Route path defined in App.tsx
51+
label: "API Documentation", // Visible label on UI
52+
},
4453
// Add more
4554
];
4655

4756
const HeaderPage: React.FC<HeaderPageProps> = ({ toggleTheme, isDarkMode }) => {
4857
const { shortcutLabel } = useHeaderHooks({ toggleTheme, isDarkMode });
4958
const { user, logout, getToken } = useAuth();
5059

60+
const { openSwaggerUI } = useSwaggerPreview();
61+
const store = useSelector((state: RootState) => ({
62+
swaggerJSON: state.leftPanel.swaggerJSON,
63+
}), shallowEqual);
5164

5265
const navigate = useNavigate();
5366
const location = useLocation();
@@ -69,12 +82,20 @@ const HeaderPage: React.FC<HeaderPageProps> = ({ toggleTheme, isDarkMode }) => {
6982
_: React.SyntheticEvent,
7083
data: { value: TabValue }
7184
) => {
72-
const newRoute = Object.keys(tabRoutes).find(
73-
(key) => tabRoutes[key] === data.value
74-
);
75-
if (newRoute) {
76-
navigate(newRoute);
85+
if (data.value == 'api') {
86+
_.preventDefault();
87+
const apiUrl: string = process.env.REACT_APP_API_BASE_URL as string;
88+
const token = localStorage.getItem('token') ?? undefined;
89+
openSwaggerUI(store.swaggerJSON, apiUrl, token)
90+
} else {
91+
const newRoute = Object.keys(tabRoutes).find(
92+
(key) => tabRoutes[key] === data.value
93+
);
94+
if (newRoute) {
95+
navigate(newRoute);
96+
}
7797
}
98+
7899
};
79100

80101

@@ -100,8 +121,8 @@ const HeaderPage: React.FC<HeaderPageProps> = ({ toggleTheme, isDarkMode }) => {
100121
</TabList>
101122
</div>
102123
<div className="headerTag">
103-
<InfoRegular style={{ marginRight: "4px" }}/>
104-
<span>AI-generated content may be incorrect</span>
124+
<InfoRegular style={{ marginRight: "4px" }} />
125+
<span>AI-generated content may be incorrect</span>
105126
</div>
106127

107128
{/* Tools Section */}

0 commit comments

Comments
 (0)