Skip to content

Commit

Permalink
Merge branch 'main' into feature/III-6358
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen authored Nov 28, 2024
2 parents 0b20501 + bb3dda5 commit 65464b2
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 106 deletions.
34 changes: 17 additions & 17 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pipeline {
}

stage('Setup and build') {
agent { label 'ubuntu && 16.04 && nodejs16' }
agent { label 'ubuntu && 20.04 && nodejs16' }
environment {
GIT_SHORT_COMMIT = build.shortCommitRef()
ARTIFACT_VERSION = "${env.PIPELINE_VERSION}" + '+sha.' + "${env.GIT_SHORT_COMMIT}"
Expand All @@ -28,12 +28,12 @@ pipeline {
}
stage('Build') {
steps {
sh label: 'Build binaries', script: 'bundle exec rake uitdatabank-frontend:build'
sh label: 'Build binaries', script: 'bundle exec rake build'
}
}
stage('Build artifact') {
steps {
sh label: 'Build artifact', script: "bundle exec rake uitdatabank-frontend:build_artifact ARTIFACT_VERSION=${env.ARTIFACT_VERSION}"
sh label: 'Build artifact', script: "bundle exec rake build_artifact ARTIFACT_VERSION=${env.ARTIFACT_VERSION}"
archiveArtifacts artifacts: "pkg/*${env.ARTIFACT_VERSION}*.deb", onlyIfSuccessful: true
}
}
Expand Down Expand Up @@ -67,59 +67,59 @@ pipeline {
APPLICATION_ENVIRONMENT = 'development'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
}
}

stage('Deploy to acceptance') {
agent any
agent { label 'ubuntu && 20.04' }
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'acceptance'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'udb3-web-acc02', timeout: 600
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
triggerDeployment nodeName: 'uitdatabank-web-acc01', timeout: 600
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${util.getJobDisplayName()} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
}
}

stage('Deploy to testing') {
input { message "Deploy to Testing?" }
agent any
agent { label 'ubuntu && 20.04' }
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'testing'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'udb3-web-test03', timeout: 600
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
triggerDeployment nodeName: 'uitdatabank-web-test01', timeout: 600
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${util.getJobDisplayName()} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
}
}

