Skip to content

Commit

Permalink
Merge branch 'beta-2.0' into DIGG-167-beta
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Gasperini <92717862+AlessandroGasperini@users.noreply.github.com>
  • Loading branch information
AlessandroGasperini authored Jan 18, 2024
2 parents dbee740 + 90790f9 commit c78f4ca
Show file tree
Hide file tree
Showing 39 changed files with 3,010 additions and 16,657 deletions.
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Dockerfile*.*
.dockerignore
node_modules
yarn-error.log
README.md
.env
.env.local
.env.test
.env.development
.yarnrc
__ENV.js
__ENV.js
.git
12 changes: 3 additions & 9 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ PORT=3000
HOST=http://localhost:$PORT
REACT_APP_RUNTIME_ENV=dev

# Screen9 token for video player.
REACT_APP_SCREEN9_API_TOKEN=secret

LOGFILE_PATH=dataportal.log
LOGGING_LEVELS=warn,error,info
HEALTHCHECK_SECRET=1234
Expand All @@ -14,6 +11,9 @@ HTTP_PROXY=http://proxy.digg.se:8080
HTTP_PROXY_USER=secretuser
HTTP_PROXY_PASS=secretpass

# Screen9 token for video player.
REACT_APP_SCREEN9_API_TOKEN=secret

## Connect to a local backend.
#APOLLO_URL=http://localhost:1301
#REACT_APP_APOLLO_URL=http://localhost:1301
Expand All @@ -26,12 +26,6 @@ HTTP_PROXY_PASS=secretpass
#IMAGE_DOMAIN=localhost
#REACT_APP_MEDIA_BASE_URL=http://127.0.0.1:1337

## Connect to production backend (dataportal.se).
#APOLLO_URL=https://graphql.digg.se/
#REACT_APP_APOLLO_URL=https://graphql.digg.se/
#IMAGE_DOMAIN=graphql.digg.se
#REACT_APP_MEDIA_BASE_URL=https://graphql.digg.se/assets/dataportal_v1

## Connect to production backend (beta.dataportal.se).
APOLLO_URL=https://graphql.digg.se/
REACT_APP_APOLLO_URL=https://graphql.digg.se/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --build-arg delete_file="middleware.ts"
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/gitlab-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: PushRepoToGitlab
on: [push]
jobs:
pushtogitlab:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Branch name
run: echo running on branch ${GITHUB_REF_NAME}
- name: Push To Gitlab
env:
token: ${{ secrets.GITLABTOKEN }}
gitlabrepo: ${{ secrets.GITLABREPO }}
run: |
echo Starting to push repo to gitlab
git config user.name "GitHub"
git config user.email "git@digitalist.github.com"
git remote set-url origin "https://oauth2:${token}@${gitlabrepo}"
git push origin ${GITHUB_REF_NAME}
71 changes: 71 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
image: docker:20.10.16
workflow:
rules:
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
IMAGE_NAME: "$IMAGE:$TAG"
DOCKER_IMAGE: "$IMAGE_NAME"
KANIKO_CACHE_ARGS: ""

stages:
- build
- deploy
image:build:release:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
rules:
- if: $CI_COMMIT_BRANCH == "beta"
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- cat $DOCKER_AUTH_CONFIG > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile Dockerfile --destination $IMAGE:$TAG

image:build:tagged:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
rules:
- if: $CI_COMMIT_TAG
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- cat $DOCKER_AUTH_CONFIG > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile Dockerfile --destination $IMAGE:$CI_COMMIT_TAG

deploy:branch:
rules:
- if: '$CI_COMMIT_BRANCH == "beta"'
variables:
IMAGE_DATAPORTAL_WEB: $IMAGE:$TAG
stage: deploy
trigger:
project: digg/deploy-dataportal
branch: main

