Skip to content

Commit

Permalink
feat(ui): Add support for jobConfigs.analyzer.repositoryConfigPath
Browse files Browse the repository at this point in the history
Resolves eclipse-apoapsis#985.

Signed-off-by: Jyrki Keisala <[email protected]>
  • Loading branch information
Etsija committed Sep 18, 2024
1 parent 5852faf commit 46f730e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import {
FormField,
FormItem,
FormLabel,
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Switch } from '@/components/ui/switch';
import { packageManagers } from '@/routes/_layout/organizations/$orgId/products/$productId/repositories/$repoId/-types';
import { CreateRunFormValues } from '@/routes/_layout/organizations/$orgId/products/$productId/repositories/$repoId/create-run';
Expand Down Expand Up @@ -59,12 +61,30 @@ export const AnalyzerFields = ({ form }: AnalyzerFieldsProps) => {
/>
<AccordionItem value='analyzer' className='flex-1'>
<AccordionTrigger>Analyzer</AccordionTrigger>
<AccordionContent>
<AccordionContent className='flex flex-col gap-6'>
<FormField
control={form.control}
name='jobConfigs.analyzer.repositoryConfigPath'
render={({ field }) => (
<FormItem>
<FormLabel>Repository configuration path</FormLabel>
<FormControl>
<Input {...field} placeholder='(optional)' />
</FormControl>
<FormDescription>
The optional path to a repository configuration file. If this
is not defined, the repository configuration is read from the
root of the analyzed project repository, ie. "./.ort.yml".
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name='jobConfigs.analyzer.allowDynamicVersions'
render={({ field }) => (
<FormItem className='mb-4 flex flex-row items-center justify-between rounded-lg border p-4'>
<FormItem className='flex flex-row items-center justify-between rounded-lg border p-4'>
<div className='space-y-0.5'>
<FormLabel>Allow dynamic versions</FormLabel>
<FormDescription>
Expand All @@ -85,7 +105,7 @@ export const AnalyzerFields = ({ form }: AnalyzerFieldsProps) => {
control={form.control}
name='jobConfigs.analyzer.skipExcluded'
render={({ field }) => (
<FormItem className='mb-4 flex flex-row items-center justify-between rounded-lg border p-4'>
<FormItem className='flex flex-row items-center justify-between rounded-lg border p-4'>
<div className='space-y-0.5'>
<FormLabel>Skip excluded</FormLabel>
<FormDescription>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export const AnalyzerJobDetails = ({ run }: AnalyzerJobDetailsProps) => {
Resolved job configuration:
</Label>
<div className='ml-2 space-y-2'>
{jobConfigs?.repositoryConfigPath && (
<div>
<Label className='font-semibold'>
Repository configuration path:
</Label>{' '}
{jobConfigs.repositoryConfigPath}
</div>
)}
{jobConfigs?.allowDynamicVersions && (
<div>
<Label className='font-semibold'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const formSchema = z.object({
jobConfigs: z.object({
analyzer: z.object({
enabled: z.boolean(),
repositoryConfigPath: z.string().optional(),
allowDynamicVersions: z.boolean(),
skipExcluded: z.boolean(),
enabledPackageManagers: z.array(z.string()),
Expand Down Expand Up @@ -159,6 +160,7 @@ const CreateRunPage = () => {
jobConfigs: {
analyzer: {
enabled: true,
repositoryConfigPath: '',
allowDynamicVersions: true,
skipExcluded: true,
enabledPackageManagers: [
Expand Down Expand Up @@ -225,6 +227,9 @@ const CreateRunPage = () => {
jobConfigs: {
analyzer: {
enabled: baseDefaults.jobConfigs.analyzer.enabled,
repositoryConfigPath:
ortRun.jobConfigs.analyzer?.repositoryConfigPath ||
baseDefaults.jobConfigs.analyzer.repositoryConfigPath,
allowDynamicVersions:
ortRun.jobConfigs.analyzer?.allowDynamicVersions ||
baseDefaults.jobConfigs.analyzer.allowDynamicVersions,
Expand Down Expand Up @@ -404,6 +409,7 @@ const CreateRunPage = () => {
// it empty, and thus disabling the job.
const analyzerConfig = {
allowDynamicVersions: values.jobConfigs.analyzer.allowDynamicVersions,
repositoryConfigPath: values.jobConfigs.analyzer.repositoryConfigPath,
skipExcluded: values.jobConfigs.analyzer.skipExcluded,
enabledPackageManagers: values.jobConfigs.analyzer.enabledPackageManagers,
};
Expand Down

0 comments on commit 46f730e

Please sign in to comment.