Skip to content

Commit

Permalink
style: run format
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Feb 12, 2024
1 parent 4707c6c commit 45a1650
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 84 deletions.
17 changes: 7 additions & 10 deletions frontend/src/lib/components/SideBar/navData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ export const navData = {
name: 'Assets',
fa_icon: 'fa-solid fa-gem',
href: '/assets'
},
}
]
},
{
name: 'Governance',
items: [

{
name: 'Policies',
fa_icon: 'fa-solid fa-user',
Expand All @@ -72,7 +71,7 @@ export const navData = {
name: 'Risk matrices',
fa_icon: 'fa-solid fa-table-cells-large',
href: '/risk-matrices'
},
}
]
},
{
Expand Down Expand Up @@ -116,10 +115,9 @@ export const navData = {
}
]
},
{
name: 'Organisation',
items : [

{
name: 'Organisation',
items: [
{
name: 'Domains',
fa_icon: 'fa-solid fa-diagram-project',
Expand All @@ -145,9 +143,8 @@ export const navData = {
fa_icon: 'fa-solid fa-user-tag',
href: '/role-assignments'
}
]

},
]
},

{
name: 'Extra',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const URL_MODEL_MAP: ModelMap = {
foreignKeyFields: [
{ field: 'security_measures', urlModel: 'security-measures' },
{ field: 'evidences', urlModel: 'evidences' },
{ field: 'compliance_assessment', urlModel: 'compliance-assessments'}
{ field: 'compliance_assessment', urlModel: 'compliance-assessments' }
]
},
libraries: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const listViewFields = {
},
'requirement-assessments': {
head: ['Name', 'Description', 'Compliance Assessment'],
body: ['name', 'description', 'compliance_assessment'],
body: ['name', 'description', 'compliance_assessment']
},
evidences: {
head: ['Name', 'File', 'Description'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,20 @@
<div class="flex flex-1 bg-gray-200 rounded-full overflow-hidden h-4 shrink">
{#each orderedStatusPercentages as sp}
{#if complianceColorMap[sp.status] === '#000000'}
<div
class="flex flex-col justify-center overflow-hidden text-white text-xs text-center bg-yellow-500"
style="width: {sp.percentage.value}%; background-color: {complianceColorMap[sp.status]}"
>
{sp.percentage.display}%
</div>
<div
class="flex flex-col justify-center overflow-hidden text-white text-xs text-center bg-yellow-500"
style="width: {sp.percentage.value}%; background-color: {complianceColorMap[sp.status]}"
>
{sp.percentage.display}%
</div>
{:else}
<div
class="flex flex-col justify-center overflow-hidden text-black text-xs text-center bg-yellow-500"
style="width: {sp.percentage.value}%; background-color: {complianceColorMap[sp.status]}"
>
{sp.percentage.display}%
<!-- {sp.percentage?.display}% -->
</div>
<div
class="flex flex-col justify-center overflow-hidden text-black text-xs text-center bg-yellow-500"
style="width: {sp.percentage.value}%; background-color: {complianceColorMap[sp.status]}"
>
{sp.percentage.display}%
<!-- {sp.percentage?.display}% -->
</div>
{/if}
{/each}
</div>
Expand Down
13 changes: 6 additions & 7 deletions frontend/src/routes/(app)/evidences/[id=uuid]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { urlModel } from '$lib/utils/types';
import { listViewFields } from '$lib/utils/table';
import { tableSourceMapper, type TableSource } from '@skeletonlabs/skeleton';

export const load: PageServerLoad = (async ({ fetch, params }) => {
export const load: PageServerLoad = async ({ fetch, params }) => {
const URLModel = 'evidences';
const endpoint = `${BASE_API_URL}/${URLModel}/${params.id}/`;

Expand Down Expand Up @@ -38,7 +38,7 @@ export const load: PageServerLoad = (async ({ fetch, params }) => {
}

return { URLModel, evidence, object, tables };
})
};

export const actions: Actions = {
deleteAttachment: async (event) => {
Expand All @@ -63,11 +63,10 @@ export const actions: Actions = {
if (response.non_field_errors) {
setError(deleteAttachmentForm, 'non_field_errors', response.non_field_errors);
}
setFlash({ type: "error", message: "An error has occured" }, event);
setFlash({ type: 'error', message: 'An error has occured' }, event);
return fail(400, { form: deleteAttachmentForm });
}
setFlash({ type: "success", message: "Attachment successfully deleted" }, event);
throw redirect(302, `/${urlmodel}/${id}`)
setFlash({ type: 'success', message: 'Attachment successfully deleted' }, event);
throw redirect(302, `/${urlmodel}/${id}`);
}

}
};
33 changes: 16 additions & 17 deletions frontend/src/routes/(app)/evidences/[id=uuid]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import { breadcrumbObject } from '$lib/utils/stores';
import { URL_MODEL_MAP } from '$lib/utils/crud';
import ConfirmModal from '$lib/components/Modals/ConfirmModal.svelte';
import type { ModalSettings, ModalComponent, ModalStore, ToastStore } from '@skeletonlabs/skeleton';
import type {
ModalSettings,
ModalComponent,
ModalStore,
ToastStore
} from '@skeletonlabs/skeleton';
import { getModalStore, TabGroup, Tab, getToastStore } from '@skeletonlabs/skeleton';
import { isURL } from '$lib/utils/helpers';
import { getModelInfo } from '$lib/utils/crud.js';
Expand Down Expand Up @@ -34,7 +39,7 @@
URLModel: getModelInfo('evidences').urlModel,
formAction: action
}
};
};
const modal: ModalSettings = {
type: 'component',
component: modalComponent,
Expand Down Expand Up @@ -129,29 +134,23 @@
</div>
<div class="card px-6 py-4 bg-white flex flex-col shadow-lg space-y-4">
<TabGroup>
<Tab bind:group={tabSet} name="compliance_assessments_tab" value={0}>
Security measures
</Tab>
<Tab bind:group={tabSet} name="risk_assessments_tab" value={1}>
Requirement assessments
</Tab>
<Tab bind:group={tabSet} name="compliance_assessments_tab" value={0}>Security measures</Tab>
<Tab bind:group={tabSet} name="risk_assessments_tab" value={1}>Requirement assessments</Tab>
<svelte:fragment slot="panel">
{#if tabSet === 0}
<div
class="h-full flex flex-col space-y-2 variant-outline-surface rounded-container-token p-4"
>
<ModelTable
source={data.tables['security-measures']}
URLModel="security-measures"
/>
<ModelTable source={data.tables['security-measures']} URLModel="security-measures" />
</div>
{/if}
{#if tabSet === 1}
<div
class="h-full flex flex-col space-y-2 variant-outline-surface rounded-container-token p-4"
>
<ModelTable source={data.tables['requirement-assessments']}
URLModel="requirement-assessments"
<ModelTable
source={data.tables['requirement-assessments']}
URLModel="requirement-assessments"
/>
</div>
{/if}
Expand All @@ -170,9 +169,9 @@
on:click={(_) => {
modalConfirm(data.evidence.id, data.evidence.attachment, '?/deleteAttachment');
}}
on:keydown={(_) => modalConfirm(data.evidence.id, data.evidence.attachment, '?/deleteAttachment')}
class="btn variant-filled-tertiary h-full"
><i class="fa-solid fa-trash" /></button
on:keydown={(_) =>
modalConfirm(data.evidence.id, data.evidence.attachment, '?/deleteAttachment')}
class="btn variant-filled-tertiary h-full"><i class="fa-solid fa-trash" /></button
>
</div>
</div>
Expand Down
58 changes: 29 additions & 29 deletions frontend/src/routes/(app)/libraries/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,35 @@
</div>
{#if tabSet === 1}
<div class="card bg-white p-4 mt-4 shadow">
{#await superValidate(LibraryUploadSchema)}
<h1>Loading the library upload button...</h1>
{:then form}
<SuperForm
class="flex flex-col space-y-3"
dataType="form"
enctype="multipart/form-data"
data={form}
let:form
validators={LibraryUploadSchema}
action="?/upload"
{...$$restProps}
>
<FileInput
{form}
helpText="Library file in YAML format"
mandatory={true}
field="file"
label="Upload your own library :"
/>

<button
class="btn variant-filled-primary font-semibold w-full"
data-testid="save-button"
type="submit">Save</button
{#await superValidate(LibraryUploadSchema)}
<h1>Loading the library upload button...</h1>
{:then form}
<SuperForm
class="flex flex-col space-y-3"
dataType="form"
enctype="multipart/form-data"
data={form}
let:form
validators={LibraryUploadSchema}
action="?/upload"
{...$$restProps}
>
</SuperForm>
{:catch err}
<h1>The following error occured while loading the library form : {err}</h1>
{/await}
<FileInput
{form}
helpText="Library file in YAML format"
mandatory={true}
field="file"
label="Upload your own library :"
/>

<button
class="btn variant-filled-primary font-semibold w-full"
data-testid="save-button"
type="submit">Save</button
>
</SuperForm>
{:catch err}
<h1>The following error occured while loading the library form : {err}</h1>
{/await}
</div>
{/if}
11 changes: 7 additions & 4 deletions frontend/src/routes/(app)/libraries/[id=urn]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@
<p class="text-md leading-5 text-gray-700">Provider: {library.provider}</p>
<p class="text-md leading-5 text-gray-700">Packager: {library.packager}</p>
{#if library.dependencies}
<p class="text-md leading-5 text-gray-700">Dependendies:
{#each library.dependencies as dependency}
<li><a href="/libraries/{dependency}" target="_parent" class="anchor">{dependency}</a></li>
{/each}
<p class="text-md leading-5 text-gray-700">
Dependendies:
{#each library.dependencies as dependency}
<li>
<a href="/libraries/{dependency}" target="_parent" class="anchor">{dependency}</a>
</li>
{/each}
</p>
{/if}
{#if library.copyright}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ export const actions: Actions = {
return fail(400, { form });
}

setFlash({ type: 'success', message: `Your password was successfully set. Welcome to CISO Assistant.` }, event);
setFlash(
{
type: 'success',
message: `Your password was successfully set. Welcome to CISO Assistant.`
},
event
);
redirect(302, '/login');
}
};
8 changes: 7 additions & 1 deletion frontend/tests/functional/nav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ type StringMap = {
[key: string]: string;
};

test('sidebar navigation tests', async ({ logedPage, analyticsPage: analyticsPage, layout, sideBar, page }) => {
test('sidebar navigation tests', async ({
logedPage,
analyticsPage: analyticsPage,
layout,
sideBar,
page
}) => {
await test.step('proper redirection to the analytics page after login', async () => {
await analyticsPage.hasUrl();
await analyticsPage.hasTitle();
Expand Down

0 comments on commit 45a1650

Please sign in to comment.