Skip to content

Commit

Permalink
Rebranding (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr authored Sep 2, 2024
2 parents 0e8b6b5 + f96e0a0 commit 4595dde
Show file tree
Hide file tree
Showing 136 changed files with 9,043 additions and 3,889 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4

- name: Start db and api's
run: docker compose up --wait stac-browser db interlis-check-service geopilot
run: docker compose up --wait

- name: Cypress run
uses: cypress-io/github-action@v6
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
- First registered user is granted administrator privileges.
- Updated to .NET 8.0.
- The app now runs on port 8080 inside the docker container.
- Redesigned complete application.
- **BREAKING** Renamed various public files:
- `info-hilfe.md` -> `info.md`
- `impressum.md` -> `imprint.md`
- `datenschutz.md` -> `privacy-policy.md`
- `nutzungsbedingungen.md` -> `terms-of-use.md`
- **BREAKING** Deleted _banner_ and _quickstart_ features.
- **BREAKING** Merged `application` and `vendor` properties in Client Settings:
- The application name is always _geopilot_. With `name` the application name can be extended, e.g. to _geopilot Test_.
- There is only one `logo` which is used for the header.
- Optionally a separate `faviconDark` can be defined for dark mode of the browser.

## v1.0.93 - 2024-05-14

Expand Down
14 changes: 7 additions & 7 deletions config/realms/keycloak-geopilot.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
},
{
"id": "1ed45832-2880-4fd4-a274-bbcc101c3307",
"username": "user",
"username": "uploader",
"enabled": true,
"emailVerified": true,
"email": "user@geopilot.ch",
"email": "uploader@geopilot.ch",
"firstName": "Ursula",
"lastName": "User",
"lastName": "Uploader",
"credentials": [
{
"type": "password",
Expand All @@ -75,12 +75,12 @@
},
{
"id": "ceab20b3-2e6a-41e7-bd77-3d96e04098ab",
"username": "unregistered",
"username": "newuser",
"enabled": true,
"emailVerified": true,
"email": "unregistered@geopilot.ch",
"firstName": "Unknown",
"lastName": "Unregistered",
"email": "newuser@geopilot.ch",
"firstName": "Norbert",
"lastName": "Newuser",
"credentials": [
{
"type": "password",
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ services:
volumes:
- ./src/Geopilot.Api/Uploads:/uploads
- ./src/Geopilot.Api/Persistent:/assets
- ./README.md:/public/info-hilfe.md
- ./LICENSE:/public/nutzungsbestimmungen.md
- ./README.md:/public/info.md
- ./LICENSE:/public/terms-of-use.md
extra_hosts:
- "localhost:host-gateway"
depends_on:
Expand All @@ -90,4 +90,3 @@ services:
ports:
- "4011:8080"
command: start-dev --import-realm

16 changes: 8 additions & 8 deletions src/Geopilot.Api/ContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void SeedTestData(this Context context)
context.SeedMandates();
context.SeedDeliveries();
context.SeedAssets();
context.AuthorizeFirstUser();
context.AddOrganisationsToDefaultUsers();

transaction.Commit();
}
Expand Down Expand Up @@ -187,15 +187,15 @@ public static void SeedAssets(this Context context)
context.SaveChanges();
}

public static void AuthorizeFirstUser(this Context context)
public static void AddOrganisationsToDefaultUsers(this Context context)
{
var user = context.Users.OrderBy(u => u.Id).First();
var organisation = context.Organisations.OrderBy(o => o.Id).First();
var mandates = context.Mandates.OrderBy(m => m.Id).Skip(1);
var admin = context.Users.Single(user => user.Email == "[email protected]");
var adminOrganisations = context.Organisations.OrderBy(o => o.Id).Skip(1);
admin.Organisations.AddRange(adminOrganisations);

user.IsAdmin = true;
user.Organisations.Add(organisation);
organisation.Mandates.AddRange(mandates);
var user = context.Users.Single(user => user.Email == "[email protected]");
var userOrganistions = context.Organisations.OrderBy(o => o.Id).Take(2);
user.Organisations.AddRange(userOrganistions);

context.SaveChanges();
}
Expand Down
11 changes: 9 additions & 2 deletions src/Geopilot.Api/Controllers/DeliveryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public DeliveryController(ILogger<DeliveryController> logger, Context context, I
[Authorize(Policy = GeopilotPolicies.User)]
[SwaggerResponse(StatusCodes.Status201Created, "The delivery was created successfully.")]
[SwaggerResponse(StatusCodes.Status400BadRequest, "The server cannot process the request due to invalid or malformed request.", typeof(ValidationProblemDetails), "application/json")]
[SwaggerResponse(StatusCodes.Status401Unauthorized, "The user is not authorized.")]
[SwaggerResponse(StatusCodes.Status404NotFound, "The validation job or mandate could not be found.")]
[SwaggerResponse(StatusCodes.Status500InternalServerError, "The server encountered an unexpected condition that prevented it from fulfilling the request. Likely there was an error persisting the assets.", typeof(ProblemDetails), "application/json")]
public async Task<IActionResult> Create(DeliveryRequest declaration)
Expand All @@ -69,8 +70,14 @@ public async Task<IActionResult> Create(DeliveryRequest declaration)

if (mandate is null || !mandate.Organisations.SelectMany(u => u.Users).Any(u => u.Id == user.Id))
{
logger.LogTrace("User <{AuthIdentifier}> is not authorized to create a delivery for mandate with id <{MandateId}>.", user.AuthIdentifier, declaration.MandateId);
return NotFound($"Mandate with id <{declaration.MandateId}> not found or user is not authorized.");
logger.LogTrace($"Mandate with id <{declaration.MandateId}> not found.");
return NotFound($"Mandate with id <{declaration.MandateId}> not found.");
}

if (!mandate.Organisations.SelectMany(u => u.Users).Any(u => u.Id == user.Id))
{
logger.LogTrace($"User <{user.AuthIdentifier}> is not authorized to create a delivery for mandate with id <{declaration.MandateId}>.");
return Unauthorized($"User is not authorized for mandate with id <{declaration.MandateId}>");
}

var precursorDelivery = declaration.PrecursorDeliveryId.HasValue ?
Expand Down
2 changes: 1 addition & 1 deletion src/Geopilot.Api/Controllers/MandateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task<IActionResult> Get(
var user = await context.GetUserByPrincipalAsync(User);
var mandates = context.MandatesWithIncludes.AsNoTracking();

if (!user.IsAdmin)
if (!user.IsAdmin || jobId != default)
{
mandates = mandates.Where(m => m.Organisations.SelectMany(o => o.Users).Any(u => u.Id == user.Id));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Geopilot.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7188;http://localhost:5075",
"applicationUrl": "http://localhost:7188",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
19 changes: 5 additions & 14 deletions src/Geopilot.Frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
env: {browser: true, es2020: true},
extends: [
"eslint:recommended",
"plugin:react/recommended",
Expand All @@ -13,20 +13,11 @@ module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "react-refresh", "prettier"],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: "detect" } },
parserOptions: {ecmaVersion: "latest", sourceType: "module"},
settings: {react: {version: "detect"}},
rules: {
"prettier/prettier": [
"error",
{
bracketSameLine: true,
trailingComma: "all",
arrowParens: "avoid",
printWidth: 120,
endOfLine: "auto",
},
],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"prettier/prettier": "error",
"react-refresh/only-export-components": ["warn", {allowConstantExport: true}],
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"react/display-name": "off",
Expand Down
3 changes: 2 additions & 1 deletion src/Geopilot.Frontend/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"trailingComma": "all",
"arrowParens": "avoid",
"printWidth": 120,
"endOfLine": "auto"
"endOfLine": "auto",
"plugins": ["prettier-plugin-sort-json"]
}
74 changes: 74 additions & 0 deletions src/Geopilot.Frontend/cypress/e2e/app.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {
isSelectedNavItem,
loadWithoutAuth,
loginAsAdmin,
loginAsNewUser,
loginAsUploader,
logout,
openTool,
selectLanguage,
} from "./helpers/appHelpers.js";
import { selectAdminNavItem } from "./helpers/adminHelpers.js";

describe("General app tests", () => {
it("shows no login button if auth settings could not be loaded", () => {
loadWithoutAuth();
cy.get('[data-cy="login-button"]').should("not.exist");
});

it.skip("registers new users and logs them in", () => {
loginAsNewUser();
cy.get('[data-cy="loggedInUser-button"]').should("exist");
cy.get('[data-cy="loggedInUser-button"]').click();
cy.contains("Norbert Newuser");
});

it("shows admin tools only for admin users", () => {
loginAsUploader();
cy.get('[data-cy="loggedInUser-button"]').click();
cy.get('[data-cy="delivery-nav"]').should("exist");
cy.get('[data-cy="admin-nav"]').should("not.exist");
cy.get('[data-cy="stacBrowser-nav"]').should("not.exist");
logout();

loginAsAdmin();
cy.get('[data-cy="loggedInUser-button"]').click();
cy.get('[data-cy="delivery-nav"]').should("exist");
isSelectedNavItem("delivery-nav", "tool-navigation");
cy.get('[data-cy="admin-nav"]').should("exist");
cy.get('[data-cy="stacBrowser-nav"]').should("exist");

openTool("admin");
cy.location().should(location => {
expect(location.pathname).to.eq(`/admin/delivery-overview`);
});
isSelectedNavItem("admin-delivery-overview-nav", "admin-navigation");

cy.get('[data-cy="loggedInUser-button"]').click();
isSelectedNavItem("admin-nav", "tool-navigation");
cy.get('[data-cy="admin-nav"]').click();

selectAdminNavItem("users");
selectAdminNavItem("mandates");
selectAdminNavItem("organisations");
selectAdminNavItem("delivery-overview");
});

it("updates the language when the user selects a different language", () => {
cy.visit("/");
cy.contains("EN");
cy.contains("Log In");

selectLanguage("de");
cy.contains("DE");
cy.contains("Anmelden");

selectLanguage("fr");
cy.contains("FR");
cy.contains("Se connecter");

selectLanguage("it");
cy.contains("IT");
cy.contains("Accedi");
});
});
Loading

0 comments on commit 4595dde

Please sign in to comment.