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

Production Release - Keycloak Update to 22.0 #770

Merged
merged 11 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ select_permissions:
- role: anonymous
permission:
columns:
- id
- created_at
- updated_at
- appName
- backgroundImageURL
- bannerBackgroundColor
- bannerTextEn
- bannerFontColor
- bannerTextDe
- backgroundImageURL
- bannerTextEn
- created_at
- previewImageURL
- updated_at
filter: {}
3 changes: 3 additions & 0 deletions backend/metadata/databases/default/tables/public_User.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ table:
name: User
schema: public
object_relationships:
- name: UserStatus
using:
foreign_key_constraint_on: status
- name: employmentByEmployment
using:
foreign_key_constraint_on: employment
Expand Down
12 changes: 12 additions & 0 deletions backend/metadata/databases/default/tables/public_UserStatus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
table:
name: UserStatus
schema: public
is_enum: true
array_relationships:
- name: Users
using:
foreign_key_constraint_on:
column: status
table:
name: User
schema: public
1 change: 1 addition & 0 deletions backend/metadata/databases/default/tables/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- "!include public_SessionSpeaker.yaml"
- "!include public_University.yaml"
- "!include public_User.yaml"
- "!include public_UserStatus.yaml"
- "!include public_Weekday.yaml"
- "!include rentAScientist_RentAScientistConfig.yaml"
- "!include rentAScientist_School.yaml"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."AppSettings" add column "app" text
-- not null unique;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."AppSettings" add column "app" text
not null unique;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."AppSettings" rename column "appName" to "app";
comment on column "public"."AppSettings"."app" is NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
comment on column "public"."AppSettings"."app" is E'Name of the app to which the given settings are applied';
alter table "public"."AppSettings" rename column "app" to "appName";
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- INSERT INTO "public"."AppSettings" ("appName", "bannerBackgroundColor", "bannerFontColor", "bannerTextDe", "bannerTextEn")
-- VALUES (E'edu', DEFAULT, DEFAULT, DEFAULT, DEFAULT);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO "public"."AppSettings" ("appName", "bannerBackgroundColor", "bannerFontColor", "bannerTextDe", "bannerTextEn")
VALUES (E'edu', DEFAULT, DEFAULT, DEFAULT, DEFAULT);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."User" add column "status" text
-- not null default 'ACTIVE';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."User" add column "status" text
not null default 'ACTIVE';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment on column "public"."User"."status" is NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment on column "public"."User"."status" is E'Current user status';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."UserStatus";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE "public"."UserStatus" ("value" text NOT NULL, "comment" text NOT NULL, PRIMARY KEY ("value") , UNIQUE ("value"));COMMENT ON TABLE "public"."UserStatus" IS E'Possible activity status of a user';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM "public"."UserStatus" WHERE "value" = 'ACTIVE';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'ACTIVE', E'User is active');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM "public"."UserStatus" WHERE "value" = 'INACTIVE';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'INACTIVE', E'User did not show any activity on the platform for more than 12 month (currently not implemented)');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM "public"."UserStatus" WHERE "value" = 'DELETED';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'DELETED', E'All private information considering these user is deleted).');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM "public"."UserStatus" WHERE "value" = 'SPAM';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'SPAM', E'The user is classified as SPAM.');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."User" drop constraint "User_status_fkey";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."User"
add constraint "User_status_fkey"
foreign key ("status")
references "public"."UserStatus"
("value") on update restrict on delete restrict;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alter table "public"."AppSettings" drop constraint "AppSettings_pkey";
alter table "public"."AppSettings"
add constraint "AppSettings_pkey"
primary key ("id");
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN TRANSACTION;
ALTER TABLE "public"."AppSettings" DROP CONSTRAINT "AppSettings_pkey";

ALTER TABLE "public"."AppSettings"
ADD CONSTRAINT "AppSettings_pkey" PRIMARY KEY ("id", "appName");
COMMIT TRANSACTION;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alter table "public"."AppSettings" drop constraint "AppSettings_pkey";
alter table "public"."AppSettings"
add constraint "AppSettings_pkey"
primary key ("id", "appName");
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN TRANSACTION;
ALTER TABLE "public"."AppSettings" DROP CONSTRAINT "AppSettings_pkey";

