Skip to content

Commit

Permalink
fix(misc): remove broken console features
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 13, 2024
1 parent 4a91103 commit 44a64f4
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 123 deletions.
1 change: 0 additions & 1 deletion idp/src/user/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ class UserRepoImpl {
async enoughActiveAdmins() {
const { rows } = await client.query(
'SELECT COUNT(*) as count FROM "user" WHERE is_admin IS TRUE AND is_active IS TRUE',
[],
)
return rows[0].count > 1
}
Expand Down
2 changes: 1 addition & 1 deletion idp/src/user/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export async function makeAdminUser(id: string, options: UserMakeAdminOptions) {
if (
user.isAdmin &&
!(await userRepo.enoughActiveAdmins()) &&
options.makeAdmin
!options.makeAdmin
) {
throw newCannotDemoteSoleAdminError()
}
Expand Down
2 changes: 1 addition & 1 deletion migrations/Cargo.lock

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

1 change: 1 addition & 0 deletions migrations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[package]
name = "voltaserve-migrations"
edition = "2021"
version = "3.0.0"
publish = false

[lib]
Expand Down
2 changes: 2 additions & 0 deletions migrations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod m20240807_000001_add_segmentation_column;
mod m20240905_000001_add_user_active_admin_fields;
mod m20240907_000001_add_user_force_change_password_field;
mod m20240913_000001_drop_segmentation_column;
mod m20241114_000001_drop_user_force_change_password_column;

#[async_trait::async_trait]
impl MigratorTrait for Migrator {
Expand All @@ -48,6 +49,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240905_000001_add_user_active_admin_fields::Migration),
Box::new(m20240907_000001_add_user_force_change_password_field::Migration),
Box::new(m20240913_000001_drop_segmentation_column::Migration),
Box::new(m20241114_000001_drop_user_force_change_password_column::Migration),
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2023 Anass Bouassaba.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// licenses/AGPL.txt.
use sea_orm_migration::prelude::*;

use crate::models::v1::{User};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(
&self,
manager: &SchemaManager,
) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(User::Table)
.drop_column(User::ForceChangePassword)
.to_owned(),
)
.await?;

Ok(())
}

async fn down(
&self,
manager: &SchemaManager,
) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(User::Table)
.add_column(
ColumnDef::new(User::ForceChangePassword)
.boolean()
.not_null()
.default(false),
)
.to_owned(),
)
.await?;

Ok(())
}
}
121 changes: 1 addition & 120 deletions ui/src/pages/console/console-panel-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,14 @@ import {
Grid,
GridItem,
Heading,
IconButton,
IconButtonProps,
Spacer,
Table,
Text,
Th,
Thead,
Tooltip,
Tr,
} from '@chakra-ui/react'
import {
Form,
IconClose,
IconEdit,
IconSync,
IconWarning,
PagePagination,
RelativeDate,
SectionError,
Expand All @@ -44,16 +36,6 @@ import ConsoleAPI from '@/client/console/console'
import UserAPI from '@/client/idp/user'
import { swrConfig } from '@/client/options'
import { getPictureUrlById } from '@/lib/helpers/picture'
import { truncateEnd } from '@/lib/helpers/truncate-end'
import truncateMiddle from '@/lib/helpers/truncate-middle'

const EditButton = (props: IconButtonProps) => (
<IconButton
icon={props.icon ? props.icon : <IconEdit />}
className={cx('h-[40px]', 'w-[40px]')}
{...props}
/>
)

const ConsolePanelUser = () => {
const { id } = useParams()
Expand Down Expand Up @@ -150,110 +132,9 @@ const ConsolePanelUser = () => {
'dark:border-gray-700',
)}
/>
{user.picture ? (
<IconButton
icon={<IconClose />}
variant="solid"
colorScheme="red"
right="5px"
bottom="10px"
position="absolute"
zIndex={1000}
title="Delete picture"
aria-label="Delete picture"
isDisabled={true}
/>
) : null}
</div>
</GridItem>
<GridItem colSpan={8}>
<Form
sections={[
{
title: 'Basics',
rows: [
{
label: 'Full name',
content: (
<>
<span>{truncateEnd(user.fullName, 50)}</span>
<EditButton
title="Edit full name"
aria-label="Edit full name"
isDisabled={true}
/>
</>
),
},
],
},
{
title: 'Credentials',
rows: [
{
label: 'Email',
content: (
<>
{user.pendingEmail ? (
<div
className={cx(
'flex',
'flex-row',
'gap-0.5',
'items-center',
)}
>
<Tooltip label="Please check your inbox to confirm your email.">
<div
className={cx(
'flex',
'items-center',
'justify-center',
'cursor-default',
)}
>
<IconWarning
className={cx('text-yellow-400')}
/>
</div>
</Tooltip>
<span>
{truncateMiddle(user.pendingEmail, 50)}
</span>
</div>
) : null}
{!user.pendingEmail ? (
<span>
{truncateMiddle(
user.pendingEmail || user.email,
50,
)}
</span>
) : null}
<EditButton
title="Edit email"
aria-label="Edit email"
isDisabled={true}
/>
</>
),
},
{
label: 'Force change password',
content: (
<EditButton
title="Force change password"
aria-label="Force change password"
icon={<IconSync />}
isDisabled={true}
/>
),
},
],
},
]}
/>
</GridItem>
<GridItem colSpan={8}></GridItem>
<GridItem colSpan={3}>
{isOrgListLoading ? (
<ListSekeleton header="Organizations">
Expand Down

0 comments on commit 44a64f4

Please sign in to comment.