Skip to content

Commit

Permalink
Merge pull request #145 from vishnoianil/overhaul-skills
Browse files Browse the repository at this point in the history
Improve the skill form
  • Loading branch information
nerdalert authored Sep 4, 2024
2 parents 4eafc99 + a35627f commit eda9e97
Show file tree
Hide file tree
Showing 26 changed files with 1,706 additions and 999 deletions.
13 changes: 5 additions & 8 deletions src/app/api/pr/skill/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SkillYamlData, AttributionData } from '@/types';
import { dumpYaml } from '@/utils/yamlConfig';

const GITHUB_API_URL = 'https://api.github.com';
const SKILL_DIR = 'compositional_skills';
const UPSTREAM_REPO_OWNER = process.env.NEXT_PUBLIC_TAXONOMY_REPO_OWNER!;
const UPSTREAM_REPO_NAME = process.env.NEXT_PUBLIC_TAXONOMY_REPO!;
const BASE_BRANCH = 'main';
Expand All @@ -31,7 +30,7 @@ export async function POST(req: NextRequest) {

try {
const body = await req.json();
const { content, attribution, name, email, submission_summary, task_description, filePath } = body;
const { content, attribution, name, email, submissionSummary, documentOutline, filePath } = body;

const githubUsername = await getGitHubUsername(headers);
console.log('GitHub Username:', githubUsername);
Expand All @@ -43,17 +42,15 @@ export async function POST(req: NextRequest) {
}

const branchName = `skill-contribution-${Date.now()}`;
const newYamlFilePath = `${SKILL_DIR}/${filePath}qna.yaml`;
const newAttributionFilePath = `${SKILL_DIR}/${filePath}attribution.txt`;
const newYamlFilePath = `${filePath}qna.yaml`;
const newAttributionFilePath = `${filePath}attribution.txt`;

const skillData = yaml.load(content) as SkillYamlData;
const attributionData = attribution as AttributionData;

const yamlString = dumpYaml(skillData);

const attributionString = `Title of work: ${attributionData.title_of_work}
Link to work: ${attributionData.link_to_work}
Revision: ${attributionData.revision}
License of the work: ${attributionData.license_of_the_work}
Creator names: ${attributionData.creator_names}
`;
Expand All @@ -74,11 +71,11 @@ Creator names: ${attributionData.creator_names}
{ path: newAttributionFilePath, content: attributionString }
],
branchName,
`${submission_summary}\n\nSigned-off-by: ${name} <${email}>`
`${submissionSummary}\n\nSigned-off-by: ${name} <${email}>`
);

// Create a pull request from the user's fork to the upstream repository
const pr = await createPullRequest(headers, githubUsername, branchName, submission_summary, task_description);
const pr = await createPullRequest(headers, githubUsername, branchName, submissionSummary, documentOutline);

return NextResponse.json(pr, { status: 201 });
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions src/app/edit-submission/knowledge/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as React from 'react';
import { useSession } from 'next-auth/react';
import { AppLayout } from '../../../../components/AppLayout';
import { AttributionData, PullRequestFile, KnowledgeYamlData, SchemaVersion } from '@/types';
import { AttributionData, PullRequestFile, KnowledgeYamlData, KnowledgeSchemaVersion } from '@/types';
import { fetchPullRequest, fetchFileContent, fetchPullRequestFiles } from '../../../../utils/github';
import yaml from 'js-yaml';
import axios from 'axios';
Expand Down Expand Up @@ -50,7 +50,7 @@ const EditKnowledgePage: React.FunctionComponent<{ params: { id: string } }> = (

const knowledgeEditFormData: KnowledgeEditFormData = {
isEditForm: true,
knowledgeVersion: SchemaVersion,
knowledgeVersion: KnowledgeSchemaVersion,
branchName: '',
knowledgeFormData: knowledgeExistingFormData,
pullRequestNumber: prNumber,
Expand Down Expand Up @@ -120,8 +120,8 @@ const EditKnowledgePage: React.FunctionComponent<{ params: { id: string } }> = (
knowledgeEditFormData.attributionFile = foundAttributionFile;
// Populate the form fields with attribution data
knowledgeExistingFormData.titleWork = attributionData.title_of_work;
knowledgeExistingFormData.linkWork = attributionData.link_to_work;
knowledgeExistingFormData.revision = attributionData.revision;
knowledgeExistingFormData.linkWork = attributionData.link_to_work ? attributionData.link_to_work : '';
knowledgeExistingFormData.revision = attributionData.revision ? attributionData.revision : '';
knowledgeExistingFormData.licenseWork = attributionData.license_of_the_work;
knowledgeExistingFormData.creators = attributionData.creator_names;
}
Expand Down
Loading

0 comments on commit eda9e97

Please sign in to comment.