deploy:tag:
rules:
- if: $CI_COMMIT_TAG
variables:
IMAGE_DATAPORTAL_WEB: $IMAGE:$CI_COMMIT_TAG
stage: deploy
trigger:
project: digg/deploy-dataportal
branch: main
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Swedish data portal](https://www.dataportal.se/images/svdp-favicon-64.png)
![Swedish data portal](https://www.dataportal.se/images/svdp-favicon-64.png)
# The Swedish data portal web client – [dataportal.se](https://www.dataportal.se)
Sweden´s national data portal gathers and shares data for re-use to make it easier for users to find and explore it across sectors and domains.The portal only contains information about datasets, i.e. metadata. The actual datasets are retrieved via links for download or requested by the respective organization responsible for their own datasets. The Agency for Digital Government (DIGG) is responsible for Sweden's national data portal.

Expand All @@ -15,33 +15,39 @@ EntryScape Registry is a solution for managing a registry of data catalogs and r
![nextjs-current](https://img.shields.io/badge/nextjs-13.0.2-green)

## Development
Start by creating an ```.env.local``` file. Use the ```.env.local.example``` as template.
Start by creating an `.env.local` file. Use the `.env.local.example` as template.
(Environment variables and tokens in .env.local.example that has placeholder value of "secret" is not available here and needs to be changed to a valid value).

### Run application in development mode

Starts the application in development mode with hot-code reloading, error reporting, and more. See [Nextjs Development](https://nextjs.org/docs/app/api-reference/next-cli#development) for more information.
Run:
```sh

```sh
yarn
yarn dev
# If you are having issues connecting to your localhost port for apollo:
export NODE_OPTIONS=--dns-result-order=ipv4first
```

Visit [http://localhost:3000](http://localhost:3000) in the browser.

### Run application in production mode
Builds the application for production usage. See [Nextjs production build](https://nextjs.org/docs/app/api-reference/next-cli#build) for more info.
And Start the Next.js production server. See [Nextjs start production](https://nextjs.org/docs/app/api-reference/next-cli#production) for more info.
Run:

```sh
yarn
yarn build
yarn start
```

Visit [http://localhost:3000](http://localhost:3000) in the browser.

### Run application with Docker
Run the following to start the application with docker.

```sh
#build image
docker build . -t dataportal-web
Expand All @@ -65,13 +71,12 @@ No cache, Do a request to content backend with startpage query.
## Notes

### Stack
- [![Nextjs](https://badgen.net/badge/Nextjs/JS%20framework/blue)](https://nextjs.org/)
- [![Nextjs](https://badgen.net/badge/Nextjs/JS%20framework/blue)](https://nextjs.org/)
- [![TypeScript](https://badgen.net/badge/TypeScript/For%20static%20types/blue)](https://www.typescriptlang.org/)
- [![React](https://badgen.net/badge/React/For%20UI/blue)](https://reactjs.org/)
- [![Emotion](https://badgen.net/badge/Emotion/For%20styling/blue)](https://emotion.sh)
- [![Apollo Client](https://badgen.net/badge/Apollo%20Client/For%20federated%20content/blue)](https://www.apollographql.com/docs/react/)


### Content backend
The Swedish Dataportal consumes news and content via a GraphQL proxy. The content is
rendered with Apollo GraphQl and React. The proxy is not published on Github.
Expand All @@ -85,3 +90,10 @@ The package is published via NMP under [`@digg/design-system`](https://www.npmjs

Display of video is done via [screen9](https://screen9.com/). To be able to display videos an account from screen9 is needed and an API key.
The key for this frontend application has read access only to DIGG screen9 account.

### Sandbox editera
To test locally in the sandbox environment, set the sandbox.editera URL on lines 6, 7, and 12 in Settings.Dev.ts

Line 6: ENTRYSCAPE_SPECS_PATH="sandbox.editera.dataportal.se"
Line 7: ENTRYSCAPE_TERMS_PATH="sandbox.editera.dataportal.se"
Line 12: ENTRYSCAPE_CONCEPT_STATS_URL="https://sandbox.editera.dataportal.se/stats/entityData.json"
Binary file added assets/logos/europeiskaunionen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions components/content/ContainerPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const ContainerPage: React.FC<ContainerPageProps> = ({
{hasRelatedContent && (
<ContainerNav related={related} domain={domain} />
)}

{!image && heading && (
<Heading
size={"lg"}
Expand All @@ -158,14 +159,6 @@ export const ContainerPage: React.FC<ContainerPageProps> = ({
</Heading>
)}

<main
className={`content col-start-1 max-w-md space-y-lg md:space-y-xl
${hasRelatedContent ? "xl:col-span-1 xl:col-start-2" : ""}`}
>
<p className="text-lg text-brown-600">{checkLang(preamble)}</p>
{blocks && blocks.length > 0 && <BlockList blocks={blocks} />}
</main>

{menuItems.length > 2 && (
<div
id="stickyNav"
Expand All @@ -184,6 +177,14 @@ export const ContainerPage: React.FC<ContainerPageProps> = ({
/>
</div>
)}

<main
className={`content col-start-1 max-w-md space-y-lg md:space-y-xl
${hasRelatedContent ? "xl:col-span-1 xl:col-start-2" : ""}`}
>
<p className="text-lg text-brown-600">{checkLang(preamble)}</p>
{blocks && blocks.length > 0 && <BlockList blocks={blocks} />}
</main>
</article>
</Container>
);
Expand Down
5 changes: 4 additions & 1 deletion components/content/FormPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ export const FormPage: FC<Props> = ({ elements, module }) => {
return (
<Container>
{formDataArray[0] && (
<div className="grid grid-cols-1 lg:max-w-xl lg:grid-cols-[200px_620px_1fr] lg:gap-x-xl ">
<div
id="FormPage"
className="grid grid-cols-1 lg:max-w-xl lg:grid-cols-[200px_620px_1fr] lg:gap-x-xl "
>
{page !== 0 && formSteps.length > 0 && (
<FormNav
pageNames={[...formSteps, t("pages|form$generate-pdf-text")]}
Expand Down
6 changes: 4 additions & 2 deletions components/content/Search/SearchFilters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const FilterSearch: React.FC<FilterSearchProps> = ({
id={filterKey}
name={filterKey}
placeholder={t("search$filtersearch")}
className="border-none hover:outline-0 focus-visible:outline-0"
className="focus--in border-none"
value={filter[filterKey] || ""}
onChange={(e) => (
clearCurrentScrollPos(),
Expand Down Expand Up @@ -314,6 +314,7 @@ export const SearchFilters: React.FC<SearchFilterProps> = ({
{searchMode == "datasets" && (
<div className="relative max-w-[74px]">
<input
tabIndex={-1}
id="api_only"
name="API"
type="checkbox"
Expand Down Expand Up @@ -366,7 +367,8 @@ export const SearchFilters: React.FC<SearchFilterProps> = ({
}}
/>
<label
className="button button--small button--secondary z-2 relative cursor-pointer pr-xl"
tabIndex={0}
className="button button--small button--secondary z-2 focus--outline focus--primary relative cursor-pointer pr-xl focus-visible:bg-whiteOpaque5"
htmlFor="api_only"
>
API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ export const SearchContentPage: FC<SearchProps> = () => {
<Heading
level={3}
size="sm"
className="mb-sm font-normal text-green-600 group-hover:underline "
className={`focus--underline focus--outline focus--primary focus--out mb-sm font-normal
text-green-600 group-hover:underline`}
lang={hit.titleLang}
>
{highlightWords(hit.title)}
Expand Down
4 changes: 2 additions & 2 deletions components/content/Search/SearchResults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export const SearchResults: React.FC<SearchResultsProps> = ({
saveCurrentScrollPos();
trackSearchHitClick(hit.url || "");
}}
className="group block no-underline"
className="group block no-underline focus-visible:outline-none"
>
{hit.metadata &&
search.allFacets &&
Expand All @@ -256,7 +256,7 @@ export const SearchResults: React.FC<SearchResultsProps> = ({
<Heading
level={3}
size="sm"
className="mb-sm font-normal text-green-600 group-hover:underline "
className="focus--underline mb-sm font-normal text-green-600 group-hover:underline"
lang={hit.titleLang}
>
{hit.title}
Expand Down
Loading

0 comments on commit c78f4ca

Please sign in to comment.