stage('Deploy to production') {
input { message "Deploy to Production?" }
agent any
agent { label 'ubuntu && 20.04' }
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'production'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'udb3-web-prod03', timeout: 600
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'focal'
triggerDeployment nodeName: 'uitdatabank-web-prod01', timeout: 600
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${util.getJobDisplayName()} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
cleanup {
cleanupAptlySnapshots repository: env.REPOSITORY_NAME
Expand All @@ -128,7 +128,7 @@ pipeline {
}

stage('Tag release') {
agent { label 'ubuntu && 16.04' }
agent any
steps {
copyArtifacts filter: 'pkg/*.deb', projectName: env.JOB_NAME, flatten: true, selector: specific(env.BUILD_NUMBER)
tagRelease commitHash: artifact.metadata(artifactFilter: '*.deb', field: 'git-ref')
Expand Down
7 changes: 7 additions & 0 deletions lib/tasks/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
desc "Build binaries"
task :build do |task|
system('yarn install') or exit 1
system('yarn build') or exit 1
system('rm -rf node_modules') or exit 1
system('yarn install --production') or exit 1
end
34 changes: 34 additions & 0 deletions lib/tasks/build_artifact.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
desc "Create a debian package from the binaries."
task :build_artifact do |task|

calver_version = ENV['PIPELINE_VERSION'].nil? ? Time.now.strftime("%Y.%m.%d.%H%M%S") : ENV['PIPELINE_VERSION']
git_short_ref = `git rev-parse --short HEAD`.strip
version = ENV['ARTIFACT_VERSION'].nil? ? "#{calver_version}+sha.#{git_short_ref}" : ENV['ARTIFACT_VERSION']
artifact_name = 'uitdatabank-frontend'
vendor = 'publiq VZW'
maintainer = 'Infra publiq <[email protected]>'
license = 'Apache-2.0'
description = 'Frontend for UiTdatabank'
source = 'https://github.com/cultuurnet/udb3-frontend'
build_url = ENV['JOB_DISPLAY_URL'].nil? ? '' : ENV['JOB_DISPLAY_URL']

FileUtils.mkdir_p('pkg')

system('touch .env') or exit 1

system("fpm -s dir -t deb -n #{artifact_name} -v #{version} -a all -p pkg \
-x '.git*' -x pkg -x vendor -x lib -x Rakefile -x Gemfile -x Gemfile.lock \
-x .bundle -x 'Jenkinsfile*' \
--prefix /var/www/udb3-frontend \
--config-files /var/www/udb3-frontend/.env \
--deb-systemd lib/tasks/uitdatabank-frontend.service \
--before-remove lib/tasks/prerm \
--deb-user www-data --deb-group www-data \
--description '#{description}' --url '#{source}' --vendor '#{vendor}' \
--license '#{license}' -m '#{maintainer}' \
--deb-field 'Pipeline-Version: #{calver_version}' \
--deb-field 'Git-Ref: #{git_short_ref}' \
--deb-field 'Build-Url: #{build_url}' \
."
) or exit 1
end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
User=www-data
Group=www-data
PIDFile=/var/run/udb3-frontend.pid
Environment=NEXT_HOST=localhost
PIDFile=/var/run/uitdatabank-frontend.pid
Environment=NEXT_HOST=127.0.0.1
Environment=NEXT_PORT=4000
EnvironmentFile=-/etc/default/udb3-frontend
EnvironmentFile=-/etc/default/uitdatabank-frontend
WorkingDirectory=/var/www/udb3-frontend
ExecStart=/usr/bin/node node_modules/next/dist/bin/next start -H ${NEXT_HOST} -p ${NEXT_PORT}
Restart=on-failure
Expand Down
9 changes: 0 additions & 9 deletions lib/tasks/uitdatabank-frontend/build.rake

This file was deleted.

36 changes: 0 additions & 36 deletions lib/tasks/uitdatabank-frontend/build_artifact.rake

This file was deleted.

38 changes: 38 additions & 0 deletions src/hooks/api/ownerships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export type OwnershipRequest = {
state: RequestState;
};

export type OwnershipCreator = {
userId: string;
email: string;
};

export const RequestState = {
APPROVED: 'approved',
REQUESTED: 'requested',
Expand Down Expand Up @@ -129,9 +134,42 @@ const useDeleteOwnershipRequestMutation = (configuration = {}) =>
...configuration,
});

const getOwnershipCreator = async ({ headers, organizerId }) => {
const res = await fetchFromApi({
path: `/organizers/${organizerId}/creator`,
options: {
headers,
},
});
if (isErrorObject(res)) {
// eslint-disable-next-line no-console
return console.error(res);
}
return await res.json();
};

type UseGetOwnershipCreatorArguments = ServerSideQueryOptions & {
organizerId: string;
};

const useGetOwnershipCreatorQuery = (
{ req, queryClient, organizerId }: UseGetOwnershipCreatorArguments,
configuration: UseQueryOptions = {},
) =>
useAuthenticatedQuery<OwnershipCreator>({
req,
queryClient,
queryKey: ['ownership-creator'],
queryFn: getOwnershipCreator,
queryArguments: { organizerId },
refetchOnWindowFocus: false,
...configuration,
});

export {
useApproveOwnershipRequestMutation,
useDeleteOwnershipRequestMutation,
useGetOwnershipCreatorQuery,
useGetOwnershipRequestsQuery,
useRejectOwnershipRequestMutation,
useRequestOwnershipMutation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { useTranslation } from 'react-i18next';

import { OwnershipRequest } from '@/hooks/api/ownerships';
import { OwnershipCreator, OwnershipRequest } from '@/hooks/api/ownerships';
import { Inline } from '@/ui/Inline';
import { List } from '@/ui/List';
import { Stack } from '@/ui/Stack';
import { colors, getValueFromTheme } from '@/ui/theme';
import { Title } from '@/ui/Title';

type Props = {
creator?: OwnershipCreator;
requests: OwnershipRequest[];
renderActions: (request: OwnershipRequest) => JSX.Element;
};

const getGlobalValue = getValueFromTheme('global');

export const OwnershipsTable = ({ requests, renderActions }: Props) => {
export const OwnershipsTable = ({
creator,
requests,
renderActions,
}: Props) => {
const { grey3 } = colors;
const { t } = useTranslation();
return (
Expand All @@ -39,14 +44,14 @@ export const OwnershipsTable = ({ requests, renderActions }: Props) => {
<Title size={3}>{t('organizers.ownerships.table.user')}</Title>
<Title size={3}>{t('organizers.ownerships.table.actions.title')}</Title>
</Inline>
<List>
<List paddingY={3}>
<List.Item>{creator.email}</List.Item>
{requests.map((request) => (
<Inline
key={request.id}
role="row"
justifyContent="space-between"
alignItems="center"
paddingY={3}
css={`
&:not(:last-child) {
border-bottom: 1px solid ${grey3};
Expand Down
Loading

0 comments on commit 65464b2

Please sign in to comment.