Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "DocumentUploadEnabled" app setting is now split into 2 new names… #6

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion webapi/Controllers/ServiceInfoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public IActionResult GetFrontEndConfig()
HeaderIcon = this._frontendOptions.HeaderIcon,
HeaderSettingsEnabled = this._frontendOptions.HeaderSettingsEnabled,
HeaderPluginsEnabled = this._frontendOptions.HeaderPluginsEnabled,
DocumentUploadEnabled = this._frontendOptions.DocumentUploadEnabled,
DocumentLocalUploadEnabled = this._frontendOptions.DocumentLocalUploadEnabled,
DocumentGlobalUploadEnabled = this._frontendOptions.DocumentGlobalUploadEnabled,
CreateNewChat = this._frontendOptions.CreateNewChat,
DisclaimerMsg = this._frontendOptions.DisclaimerMsg
};
Expand Down
6 changes: 4 additions & 2 deletions webapi/Models/FrontendConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;

Check warning on line 1 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

A source file is missing a required header.
using System.Text.Json.Serialization;

namespace CopilotChat.WebApi.Models.Response;

Check warning on line 4 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

Namespace "CopilotChat.WebApi.Models.Response" does not match folder structure, expected "CopilotChat.WebApi.Models"

/// <summary>
/// Configuration to be used by the frontend client to this service.
Expand All @@ -21,16 +21,18 @@
public string HeaderIcon { get; set; } = string.Empty;

[JsonPropertyName("headerSettingsEnabled")]
public Boolean HeaderSettingsEnabled { get; set; } = false;

Check warning on line 24 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified

[JsonPropertyName("headerPluginsEnabled")]
public Boolean HeaderPluginsEnabled { get; set; } = false;

Check warning on line 27 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified

[JsonPropertyName("documentUploadEnabled")]
public Boolean DocumentUploadEnabled { get; set; } = false;
[JsonPropertyName("documentLocalUploadEnabled")]
public Boolean DocumentLocalUploadEnabled { get; set; } = false;

Check warning on line 30 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified
[JsonPropertyName("documentGlobalUploadEnabled")]
public Boolean DocumentGlobalUploadEnabled { get; set; } = false;

Check warning on line 32 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified

[JsonPropertyName("createNewChat")]
public Boolean CreateNewChat { get; set; } = false;

Check warning on line 35 in webapi/Models/FrontendConfig.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified
[JsonPropertyName("disclaimerMsg")]
public string DisclaimerMsg { get; set; } = string.Empty;

Expand Down
3 changes: 2 additions & 1 deletion webapi/Options/FrontendOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
public string HeaderTitleColor { get; set; } = string.Empty;
public string HeaderBackgroundColor { get; set; } = string.Empty;
public string HeaderIcon { get; set; } = string.Empty;
public Boolean HeaderSettingsEnabled { get; set; } = false;

Check warning on line 23 in webapi/Options/FrontendOptions.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified
public Boolean HeaderPluginsEnabled { get; set; } = false;

Check warning on line 24 in webapi/Options/FrontendOptions.cs

View workflow job for this annotation

GitHub Actions / check-format

Name can be simplified
public Boolean DocumentUploadEnabled { get; set; } = false;
public Boolean DocumentLocalUploadEnabled { get; set; } = false;
public Boolean DocumentGlobalUploadEnabled { get; set; } = false;
public Boolean CreateNewChat { get; set; } = false;
public string DisclaimerMsg { get; set; } = string.Empty;
}
13 changes: 8 additions & 5 deletions webapp/src/components/chat/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({ isDraggingOver, onDragLeav
};

const handleDrop = (e: React.DragEvent<HTMLTextAreaElement>) => {
if (store.getState().app.frontendSettings?.documentUploadEnabled != true) {
if (store.getState().app.frontendSettings?.documentLocalUploadEnabled != true) {
return;
} else {
onDragLeave(e);
Expand Down Expand Up @@ -194,13 +194,13 @@ export const ChatInput: React.FC<ChatInputProps> = ({ isDraggingOver, onDragLeav
disabled={conversations[selectedId].disabled}
textarea={{
className:
isDraggingOver && store.getState().app.frontendSettings?.documentUploadEnabled == true
isDraggingOver && store.getState().app.frontendSettings?.documentLocalUploadEnabled == true
? mergeClasses(classes.dragAndDrop, classes.textarea)
: classes.textarea,
}}
className={classes.input}
value={
isDraggingOver && store.getState().app.frontendSettings?.documentUploadEnabled == true
isDraggingOver && store.getState().app.frontendSettings?.documentLocalUploadEnabled == true
? 'Drop your files here'
: value
}
Expand All @@ -219,7 +219,10 @@ export const ChatInput: React.FC<ChatInputProps> = ({ isDraggingOver, onDragLeav
}
}}
onChange={(_event, data) => {
if (isDraggingOver && store.getState().app.frontendSettings?.documentUploadEnabled == true) {
if (
isDraggingOver &&
store.getState().app.frontendSettings?.documentLocalUploadEnabled == true
) {
return;
}

Expand Down Expand Up @@ -257,7 +260,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({ isDraggingOver, onDragLeav
/>
<Button
disabled={
store.getState().app.frontendSettings?.documentUploadEnabled != true ||
store.getState().app.frontendSettings?.documentLocalUploadEnabled != true ||
conversations[selectedId].disabled ||
(importingDocuments && importingDocuments.length > 0)
}
Expand Down
5 changes: 4 additions & 1 deletion webapp/src/components/chat/tabs/DocumentsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const DocumentsTab: React.FC = () => {
{/* Hidden input for file upload. Only accept .txt and .pdf files for now. */}
<input
type="file"
disabled={store.getState().app.frontendSettings?.documentLocalUploadEnabled != true}
ref={localDocumentFileRef}
style={{ display: 'none' }}
accept={Constants.app.importTypes}
Expand All @@ -148,6 +149,7 @@ export const DocumentsTab: React.FC = () => {
/>
<input
type="file"
disabled={store.getState().app.frontendSettings?.documentGlobalUploadEnabled != true}
ref={globalDocumentFileRef}
style={{ display: 'none' }}
accept={Constants.app.importTypes}
Expand All @@ -163,7 +165,6 @@ export const DocumentsTab: React.FC = () => {
className={classes.uploadButton}
icon={<DocumentArrowUp20Regular />}
disabled={
store.getState().app.frontendSettings?.documentUploadEnabled != true ||
conversations[selectedId].disabled ||
(importingDocuments && importingDocuments.length > 0)
}
Expand All @@ -179,6 +180,7 @@ export const DocumentsTab: React.FC = () => {
onClick={() => localDocumentFileRef.current?.click()}
icon={<Add20 />}
disabled={
store.getState().app.frontendSettings?.documentLocalUploadEnabled != true ||
conversations[selectedId].disabled ||
(importingDocuments && importingDocuments.length > 0)
}
Expand All @@ -190,6 +192,7 @@ export const DocumentsTab: React.FC = () => {
onClick={() => globalDocumentFileRef.current?.click()}
icon={<GlobeAdd20Regular />}
disabled={
store.getState().app.frontendSettings?.documentGlobalUploadEnabled != true ||
conversations[selectedId].disabled ||
(importingDocuments && importingDocuments.length > 0)
}
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/libs/frontend/FrontendHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export interface FrontendConfig {
headerIcon: string;
headerSettingsEnabled: boolean;
headerPluginsEnabled: boolean;
documentUploadEnabled: boolean;
documentLocalUploadEnabled: boolean;
documentGlobalUploadEnabled: boolean;
createNewChat: boolean;
disclaimerMsg: string;
}
Expand Down
Loading