Skip to content

Commit

Permalink
Remove validation for repo URL in native mode
Browse files Browse the repository at this point in the history
- Also change the field name to include server side filepath.

Signed-off-by: Brent Salisbury <[email protected]>
  • Loading branch information
nerdalert committed Dec 24, 2024
1 parent d9c6d17 commit 2ace807
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,6 @@ const DocumentInformation: React.FC<Props> = ({
}
}, [isEditForm]);

const validateRepo = (repoStr: string) => {
const repo = repoStr.trim();
if (repo.length === 0) {
setDisableAction(true);
setValidRepo(ValidatedOptions.error);
return;
}
try {
new URL(repo);
setValidRepo(ValidatedOptions.success);
setDisableAction(!checkKnowledgeFormCompletion(knowledgeFormData));
return;
} catch (e) {
setDisableAction(true);
setValidRepo(ValidatedOptions.warning);
return;
}
};

const validateCommit = (commitStr: string) => {
const commit = commitStr.trim();
if (commit.length > 0) {
Expand Down Expand Up @@ -283,7 +264,7 @@ const DocumentInformation: React.FC<Props> = ({
</Modal>
{!useFileUpload ? (
<>
<FormGroup isRequired key={'doc-info-details-id'} label="Repo URL">
<FormGroup isRequired key={'doc-info-details-id'} label="Repo URL or Server Side File Path">
<TextInput
isRequired
type="url"
Expand All @@ -292,26 +273,7 @@ const DocumentInformation: React.FC<Props> = ({
placeholder="Enter repo URL where document exists"
value={knowledgeDocumentRepositoryUrl}
onChange={(_event, value) => setKnowledgeDocumentRepositoryUrl(value)}
onBlur={() => validateRepo(knowledgeDocumentRepositoryUrl)}
/>
{validRepo === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validRepo}>
Required field
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
{validRepo === ValidatedOptions.warning && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant="error">
Please enter a valid URL.
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
<FormGroup isRequired key={'doc-info-details-commit_sha'} label="Commit SHA">
<TextInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,17 @@ const KnowledgeQuestionAnswerPairsNative: React.FC<Props> = ({
color: '#333'
}}
>
A commit SHA (<strong>{commitSha}</strong>) has already been selected in a previous seed example. All subsequent selections must use the
same commit SHA for consistency.
<Alert
variant="warning"
isInline
title="All knowledge files need to originate from the same commit or 'Document Information' submission"
style={{ marginBottom: '20px' }}
>
A commit SHA (<strong>{commitSha}</strong>) has already been selected in a previous seed example. All subsequent selections must use the
same commit SHA for consistency.
</Alert>
{/*A commit SHA (<strong>{commitSha}</strong>) has already been selected in a previous seed example. All subsequent selections must use the*/}
{/*same commit SHA for consistency.*/}
</div>
)}

Expand Down
48 changes: 21 additions & 27 deletions src/components/Contribute/Knowledge/ReviewSubmission/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ export const ReviewSubmission: React.FC<ReviewSubmissionProps> = ({ knowledgeFor
{/* Knowledge Information */}
<h3>Knowledge Information</h3>
<p>
<strong>Submission Summary:</strong> {knowledgeFormData.submissionSummary || 'N/A'}
<strong>Submission Summary:</strong> {knowledgeFormData.submissionSummary}
</p>
<p>
<strong>Domain:</strong> {knowledgeFormData.domain || 'N/A'}
<strong>Domain:</strong> {knowledgeFormData.domain}
</p>
<p>
<strong>Document Outline:</strong> {knowledgeFormData.documentOutline || 'N/A'}
<strong>Document Outline:</strong> {knowledgeFormData.documentOutline}
</p>

{/* File Path Information */}
<h3>File Path Information</h3>
<p>
<strong>File Path:</strong> {knowledgeFormData.filePath || 'N/A'}
<strong>File Path:</strong> {knowledgeFormData.filePath}
</p>

{/* Seed Examples */}
Expand All @@ -44,15 +44,15 @@ export const ReviewSubmission: React.FC<ReviewSubmissionProps> = ({ knowledgeFor
<div key={index}>
<h4>Seed Example {index + 1}</h4>
<p>
<strong>Context:</strong> {seedExample.context || 'N/A'}
<strong>Context:</strong> {seedExample.context}
</p>
{seedExample.questionAndAnswers.map((qa, qaIndex) => (
<div key={qaIndex}>
<p>
<strong>Question {qaIndex + 1}:</strong> {qa.question || 'N/A'}
<strong>Question {qaIndex + 1}:</strong> {qa.question}
</p>
<p>
<strong>Answer {qaIndex + 1}:</strong> {qa.answer || 'N/A'}
<strong>Answer {qaIndex + 1}:</strong> {qa.answer}
</p>
</div>
))}
Expand All @@ -61,38 +61,32 @@ export const ReviewSubmission: React.FC<ReviewSubmissionProps> = ({ knowledgeFor

{/* Document Information */}
<h3>Document Information</h3>
{knowledgeFormData.knowledgeDocumentRepositoryUrl && knowledgeFormData.knowledgeDocumentCommit ? (
<div>
<p>
<strong>Repository URL:</strong> {knowledgeFormData.knowledgeDocumentRepositoryUrl}
</p>
<p>
<strong>Commit SHA:</strong> {knowledgeFormData.knowledgeDocumentCommit}
</p>
<p>
<strong>Document Names:</strong> {knowledgeFormData.documentName || 'N/A'}
</p>
</div>
) : (
<p>No Document Information Provided.</p>
)}
<p>
<strong>Repository URL:</strong> {knowledgeFormData.knowledgeDocumentRepositoryUrl}
</p>
<p>
<strong>Commit:</strong> {knowledgeFormData.knowledgeDocumentCommit}
</p>
<p>
<strong>Document Name:</strong> {knowledgeFormData.documentName}
</p>

{/* Attribution Information */}
<h3>Attribution Information</h3>
<p>
<strong>Title of Work:</strong> {knowledgeFormData.titleWork || 'N/A'}
<strong>Title of Work:</strong> {knowledgeFormData.titleWork}
</p>
<p>
<strong>Link to Work:</strong> {knowledgeFormData.linkWork || 'N/A'}
<strong>Link to Work:</strong> {knowledgeFormData.linkWork}
</p>
<p>
<strong>Revision:</strong> {knowledgeFormData.revision || 'N/A'}
<strong>Revision:</strong> {knowledgeFormData.revision}
</p>
<p>
<strong>License of Work:</strong> {knowledgeFormData.licenseWork || 'N/A'}
<strong>License of Work:</strong> {knowledgeFormData.licenseWork}
</p>
<p>
<strong>Creators:</strong> {knowledgeFormData.creators || 'N/A'}
<strong>Creators:</strong> {knowledgeFormData.creators}
</p>
</div>
);
Expand Down

0 comments on commit 2ace807

Please sign in to comment.