-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add details page to dataset-catalog
- Loading branch information
Showing
32 changed files
with
1,112 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...set-catalog/app/catalogs/[catalogId]/datasets/[datasetId]/dataset-details-page-client.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
'use client'; | ||
|
||
import { Dataset, DatasetSeries, ReferenceData } from '@catalog-frontend/types'; | ||
import { DeleteButton, DetailsPageLayout, LinkButton } from '@catalog-frontend/ui'; | ||
import { getTranslateText, localization } from '@catalog-frontend/utils'; | ||
import { useState } from 'react'; | ||
import styles from './dataset-details-page.module.css'; | ||
import { RightColumn } from '../../../../../components/details-page-columns/details-page-right-column'; | ||
import { LeftColumn } from '../../../../../components/details-page-columns/details-page-left-column'; | ||
import { deleteDataset } from '../../../../actions/actions'; | ||
import { Tag } from '@digdir/designsystemet-react'; | ||
|
||
interface datasetDetailsPageProps { | ||
dataset: Dataset; | ||
catalogId: string; | ||
datasetId: string; | ||
hasWritePermission: boolean; | ||
searchEnv: string; | ||
referenceDataEnv: string; | ||
referenceData: ReferenceData; | ||
datasetSeries: DatasetSeries[]; | ||
} | ||
|
||
const DatasetDetailsPageClient = ({ | ||
dataset, | ||
catalogId, | ||
datasetId, | ||
hasWritePermission, | ||
searchEnv, | ||
referenceDataEnv, | ||
referenceData, | ||
datasetSeries, | ||
}: datasetDetailsPageProps) => { | ||
const [language, setLanguage] = useState('nb'); | ||
|
||
const handleLanguageChange = (value: string) => { | ||
setLanguage(value); | ||
}; | ||
|
||
const handleDeleteDataset = async () => { | ||
if (dataset) { | ||
if (window.confirm(localization.serviceCatalog.form.confirmDelete)) { | ||
try { | ||
await deleteDataset(catalogId, dataset.id); | ||
} catch (error) { | ||
window.alert(error); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
enum StatusColors { | ||
DRAFT = 'second', | ||
PUBLISH = 'success', | ||
APPROVE = 'info', | ||
} | ||
|
||
return ( | ||
<DetailsPageLayout | ||
handleLanguageChange={handleLanguageChange} | ||
language={language} | ||
headingTitle={getTranslateText(dataset?.title ?? '', language)} | ||
headingTag={ | ||
<Tag | ||
size='md' | ||
color={StatusColors[dataset.registrationStatus]} | ||
> | ||
{localization.datasetForm.status[dataset.registrationStatus]} | ||
</Tag> | ||
} | ||
loading={false} | ||
> | ||
<DetailsPageLayout.Left> | ||
<LeftColumn | ||
dataset={dataset} | ||
referenceDataEnv={referenceDataEnv} | ||
searchEnv={searchEnv} | ||
referenceData={referenceData} | ||
datasetSeries={datasetSeries} | ||
/> | ||
</DetailsPageLayout.Left> | ||
<DetailsPageLayout.Right> | ||
<RightColumn | ||
dataset={dataset} | ||
hasWritePermission={hasWritePermission} | ||
/> | ||
</DetailsPageLayout.Right> | ||
<DetailsPageLayout.Buttons> | ||
{hasWritePermission && ( | ||
<div className={styles.set}> | ||
<LinkButton href={`/catalogs/${catalogId}/datasets/${datasetId}/edit`}> | ||
{localization.button.edit} | ||
</LinkButton> | ||
|
||
<DeleteButton | ||
variant='secondary' | ||
onClick={() => handleDeleteDataset()} | ||
/> | ||
</div> | ||
)} | ||
</DetailsPageLayout.Buttons> | ||
</DetailsPageLayout> | ||
); | ||
}; | ||
|
||
export default DatasetDetailsPageClient; |
5 changes: 5 additions & 0 deletions
5
...set-catalog/app/catalogs/[catalogId]/datasets/[datasetId]/dataset-details-page.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.set { | ||
display: flex; | ||
gap: 0.5rem; | ||
padding-bottom: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-catalog/components/dataset-form/components/details-section/recommended-detail-fields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/dataset-catalog/components/dataset-form/components/details-section/temporal-modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.