Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hknots committed Aug 1, 2024
2 parents 7508373 + 53cf4e6 commit f852c51
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 27 deletions.
17 changes: 8 additions & 9 deletions app/routes/adapter.$name/AdapterDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DeleteAdapter } from './DeleteAdapter';
import { GeneralDetailView } from './GeneralDetailView';
import { BackButton } from '~/components/shared/BackButton';
import { DeleteModal } from '~/components/shared/DeleteModal';
import ComponentSelector from './ComponentSelector';

export function AdapterDetail({ adapter }: { adapter: IAdapter }) {
const { components } = useLoaderData<{ components: IComponent[] }>();
Expand Down Expand Up @@ -58,15 +59,13 @@ export function AdapterDetail({ adapter }: { adapter: IAdapter }) {
allDetails={allDetails}
/>
<Divider className="pt-3" />
<VStack>
<Heading size="medium" spacing>
Komponenter
</Heading>
<ComponentsTable
components={components}
selectedComponents={selectedComponents}
/>
</VStack>
<ComponentSelector
items={components}
selectedItems={adapter.components.map((a) => {
const match = a.match(/cn=([^,]+)/);
return match ? match[1] : '';
})}
/>
<DeleteModal
title="Slett adapter"
bodyText="Er du sikker på at du vil slette dette adapteret?"
Expand Down
49 changes: 49 additions & 0 deletions app/routes/adapter.$name/ComponentSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { Box, Heading, HGrid } from '@navikt/ds-react';
import { useSubmit } from '@remix-run/react';
import { IClient } from '~/types/Clients';
import { IComponent } from '~/types/Component';
import ComponentsTable from '../komponenter._index/ComponentsTable';

interface ComponentSelectorProps {
items: IComponent[];
selectedItems: string[];
}

const ComponentSelector: React.FC<ComponentSelectorProps> = ({ items, selectedItems }) => {
const submit = useSubmit();

return (
<>
<Box padding="4">
<HGrid gap="8">
<Heading size="medium" spacing>
Komponenter tilknyttet ressurs
</Heading>
<ComponentsTable components={items} selectedComponents={selectedItems} />
{/* <ClientTable
clients={items}
selectable
selectedItems={selectedItems}
toggleSwitch={(name, isChecked) => {
submit(
{
clientName: name,
updateType: isChecked ? 'add' : 'remove',
actionType: 'UPDATE_CLIENT_IN_ASSET',
},
{
method: 'POST',
action: 'update',
navigate: false,
}
);
}}
/> */}
</HGrid>
</Box>
</>
);
};

export default ComponentSelector;
26 changes: 10 additions & 16 deletions app/routes/komponenter._index/ComponentsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,33 @@ const ComponentsTable: React.FC<ComponentsSectionProps> = ({
<Table key={chunkIndex} size={'small'}>
<Table.Body>
{chunk.map((component, index) => (
<Table.Row
key={index}
onClick={() => handleRowClick(component)}>
{/*<Table.DataCell>*/}
{/* /!*<Label>{component.description}</Label>*!/*/}
{/* <Detail>{component.basePath}</Detail>*/}
{/*</Table.DataCell>*/}
<Table.Row key={index}>
<Table.DataCell>
<Switch
checked={selectedComponents.includes(component.dn)}
onChange={() => {}}
// hideLabel={true}
// position="right"
>
<Label>{component.description}</Label>
<Detail>{component.basePath}</Detail>
onChange={() => {}}>
{''}
</Switch>
</Table.DataCell>
<Table.DataCell>
<Table.DataCell onClick={() => handleRowClick(component)}>
<Label>{component.description}</Label>
<Detail>{component.basePath}</Detail>
</Table.DataCell>
<Table.DataCell onClick={() => handleRowClick(component)}>
{component.common && (
<Tag variant="info" size={'xsmall'}>
Felles
</Tag>
)}
</Table.DataCell>
<Table.DataCell>
<Table.DataCell onClick={() => handleRowClick(component)}>
{component.openData && (
<Tag variant="neutral" size={'xsmall'}>
Åpne Data
</Tag>
)}
</Table.DataCell>
<Table.DataCell>
<Table.DataCell onClick={() => handleRowClick(component)}>
<ChevronRightIcon
title="a11y-title"
fontSize="1.5rem"
Expand Down
4 changes: 2 additions & 2 deletions app/routes/user/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export let loader = async () => {

export default function Index() {
const user = useLoaderData<IMeData>();
const breadcrumbs = [{ name: 'Test Page', link: '/test' }];
// const breadcrumbs = [{ name: 'Profile', link: '/user' }];

return (
<div>
<Breadcrumbs breadcrumbs={breadcrumbs} />
{/* <Breadcrumbs breadcrumbs={breadcrumbs} /> */}
<InternalPageHeader title={'User Information'} icon={PersonIcon} />
<div style={{ marginBottom: '1rem' }}>
<Label>Full Name:</Label>
Expand Down

0 comments on commit f852c51

Please sign in to comment.