ALTER TABLE "public"."AppSettings"
ADD CONSTRAINT "AppSettings_pkey" PRIMARY KEY ("appName");
COMMIT TRANSACTION;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
comment on column "public"."AppSettings"."id" is E'To store characteristics on the app level.';
alter table "public"."AppSettings" alter column "id" set default nextval('"AppSettings_id_seq"'::regclass);
alter table "public"."AppSettings" alter column "id" drop not null;
alter table "public"."AppSettings" add column "id" int4;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."AppSettings" drop column "id" cascade;
89 changes: 89 additions & 0 deletions frontend-nx/apps/edu-hub/__generated__/globalTypes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import { useAdminMutation } from '../../hooks/authedMutation';
import { useAdminQuery } from '../../hooks/authedQuery';

import { UpdateAppSettingsVariables, UpdateAppSettings } from '../../queries/__generated__/UpdateAppSettings';
import { APP_SETTINGS, INSERT_APP_SETTINGS, UPDATE_APP_SETTINGS } from '../../queries/appSettings';
import { APP_SETTINGS, UPDATE_APP_SETTINGS } from '../../queries/appSettings';
import { AppSettings } from '../../queries/__generated__/AppSettings';
import { InsertAppSettings, InsertAppSettingsVariables } from '../../queries/__generated__/InsertAppSettings';

type Inputs = {
// backgroundImageURL: string;
Expand Down Expand Up @@ -49,8 +48,9 @@ const ManageAppSettingsOverview: FC = () => {
error: appSettingsError,
refetch: refetchAppSettings,
} = useAdminQuery<AppSettings>(APP_SETTINGS, {
variables: { appName: 'edu' },
onCompleted: (data) => {
const appSettings = data.AppSettings[0];
const [appSettings] = data.AppSettings; // Using array destructuring to get the first item

if (appSettings) {
reset({
Expand All @@ -66,32 +66,19 @@ const ManageAppSettingsOverview: FC = () => {
});

const [updateAppSettings] = useAdminMutation<UpdateAppSettings, UpdateAppSettingsVariables>(UPDATE_APP_SETTINGS);
const [insertAppSettings] = useAdminMutation<InsertAppSettings, InsertAppSettingsVariables>(INSERT_APP_SETTINGS);

const onSubmit: SubmitHandler<Inputs> = async (data) => {
try {
const variables = {
// backgroundImageURL: data.backgroundImageURL,
bannerBackgroundColor: data.bannerBackgroundColor,
bannerFontColor: data.bannerFontColor,
bannerTextDe: data.bannerTextDe,
bannerTextEn: data.bannerTextEn,
};

if (appSettingsData.AppSettings && appSettingsData.AppSettings[0]) {
await updateAppSettings({
variables: {
...variables,
id: appSettingsData.AppSettings[0].id,
},
});
} else {
await insertAppSettings({
variables: {
...variables,
},
});
}
await updateAppSettings({
variables: {
appName: 'edu',
// backgroundImageURL: data.backgroundImageURL,
bannerBackgroundColor: data.bannerBackgroundColor,
bannerFontColor: data.bannerFontColor,
bannerTextDe: data.bannerTextDe,
bannerTextEn: data.bannerTextEn,
},
});

refetchAppSettings();
await new Promise((resolve) => setTimeout(resolve, 1000));
Expand Down Expand Up @@ -139,10 +126,10 @@ const ManageAppSettingsOverview: FC = () => {
</div>
<div className="flex flex-wrap">
<div className="w-1/2 pr-3">
<FormFieldRow<Inputs> label={t('manageAppSettings:bannerTextDe')} name="bannerTextDe" required />
<FormFieldRow<Inputs> label={t('manageAppSettings:bannerTextDe')} name="bannerTextDe" />
</div>
<div className="w-1/2 pl-3">
<FormFieldRow<Inputs> label={t('manageAppSettings:bannerTextEn')} name="bannerTextEn" required />
<FormFieldRow<Inputs> label={t('manageAppSettings:bannerTextEn')} name="bannerTextEn" />
</div>
</div>
{/* <div className="flex flex-wrap">
Expand Down
6 changes: 4 additions & 2 deletions frontend-nx/apps/edu-hub/components/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export const Page: FC<PageProps> = ({ children, className }) => {
loading: appSettingsLoading,
error: appSettingsError,
} = useRoleQuery<AppSettings>(APP_SETTINGS, {
variables: { appName: 'edu' },
onCompleted: (data) => {
const appSettings = data.AppSettings[0];
if (appSettings) {
const [appSettings] = data.AppSettings; // Using array destructuring to get the first item

if (appSettings.bannerTextDe && appSettings.bannerTextEn) {
if (lang === 'de') handleBanner('bannerContentDe', appSettings.bannerTextDe);
else if (lang === 'en') handleBanner('bannerContentEn', appSettings.bannerTextEn);
}
Expand Down
Loading