sharepoint test
This commit is contained in:
parent
860fbd51f0
commit
fa1cb5be2e
2 changed files with 152 additions and 7 deletions
|
|
@ -314,4 +314,84 @@
|
|||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* SharePoint Site Discovery Styles */
|
||||
.sitesDiscovery {
|
||||
margin-top: 15px;
|
||||
padding: 15px;
|
||||
background-color: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.sitesList {
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.siteItem {
|
||||
padding: 12px;
|
||||
margin-bottom: 8px;
|
||||
background-color: white;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.siteItem:hover {
|
||||
background-color: #f1f3f4;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.selectedSite {
|
||||
background-color: #e3f2fd !important;
|
||||
border-color: #2196f3 !important;
|
||||
box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
|
||||
}
|
||||
|
||||
.siteName {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.siteName strong {
|
||||
color: #333;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.siteType {
|
||||
font-size: 0.8em;
|
||||
color: #666;
|
||||
background-color: #e9ecef;
|
||||
padding: 2px 6px;
|
||||
border-radius: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.siteUrl {
|
||||
font-size: 0.85em;
|
||||
color: #007bff;
|
||||
margin-bottom: 4px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.siteDescription {
|
||||
font-size: 0.8em;
|
||||
color: #666;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.noSitesFound {
|
||||
padding: 15px;
|
||||
background-color: #fff3cd;
|
||||
border: 1px solid #ffeaa7;
|
||||
border-radius: 4px;
|
||||
color: #856404;
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
|
@ -49,6 +49,8 @@ function TestSharepoint() {
|
|||
const [examples, setExamples] = useState<any>({});
|
||||
const [testResults, setTestResults] = useState<any>({});
|
||||
const [tokenDebugInfo, setTokenDebugInfo] = useState<any>(null);
|
||||
const [discoveredSites, setDiscoveredSites] = useState<any[]>([]);
|
||||
const [sitesDiscovered, setSitesDiscovered] = useState<boolean>(false);
|
||||
|
||||
// Form data
|
||||
const [formData, setFormData] = useState<FormData>({
|
||||
|
|
@ -123,6 +125,28 @@ function TestSharepoint() {
|
|||
}
|
||||
};
|
||||
|
||||
const handleDiscoverSites = async () => {
|
||||
try {
|
||||
const result = await discoverSites();
|
||||
if (result.success && result.data.sites) {
|
||||
setDiscoveredSites(result.data.sites);
|
||||
setSitesDiscovered(true);
|
||||
} else {
|
||||
console.error('Site discovery failed:', result.message);
|
||||
setDiscoveredSites([]);
|
||||
setSitesDiscovered(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Site discovery failed:', error);
|
||||
setDiscoveredSites([]);
|
||||
setSitesDiscovered(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectSite = (siteUrl: string) => {
|
||||
setFormData(prev => ({ ...prev, siteUrl: siteUrl }));
|
||||
};
|
||||
|
||||
const handleFormChange = (field: keyof FormData, value: any) => {
|
||||
setFormData(prev => ({ ...prev, [field]: value }));
|
||||
};
|
||||
|
|
@ -298,13 +322,54 @@ function TestSharepoint() {
|
|||
|
||||
<div className={styles.formGroup}>
|
||||
<label className={styles.label}>SharePoint Site URL</label>
|
||||
<input
|
||||
type="text"
|
||||
className={styles.input}
|
||||
value={formData.siteUrl}
|
||||
onChange={(e) => handleFormChange('siteUrl', e.target.value)}
|
||||
placeholder="https://your-tenant.sharepoint.com/sites/your-site"
|
||||
/>
|
||||
<div style={{ display: 'flex', gap: '10px', alignItems: 'center', marginBottom: '10px' }}>
|
||||
<input
|
||||
type="text"
|
||||
className={styles.input}
|
||||
value={formData.siteUrl}
|
||||
onChange={(e) => handleFormChange('siteUrl', e.target.value)}
|
||||
placeholder="https://your-tenant.sharepoint.com/sites/your-site"
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
<button
|
||||
className={`${styles.button} ${styles.exampleButton}`}
|
||||
onClick={handleDiscoverSites}
|
||||
disabled={isLoading}
|
||||
type="button"
|
||||
>
|
||||
Discover Sites
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{sitesDiscovered && discoveredSites.length > 0 && (
|
||||
<div className={styles.sitesDiscovery}>
|
||||
<label className={styles.label}>Discovered Sites ({discoveredSites.length}):</label>
|
||||
<div className={styles.sitesList}>
|
||||
{discoveredSites.map((site, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className={`${styles.siteItem} ${formData.siteUrl === site.url ? styles.selectedSite : ''}`}
|
||||
onClick={() => handleSelectSite(site.url)}
|
||||
>
|
||||
<div className={styles.siteName}>
|
||||
<strong>{site.name}</strong>
|
||||
<span className={styles.siteType}>({site.type})</span>
|
||||
</div>
|
||||
<div className={styles.siteUrl}>{site.url}</div>
|
||||
{site.description && (
|
||||
<div className={styles.siteDescription}>{site.description}</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{sitesDiscovered && discoveredSites.length === 0 && (
|
||||
<div className={styles.noSitesFound}>
|
||||
No SharePoint sites found. You may need additional permissions or the sites may not be accessible.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{activeTab === 'list' && (
|
||||
|
|
|
|||
Loading…
Reference in a new issue