Skip to content

Commit

Permalink
Remove breadcrumbObject store
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Dec 20, 2024
1 parent 36c924b commit 73ff076
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 166 deletions.
29 changes: 12 additions & 17 deletions frontend/src/lib/components/DetailView/DetailView.svelte
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
<script lang="ts">
import { safeTranslate } from '$lib/utils/i18n';
import { page } from '$app/stores';
import Anchor from '$lib/components/Anchor/Anchor.svelte';
import List from '$lib/components/List/List.svelte';
import ConfirmModal from '$lib/components/Modals/ConfirmModal.svelte';
import CreateModal from '$lib/components/Modals/CreateModal.svelte';
import MissingConstraintsModal from '$lib/components/Modals/MissingConstraintsModal.svelte';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import { ISO_8601_REGEX } from '$lib/utils/constants';
import { URL_MODEL_MAP, checkConstraints } from '$lib/utils/crud';
import { getModelInfo } from '$lib/utils/crud.js';
import { formatDateOrDateTime } from '$lib/utils/datetime';
import { isURL } from '$lib/utils/helpers';
import { safeTranslate } from '$lib/utils/i18n';
import { toCamelCase } from '$lib/utils/locales.js';
import * as m from '$paraglide/messages.js';
import { languageTag } from '$paraglide/runtime.js';
import type {
ModalComponent,
ModalSettings,
ModalStore,
ToastStore
} from '@skeletonlabs/skeleton';
import { TabGroup, Tab, getModalStore, getToastStore } from '@skeletonlabs/skeleton';
import { breadcrumbObject } from '$lib/utils/stores';
import { getModelInfo } from '$lib/utils/crud.js';
import { URL_MODEL_MAP } from '$lib/utils/crud';
import { isURL } from '$lib/utils/helpers';
import { toCamelCase } from '$lib/utils/locales.js';
import { checkConstraints } from '$lib/utils/crud';
import { languageTag } from '$paraglide/runtime.js';
import * as m from '$paraglide/messages.js';
import { ISO_8601_REGEX } from '$lib/utils/constants';
import { formatDateOrDateTime } from '$lib/utils/datetime';
import List from '$lib/components/List/List.svelte';
import Anchor from '$lib/components/Anchor/Anchor.svelte';
import { Tab, TabGroup, getModalStore, getToastStore } from '@skeletonlabs/skeleton';
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
const modalStore: ModalStore = getModalStore();
const toastStore: ToastStore = getToastStore();
Expand All @@ -50,8 +47,6 @@
);
}
$: breadcrumbObject.set(data.data);
let tabSet = 0;
function handleFormUpdated({
Expand Down
1 change: 0 additions & 1 deletion frontend/src/lib/utils/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ showNotification.subscribe((val) => {
if (browser) return (localStorage.showNotification = val);
});

export const breadcrumbObject = writable({ id: '', name: '', email: '' });
export const pageTitle = writable('');
export const clientSideToast = writable(undefined);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<script lang="ts">
import type { PageData } from './$types';
import ModelForm from '$lib/components/Forms/ModelForm.svelte';
import { breadcrumbObject } from '$lib/utils/stores';
import type { PageData } from './$types';
export let data: PageData;
const customNameDescription = ['operational-scenarios'].includes(data.model.urlModel);
breadcrumbObject.set(data.object);
</script>

<ModelForm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script lang="ts">
import { composerSchema } from '$lib/utils/schemas';
import SuperForm from '$lib/components/Forms/Form.svelte';
import Anchor from '$lib/components/Anchor/Anchor.svelte';
import AutocompleteSelect from '$lib/components/Forms/AutocompleteSelect.svelte';
import type { AnyZodObject } from 'zod';
import type { SuperValidated } from 'sveltekit-superforms';
import { onMount } from 'svelte';
import SuperForm from '$lib/components/Forms/Form.svelte';
import { getOptions } from '$lib/utils/crud';
import { composerSchema } from '$lib/utils/schemas';
import * as m from '$paraglide/messages';
import { onMount } from 'svelte';
import type { SuperValidated } from 'sveltekit-superforms';
import { zod } from 'sveltekit-superforms/adapters';
import Anchor from '$lib/components/Anchor/Anchor.svelte';
export let composerForm: SuperValidated<Record<string, any>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<script lang="ts">
import * as m from '$paraglide/messages.js';
import type { TableSource } from '$lib/components/ModelTable/types';
import { Tab, TabGroup, tableSourceMapper } from '@skeletonlabs/skeleton';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import { breadcrumbObject } from '$lib/utils/stores';
import type { TableSource } from '$lib/components/ModelTable/types';
import * as m from '$paraglide/messages.js';
import { tableSourceMapper } from '@skeletonlabs/skeleton';
export let data;
breadcrumbObject.set(data.compliance_assessment);
let tabSet = 0;
const appliedControlsHead = {
name: 'name',
status: 'status',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<script lang="ts">
import type { PageData } from './$types';
import { RadioGroup, RadioItem } from '@skeletonlabs/skeleton';
import * as m from '$paraglide/messages';
import { breadcrumbObject } from '$lib/utils/stores';
import { complianceResultTailwindColorMap } from '$lib/utils/constants';
import * as m from '$paraglide/messages';
import { RadioGroup, RadioItem } from '@skeletonlabs/skeleton';
import type { PageData } from './$types';
export let data: PageData;
breadcrumbObject.set(data.compliance_assessment);
const possible_options = [
{ id: 'not_assessed', label: m.notAssessed() },
{ id: 'non_compliant', label: m.nonCompliant() },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<script lang="ts">
import * as m from '$paraglide/messages';
import { safeTranslate } from '$lib/utils/i18n';
import Tile from './Tile.svelte';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import type { PageData, ActionData } from './$types';
import { breadcrumbObject } from '$lib/utils/stores';
import type { ModalComponent, ModalSettings, ModalStore } from '@skeletonlabs/skeleton';
import { getModalStore } from '@skeletonlabs/skeleton';
import CreateModal from '$lib/components/Modals/CreateModal.svelte';
import MissingConstraintsModal from '$lib/components/Modals/MissingConstraintsModal.svelte';
import { checkConstraints } from '$lib/utils/crud';
import { goto } from '$app/navigation';
import { getSecureRedirect } from '$lib/utils/helpers';
import { safeTranslate } from '$lib/utils/i18n';
import * as m from '$paraglide/messages';
import type { ModalComponent, ModalSettings, ModalStore } from '@skeletonlabs/skeleton';
import { getModalStore } from '@skeletonlabs/skeleton';
import type { ActionData, PageData } from './$types';
import Tile from './Tile.svelte';
const modalStore: ModalStore = getModalStore();
export let data: PageData;
export let form: ActionData;
$: breadcrumbObject.set(data.data);
const workshopsData = {
ws1: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
import * as m from '$paraglide/messages';
import { TreeView, TreeViewItem } from '@skeletonlabs/skeleton';
import AuditTableMode from '../../../(third-party)/compliance-assessments/[id=uuid]/table-mode/+page.svelte';
import type { PageData, Actions } from './$types';
import type { Actions, PageData } from './$types';
export let data: PageData;
export let form: Actions;
import { breadcrumbObject } from '$lib/utils/stores';
breadcrumbObject.set(data.data);
const mailing =
Boolean(data.data.compliance_assessment) && Boolean(data.data.representatives.length);
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<script lang="ts">
import type { PageData } from './$types';
import type { TreeViewNode } from '@skeletonlabs/skeleton';
import RecursiveTreeView from '$lib/components/TreeView/RecursiveTreeView.svelte';
import TreeViewItemContent from './TreeViewItemContent.svelte';
import { breadcrumbObject } from '$lib/utils/stores';
import { URL_MODEL_MAP } from '$lib/utils/crud';
import * as m from '$paraglide/messages';
import { toCamelCase } from '$lib/utils/locales';
import { safeTranslate } from '$lib/utils/i18n';
import * as m from '$paraglide/messages';
import type { TreeViewNode } from '@skeletonlabs/skeleton';
import type { PageData } from './$types';
import TreeViewItemContent from './TreeViewItemContent.svelte';
export let data: PageData;
breadcrumbObject.set(data.framework);
const tree = data.tree;
function transformToTreeView(nodes) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<script lang="ts">
import { breadcrumbObject } from '$lib/utils/stores';
import { page } from '$app/stores';
import Dropdown from '$lib/components/Dropdown/Dropdown.svelte';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import RiskMatrix from '$lib/components/RiskMatrix/RiskMatrix.svelte';
import Dropdown from '$lib/components/Dropdown/Dropdown.svelte';
import TreeViewItemContent from '../../frameworks/[id=uuid]/TreeViewItemContent.svelte';
import * as m from '$paraglide/messages';
import { page } from '$app/stores';
import TreeViewItemContent from '../../frameworks/[id=uuid]/TreeViewItemContent.svelte';
export let data;
let loading = { form: false, library: '' };
Expand All @@ -14,12 +13,6 @@
[key: string]: any;
}
const breadcrumb_library_data = {
...data.library,
id: data.library.id
};
$: breadcrumbObject.set(breadcrumb_library_data);
const libraryObjects: LibraryObjects = data.library.objects ?? [];
const riskMatrices = libraryObjects['risk_matrix'] ?? [];
const referenceControls = libraryObjects['reference_controls'] ?? [];
Expand All @@ -37,10 +30,10 @@
});
}
import { ProgressRadial, tableSourceMapper, type TreeViewNode } from '@skeletonlabs/skeleton';
import RecursiveTreeView from '$lib/components/TreeView/RecursiveTreeView.svelte';
import type { TableSource } from '$lib/components/ModelTable/types';
import { enhance } from '$app/forms';
import type { TableSource } from '$lib/components/ModelTable/types';
import RecursiveTreeView from '$lib/components/TreeView/RecursiveTreeView.svelte';
import { ProgressRadial, tableSourceMapper } from '@skeletonlabs/skeleton';
const riskMatricesTable: TableSource = {
head: { name: 'name', description: 'description' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import RiskMatrix from '$lib/components/RiskMatrix/RiskMatrix.svelte';
import { URL_MODEL_MAP, getModelInfo } from '$lib/utils/crud.js';
import { breadcrumbObject } from '$lib/utils/stores';
import type { RiskMatrixJsonDefinition, RiskScenario } from '$lib/utils/types';
import type {
ModalComponent,
Expand All @@ -17,16 +16,14 @@
import { superForm } from 'sveltekit-superforms';
import RiskScenarioItem from '$lib/components/RiskMatrix/RiskScenarioItem.svelte';
import { safeTranslate } from '$lib/utils/i18n.js';
import * as m from '$paraglide/messages';
import { languageTag } from '$paraglide/runtime';
import { safeTranslate } from '$lib/utils/i18n.js';
export let data;
const showRisks = true;
const risk_assessment = data.risk_assessment;
breadcrumbObject.set(risk_assessment);
const modalStore: ModalStore = getModalStore();
const toastStore: ToastStore = getToastStore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<script lang="ts">
import * as m from '$paraglide/messages.js';
import { breadcrumbObject } from '$lib/utils/stores';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import type { TableSource } from '$lib/components/ModelTable/types';
import { safeTranslate } from '$lib/utils/i18n.js';
import { toCamelCase } from '$lib/utils/locales.js';
import type { TableSource } from '$lib/components/ModelTable/types';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import * as m from '$paraglide/messages.js';
export let data;
breadcrumbObject.set(data.risk_assessment);
const scenarioTreatmentColorMap = (status: string) => {
const map: Record<string, string> = {
open: 'bg-orange-200',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<script lang="ts">
import { page } from '$app/stores';
import { breadcrumbObject } from '$lib/utils/stores';
import RiskMatrix from '$lib/components/RiskMatrix/RiskMatrix.svelte';
import { URL_MODEL_MAP } from '$lib/utils/crud.js';
const showRisks = true;
export let data;
const riskMatrix = data.data;
breadcrumbObject.set(riskMatrix);
</script>

<div class="flex flex-row justify-between">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<script lang="ts">
import { breadcrumbObject } from '$lib/utils/stores';
import { page } from '$app/stores';
import type { PageData } from './$types';
import { URL_MODEL_MAP } from '$lib/utils/crud';
import type { PageData } from './$types';
import { safeTranslate } from '$lib/utils/i18n';
import * as m from '$paraglide/messages';
import { languageTag } from '$paraglide/runtime';
import { toCamelCase } from '$lib/utils/locales';
import { safeTranslate } from '$lib/utils/i18n';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import { isDark } from '$lib/utils/helpers';
export let data: PageData;
$: breadcrumbObject.set(data.scenario);
const user = $page.data.user;
const model = URL_MODEL_MAP['risk-scenarios'];
const canEditObject: boolean = Object.hasOwn(user.permissions, `change_${model.name}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import TextArea from '$lib/components/Forms/TextArea.svelte';
import TextField from '$lib/components/Forms/TextField.svelte';
import CreateModal from '$lib/components/Modals/CreateModal.svelte';
import ModelTable from '$lib/components/ModelTable/ModelTable.svelte';
import { getOptions } from '$lib/utils/crud';
import { modelSchema } from '$lib/utils/schemas';
import { getSecureRedirect } from '$lib/utils/helpers';
import { modelSchema } from '$lib/utils/schemas';
import type { StrengthOfKnowledgeEntry } from '$lib/utils/types';
import {
getModalStore,
getToastStore,
Expand All @@ -18,23 +18,18 @@
type ToastStore
} from '@skeletonlabs/skeleton';
import type { PageData } from './$types';
import type { StrengthOfKnowledgeEntry } from '$lib/utils/types';
import RiskLevel from './RiskLevel.svelte';
import { browser } from '$app/environment';
import { breadcrumbObject } from '$lib/utils/stores';
import { superForm } from 'sveltekit-superforms';
import { page } from '$app/stores';
import { superForm } from 'sveltekit-superforms';
import * as m from '$paraglide/messages';
import { safeTranslate } from '$lib/utils/i18n';
import { languageTag } from '$paraglide/runtime';
import * as m from '$paraglide/messages';
import { zod } from 'sveltekit-superforms/adapters';
export let data: PageData;
breadcrumbObject.set(data.scenario);
const schema = modelSchema(data.model.urlModel!);
const strengthOfKnowledgeFormChoices: { label: string; value: number }[] = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<script lang="ts">
import type { PageData } from './$types';
import ModelForm from '$lib/components/Forms/ModelForm.svelte';
import { breadcrumbObject } from '$lib/utils/stores';
import type { PageData } from './$types';
export let data: PageData;
breadcrumbObject.set(data.object);
</script>

<ModelForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
import { page } from '$app/stores';
import ModelForm from '$lib/components/Forms/ModelForm.svelte';
import { UserEditSchema } from '$lib/utils/schemas';
import { breadcrumbObject } from '$lib/utils/stores';
import type { PageData } from './$types';
import * as m from '$paraglide/messages';
export let data: PageData;
breadcrumbObject.set(data.object);
</script>

<div class="card bg-white shadow p-4">
Expand Down
Loading

0 comments on commit 73ff076

Please sign in to comment.