Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

923 add support for categories for software #946

Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
f8df9c6
feat: add UI component for software categories (#923)
fembau Jun 27, 2023
c3485e2
feat: add tables and views for categories (#923)
fembau Jul 11, 2023
a593a92
feat: edit software categories (#923)
fembau Jul 12, 2023
0fd697f
fix: db constraints, policies; update UI
fembau Jul 18, 2023
76b8e0e
fine-tuning (#923)
fembau Jul 20, 2023
59fefd3
Merge remote-tracking branch 'origin/main' into 923-add-support-for-c…
fembau Jul 20, 2023
0148605
update TODOs
fembau Jul 20, 2023
769ed58
update licenses
fembau Jul 20, 2023
e70c755
small fixes
fembau Jul 20, 2023
68c5878
fix type error
fembau Jul 21, 2023
8fbb246
Merge remote-tracking branch 'origin/main' into 923-add-support-for-c…
fembau Jul 21, 2023
936627c
add policy for `category`
fembau Jul 25, 2023
12b324b
feat: upgrade to postgres 15
ewan-escience Jul 21, 2023
bf58fdf
chore(release): update citation file
jmaassen Jul 26, 2023
ad6e072
update policy for `category`
fembau Jul 26, 2023
ce66d6e
remove workaround for pgsql 14
fembau Jul 26, 2023
b7b9381
add sanitizers for category
fembau Jul 28, 2023
ac67358
add more UI examples
fembau Jul 31, 2023
5c291cf
add test categories
fembau Aug 1, 2023
7439667
UI fix
fembau Aug 1, 2023
7e5708d
feat: software overview page v2
dmijatovic Jun 9, 2023
e8ead90
feat: add country and short description to organisation card and cons…
dmijatovic Jun 15, 2023
fd0b7ef
Added real organization logos to data-generation set
jmaassen Jun 16, 2023
9d512ae
fix: use logos in data generation for organisations
ewan-escience Jun 16, 2023
70ebac3
Added software logos
jmaassen Jun 19, 2023
ee8a5e1
fix: use software logos in data generation
ewan-escience Jun 19, 2023
48264fa
fix: sometimes have no image for different entities in data generation
ewan-escience Jun 19, 2023
d84d286
Fixed the licenses to properly refect owners
jmaassen Jun 22, 2023
4f8c84d
Fixed the licenses to properly refect owners
jmaassen Jun 22, 2023
b48a2b4
Calculate distance between left an centered container (#918)
ctwhome Jun 23, 2023
8b84327
feat: organisation page v2 design implementation
dmijatovic Jun 29, 2023
2a73074
chore: upgrade dependencies
dmijatovic Jul 3, 2023
22faf36
e2e: fix broken e2e test and recover lost fake api calls commit
dmijatovic Jul 4, 2023
da5e988
fix: release date, show message when no release date instead 1-1-1970
dmijatovic Jul 4, 2023
005952f
fix: show 404 page for non-existing organisation/research unit
dmijatovic Jul 4, 2023
d35128a
chore!: bump frontend version to 2.0.0 after software,project and org…
dmijatovic Jul 4, 2023
d67776c
chore: clean unused imports code and files using unimported library
dmijatovic Jul 6, 2023
1edc03e
fix: duplicate project entries per organisation
dmijatovic Jul 6, 2023
7e5d4e6
chore: add unimported lib for checking unused files/components
dmijatovic Jul 6, 2023
22ea36d
feat: add order on project title
dmijatovic Jul 6, 2023
a9b7c6e
feat: link to software and project page with default order on mention…
dmijatovic Jul 7, 2023
77fc31f
fix: group software metric values bottom right
dmijatovic Jul 11, 2023
7e68c7c
ui: add Software Hightlights text
dmijatovic Jul 11, 2023
71589ef
fix: null contributors/mentions in masonry card stats
dmijatovic Jul 11, 2023
0d31105
chore: upgrade eslint to support latest version of typescript
dmijatovic Aug 8, 2023
4f4d6b3
feat: add project status filter to project overview and organisation …
dmijatovic Aug 15, 2023
6e20407
chore: remove test pattern from exclude as it is automatically added …
dmijatovic Aug 15, 2023
7ccfc10
Merge pull request #964 from research-software-directory/934-project-…
dmijatovic Aug 15, 2023
f1ad4d9
feat: add verified organisation badge and claim organisation button
dmijatovic Aug 15, 2023
7cc0b0b
refactor: do not show project period component only when both date ar…
dmijatovic Aug 17, 2023
4d442dd
Merge pull request #968 from research-software-directory/938-verified…
dmijatovic Aug 17, 2023
8a12508
refactor: implement sonar suggestions in admin, projects, software, u…
dmijatovic Aug 21, 2023
a9dc400
Merge pull request #969 from research-software-directory/rsd-v2-relea…
dmijatovic Aug 21, 2023
ab1edac
tests: additional unit tests
dmijatovic Aug 21, 2023
c6d28b1
Merge remote-tracking branch 'origin/rsd-v2-release' into 923-add-sup…
fembau Aug 28, 2023
6677fc5
core: follow prefered way to install yarn
fembau Aug 28, 2023
964df25
workaround: node option --inspect is broken
fembau Aug 29, 2023
f393aa4
fix lint format warnings
fembau Aug 29, 2023
7216ac9
chore: fix/update VSCode project settings for ESLint and formating
fembau Aug 29, 2023
6acf3ab
chore: fix linter warnings
fembau Aug 31, 2023
e80633f
feat: adds global announcements
Aug 22, 2023
0ad1cb9
refactor: basic announcement setup extract api calls from ui componen…
dmijatovic Aug 28, 2023
f9caa21
test: create basic tests for announcement components
dmijatovic Aug 28, 2023
a9704a7
fix: font color used in admin keyword and rsd-contributors tables
dmijatovic Aug 29, 2023
37d25da
Merge pull request #972 from research-software-directory/fix-vscode-p…
fembau Sep 1, 2023
8244c8c
refactor: cache login providers after intial api call
dmijatovic Aug 29, 2023
3e459cc
refactor: use more efficient mentions queries as advised in #955
dmijatovic Aug 29, 2023
51abed5
fix: highlight carousel cumulative layout shift when calculating firs…
dmijatovic Aug 31, 2023
b5cdcc0
chore: upgrade fe image to use node v20 and bump fe version
dmijatovic Aug 31, 2023
ace963c
Merge remote-tracking branch 'origin/rsd-v2-release' into 923-add-sup…
fembau Sep 1, 2023
5246854
audit: increase max-age for image cache to 1yr based on lighthouse a…
dmijatovic Sep 1, 2023
136f411
audit: use explicit image size in cards and logos, based on lighthous…
dmijatovic Sep 1, 2023
07104a4
Merge pull request #973 from research-software-directory/955-improve-…
dmijatovic Sep 1, 2023
a567a45
minor: remove wrong license and apply suggestions
cmeessen Sep 1, 2023
56634b3
Merge pull request #970 from research-software-directory/maintenance-…
cmeessen Sep 4, 2023
9dcc5a1
lighthouse: add arial labels to admin buttons.
dmijatovic Sep 4, 2023
a07ed9e
Merge pull request #977 from research-software-directory/976-lighthou…
dmijatovic Sep 4, 2023
844de08
fe: update UI components
fembau Sep 4, 2023
c7e1dae
chore: update license info
fembau Sep 4, 2023
8ab3e14
lighthouse: change csp values adviced during audit
dmijatovic Sep 4, 2023
cffb052
fix: image scaling on participating organisations and software card (…
dmijatovic Sep 5, 2023
5507dfc
fix: software pinnen filter
dmijatovic Sep 5, 2023
48416c1
be: cleaned up sample data
fembau Sep 5, 2023
45fcd40
feat: add icon for category
fembau Sep 5, 2023
222a75a
fix: showing one software/project on multiple pages during the pagina…
dmijatovic Sep 5, 2023
033a498
fix: remove pinned order from project overview and set is as default …
dmijatovic Sep 5, 2023
2eac99f
fe: update/fix design
fembau Sep 5, 2023
1f81bd2
chore: extend CSP based on audit suggestion
dmijatovic Sep 5, 2023
fb60134
refactor: only show organisation member badge, do not offer claim org…
dmijatovic Sep 5, 2023
48ff209
chore: fix linter warnings
dmijatovic Sep 5, 2023
70ae400
clean-up code and design fixes
fembau Sep 6, 2023
1df101d
Merge remote-tracking branch 'origin/rsd-v2-release' into 923-add-sup…
fembau Sep 6, 2023
92b7603
test: fix tests
fembau Sep 7, 2023
829b3af
clean up code
fembau Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions TODOs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

TODOs for category feature
==========================

- add backend test? how?
- how should be abbreviate some of these long category names?
- the API calling functions have a lot of copy&paste code. Let's create some generic helper functions for API calls
153 changes: 153 additions & 0 deletions database/007-create-keyword-and-category.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
-- SPDX-FileCopyrightText: 2022 Ewan Cahen (Netherlands eScience Center) <[email protected]>
-- SPDX-FileCopyrightText: 2022 Netherlands eScience Center
-- SPDX-FileCopyrightText: 2023 Felix Mühlbauer (GFZ) <[email protected]>
-- SPDX-FileCopyrightText: 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
--
-- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: EUPL-1.2

--------------
-- Keywords --
--------------

CREATE TABLE keyword (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
value CITEXT UNIQUE CHECK (value ~ '^\S+( \S+)*$')
);

CREATE FUNCTION sanitise_insert_keyword() RETURNS TRIGGER LANGUAGE plpgsql AS
$$
BEGIN
NEW.id = gen_random_uuid();
return NEW;
END
$$;

CREATE TRIGGER sanitise_insert_keyword BEFORE INSERT ON keyword FOR EACH ROW EXECUTE PROCEDURE sanitise_insert_keyword();


CREATE FUNCTION sanitise_update_keyword() RETURNS TRIGGER LANGUAGE plpgsql AS
$$
BEGIN
NEW.id = OLD.id;
return NEW;
END
$$;

CREATE TRIGGER sanitise_update_keyword BEFORE UPDATE ON keyword FOR EACH ROW EXECUTE PROCEDURE sanitise_update_keyword();


CREATE TABLE keyword_for_software (
software UUID references software (id),
keyword UUID references keyword (id),
PRIMARY KEY (software, keyword)
);

CREATE TABLE keyword_for_project (
project UUID references project (id),
keyword UUID references keyword (id),
PRIMARY KEY (project, keyword)
);

-- ADD basic keywords from topics and tags
INSERT into keyword (value)
VALUES
('Big data'),
('GPU'),
('High performance computing'),
('Image processing'),
('Inter-operability & linked data'),
('Machine learning'),
('Multi-scale & multi model simulations'),
('Optimized data handling'),
('Real time data analysis'),
('Text analysis & natural language processing'),
('Visualization'),
('Workflow technologies');

----------------
-- Categories --
----------------

CREATE TABLE category (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
parent UUID REFERENCES category DEFAULT NULL,
short_name VARCHAR NOT NULL,
name VARCHAR NOT NULL
-- We need postgresql 15 for "NULLS NOT DISTINCT" :(
-- UNIQUE NULLS NOT DISTINCT (parent, short_name),
-- UNIQUE NULLS NOT DISTINCT (parent, name)
);
-- workaround: for postgrsql <15 for "NULLS NOT DISTINCT"
CREATE UNIQUE INDEX category_parent_short_name_key1 ON category (parent, short_name) WHERE parent IS NOT NULL;
CREATE UNIQUE INDEX category_parent_short_name_key2 ON category (short_name) WHERE parent IS NULL;
CREATE UNIQUE INDEX category_parent_name_key1 ON category (parent, name) WHERE parent IS NOT NULL;
CREATE UNIQUE INDEX category_parent_name_key2 ON category (name) WHERE parent IS NULL;
-- workaround END

CREATE TABLE category_for_software (
software_id UUID references software (id),
category_id UUID references category (id),
PRIMARY KEY (software_id, category_id)
);

CREATE FUNCTION category_path(category_id UUID)
RETURNS TABLE (like category)
LANGUAGE SQL STABLE AS
$$
WITH RECURSIVE cat_path AS (
SELECT *, 1 AS r_index
FROM category WHERE id = category_id
UNION ALL
SELECT category.*, cat_path.r_index+1
FROM category
JOIN cat_path
ON category.id = cat_path.parent
)
-- TODO: How can we reverse the output rows without injecting a new column
-- Now we have to list all columns of `category` explicitely
-- I want to have something like `* without 'r_index'` to be independant from modifications of `category`
SELECT id, parent, short_name, name
FROM cat_path
ORDER BY r_index DESC;
$$;

-- returns a list of `category` entries traversing from the tree root to entry with `category_id`
CREATE FUNCTION category_path_expanded(category_id UUID)
RETURNS JSON
LANGUAGE SQL STABLE AS
$$
SELECT json_agg(row_to_json) AS path FROM (SELECT row_to_json(category_path(category_id))) AS cats;
$$;


CREATE FUNCTION category_paths_by_software_expanded(software_id UUID)
RETURNS JSON
LANGUAGE SQL STABLE AS
$$
WITH
cat_ids AS
(SELECT category_id FROM category_for_software AS c4s WHERE c4s.software_id = category_paths_by_software_expanded.software_id),
paths as
(SELECT category_path_expanded(category_id) AS path FROM cat_ids)
SELECT
CASE WHEN EXISTS(SELECT 1 FROM cat_ids) THEN (SELECT json_agg(path) FROM paths)
ELSE '[]'::json
END as result
$$;


CREATE FUNCTION available_categories_expanded()
RETURNS JSON
LANGUAGE SQL STABLE AS
$$
WITH
cat_ids AS
(SELECT id AS category_id FROM category AS node WHERE NOT EXISTS (SELECT 1 FROM category AS sub WHERE node.id = sub.parent)),
paths AS
(SELECT category_path_expanded(category_id) AS path FROM cat_ids)
SELECT
CASE WHEN EXISTS(SELECT 1 FROM cat_ids) THEN (SELECT json_agg(path) AS result FROM paths)
ELSE '[]'::json
END
$$
59 changes: 0 additions & 59 deletions database/007-create-keyword.sql

This file was deleted.

24 changes: 24 additions & 0 deletions database/020-row-level-security.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
-- SPDX-FileCopyrightText: 2021 - 2023 Netherlands eScience Center
-- SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all)
-- SPDX-FileCopyrightText: 2022 - 2023 dv4all
-- SPDX-FileCopyrightText: 2023 Felix Mühlbauer (GFZ) <[email protected]>
-- SPDX-FileCopyrightText: 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
--
-- SPDX-License-Identifier: Apache-2.0
-- SPDX-License-Identifier: EUPL-1.2

-- maintainer tables
ALTER TABLE maintainer_for_software ENABLE ROW LEVEL SECURITY;
Expand Down Expand Up @@ -273,6 +276,27 @@ CREATE POLICY admin_all_rights ON testimonial TO rsd_admin
USING (TRUE)
WITH CHECK (TRUE);

-- categories for software

ALTER TABLE category_for_software ENABLE ROW LEVEL SECURITY;

-- allow everybody to read metadata of published software
CREATE POLICY anyone_can_read ON category_for_software
FOR SELECT
TO rsd_web_anon, rsd_user
USING (EXISTS(SELECT 1 FROM software WHERE id = software_id AND is_published = TRUE));

-- allow software maintainers to have read/write access to their software
CREATE POLICY maintainer_all_rights ON category_for_software
TO rsd_user
USING (software_id IN (SELECT * FROM software_of_current_maintainer()));

-- allow admins to have full read/write access
CREATE POLICY admin_all_rights ON category_for_software
TO rsd_admin
USING (TRUE);


-- keywords
ALTER TABLE keyword ENABLE ROW LEVEL SECURITY;

Expand Down
56 changes: 56 additions & 0 deletions database/999-add-hgf-categories.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- SPDX-FileCopyrightText: 2023 Felix Mühlbauer (GFZ) <[email protected]>
-- SPDX-FileCopyrightText: 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
--
-- SPDX-License-Identifier: EUPL-1.2

-- THIS FILE SHOULD BE MOVED TO THE DEPLOMENT REPO AND USED AS A MIGRATION FILE

CREATE FUNCTION add_category(parent_name varchar, parent_short_name varchar, sub_categories varchar[][])
RETURNS TABLE (LIKE category)
LANGUAGE plpgsql
AS $$
DECLARE parent_id uuid;
DECLARE category varchar[];
BEGIN
INSERT INTO category(short_name, name) VALUES (parent_short_name, parent_name)
RETURNING id INTO parent_id;
FOREACH category SLICE 1 IN ARRAY sub_categories LOOP
INSERT INTO category(parent, short_name, name) VALUES (parent_id, category[1], category[2]);
END LOOP;
END
$$;

SELECT add_category('Research fields', 'Research fields',
ARRAY[
['Energy', 'Energy'],
['E&E', 'Earth and Environment'],
['Health', 'Health'],
['Information', 'Information'],
['AST', 'Aeronautics, Space and Transport'],
['Matter', 'Matter']
]
);

SELECT add_category('POF IV', 'Program-oriented Funding IV',
ARRAY[
['Energy System Design', 'Energy System Design (Energy)'],
['Materials and Technologies for the Energy Transition', 'Materials and Technologies for the Energy Transition (Energy)'],
['Fusion', 'Fusion (Energy)'],
['Nuclear Waste Management, Safety, and Radiation Research', 'Nuclear Waste Management, Safety, and Radiation Research (Energy)'],
['Changing Earth – Sustaining our Future', 'Changing Earth – Sustaining our Future (Earth and Environment)'],
['Cancer Research', 'Cancer Research (Health)'],
['Environment-related and Metabolic Diseases', 'Environment-related and Metabolic Diseases (Health)'],
['Systemic Medicine and Cardiovascular Diseases', 'Systemic Medicine and Cardiovascular Diseases (Health)'],
['Infection Research', 'Infection Research (Health)'],
['Neurodegenerative Diseases', 'Neurodegenerative Diseases (Health)'],
['Engineering Digital Futures', 'Engineering Digital Futures (Information)'],
['Natural, Artificial, and Cognitive Information Processing', 'Natural, Artificial, and Cognitive Information Processing (Information)'],
['Materials Systems Engineering', 'Materials Systems Engineering (Information)'],
['Aeronautics', 'Aeronautics (Aeronautics, Space, and Transport)'],
['Space', 'Space (Aeronautics, Space, and Transport)'],
['Transport', 'Transport (Aeronautics, Space, and Transport)'],
['Matter and the Universe', 'Matter and the Universe (Matter)'],
['Matter and Technologies', 'Matter and Technologies (Matter)'],
['From Matter to Materials and Life', 'From Matter to Materials and Life (Matter)']
]
);
14 changes: 9 additions & 5 deletions frontend/components/software/AboutSection.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
// SPDX-FileCopyrightText: 2021 - 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2021 - 2023 dv4all
// SPDX-FileCopyrightText: 2022 - 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
// SPDX-FileCopyrightText: 2022 Christian Meeßen (GFZ) <[email protected]>
// SPDX-FileCopyrightText: 2022 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
// SPDX-FileCopyrightText: 2023 Felix Mühlbauer (GFZ) <[email protected]>
//
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: EUPL-1.2

import {License, ProgramingLanguages, CodePlatform, KeywordForSoftware} from '../../types/SoftwareTypes'
import {License, ProgramingLanguages, CodePlatform, KeywordForSoftware, CategoriesForSoftware} from '../../types/SoftwareTypes'
import PageContainer from '../layout/PageContainer'
import AboutStatement from './AboutStatement'
import SoftwareKeywords from './SoftwareKeywords'
import AboutLanguages from './AboutLanguages'
import AboutLicense from './AboutLicense'
import AboutSourceCode from './AboutSourceCode'
import SoftwareLogo from './SoftwareLogo'
import { SoftwareCategoriesWithHeadline } from './SoftwareCategories'

type AboutSectionType = {
brand_name: string
description: string
description_type: 'link' | 'markdown'
keywords: KeywordForSoftware[]
categories: CategoriesForSoftware
licenses: License[]
repository: string | null
platform: CodePlatform
languages: ProgramingLanguages,
languages: ProgramingLanguages
image_id: string | null
}


export default function AboutSection(props:AboutSectionType) {
const {
brand_name = '', description = '', keywords, licenses,
brand_name = '', description = '', keywords, categories, licenses,
repository, languages, platform, description_type = 'markdown',
image_id
} = props
Expand Down Expand Up @@ -58,6 +61,7 @@ export default function AboutSection(props:AboutSectionType) {
</div>
<div className="flex-1">
{getSoftwareLogo()}
<SoftwareCategoriesWithHeadline categories={categories} />
<SoftwareKeywords keywords={keywords || []} />
<AboutLanguages languages={languages} platform={platform} />
<AboutLicense license={license || []} />
Expand Down
Loading