Skip to content
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
1 change: 1 addition & 0 deletions docs/app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets/index-CMOXPEBZ.js

Large diffs are not rendered by default.

395 changes: 395 additions & 0 deletions docs/assets/index-DvHpIefc.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
}(window.location))
</script>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/MonitoringTool/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/MonitoringTool/app.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Monitoring Tool</title>
<script type="module" crossorigin src="/MonitoringTool/assets/index-DEWhE3Ay.js"></script>
<script type="module" crossorigin src="/MonitoringTool/assets/index-DvHpIefc.js"></script>
<link rel="stylesheet" crossorigin href="/MonitoringTool/assets/index-B_hvZakY.css">
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/app.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Monitoring Tool</title>
</head>
Expand Down
6 changes: 3 additions & 3 deletions src/components/ApplicationsList/ApplicationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Link } from '@tanstack/react-router';
import { useRepositories } from '../../proxy-queries/useRepositories';
import { LanguageIcon } from '../LanguageIcon/LanguageIcon';
import { CardContainer } from '../CardContainer/CardContainer';
import { useOwner } from '../../domain/owner/owner.store';
import { useOwnersStore } from '../../stores/owners.store';

const IconText = ({ icon, text }: { icon: React.FC; text: string }) => (
<Space>
Expand All @@ -19,8 +19,8 @@ export interface ApplicationsListProps extends PropsWithChildren {
}

export const ApplicationsList: FC<ApplicationsListProps> = ({ children, filter }: ApplicationsListProps): ReactElement => {
const { owner } = useOwner();
const { data: applications, isPending } = useRepositories({ user: owner?.username ?? '', filter });
const { selectedOwner } = useOwnersStore();
const { data: applications, isPending } = useRepositories({ user: selectedOwner ?? '', filter });

if (isPending) {
return <div>Loading...</div>;
Expand Down
58 changes: 58 additions & 0 deletions src/components/OwnerManager/OwnerManager.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { type FC } from 'react';
import { Button, Form, Input, Modal } from 'antd';
import { useOwnersStore } from '../../stores/owners.store';

interface AddOwnerFormData {
username: string;
}

export interface OwnerManagerProps {
open: boolean;
onClose: () => void;
}

export const OwnerManager: FC<OwnerManagerProps> = ({ open, onClose }) => {
const { owners, setOwners } = useOwnersStore();
const [form] = Form.useForm<AddOwnerFormData>();

const handleSubmit = (values: AddOwnerFormData) => {
const newOwners = [...owners];
if (!newOwners.includes(values.username)) {
newOwners.push(values.username);
setOwners(newOwners);
}
form.resetFields();
onClose();
};

return (
<Modal
title="Manage Owners"
open={open}
onCancel={onClose}
footer={null}
>
<Form
form={form}
onFinish={handleSubmit}
layout="vertical"
>
<Form.Item
label="Username"
name="username"
rules={[
{ required: true, message: 'Please input the username!' },
{ pattern: /^[a-zA-Z0-9-]+$/, message: 'Username can only contain letters, numbers, and hyphens!' }
]}
>
<Input placeholder="Enter GitHub username" />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
Add Owner
</Button>
</Form.Item>
</Form>
</Modal>
);
};
62 changes: 38 additions & 24 deletions src/components/OwnerSelector/OwnerSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
import { Select } from 'antd';
import { useOwner } from '../../domain/owner/owner.store';
import type { FC, ReactElement } from 'react';
import { Select, Space, Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { useState, type FC, type ReactElement } from 'react';
import { useOwnersStore } from '../../stores/owners.store';
import { OwnerManager } from '../OwnerManager/OwnerManager';

export const OwnerSelector: FC = (): ReactElement => {
const { owner, setOwner } = useOwner();
const { owners, selectedOwner, setSelectedOwner } = useOwnersStore();
const [isManagerOpen, setIsManagerOpen] = useState(false);

const handleChange = (username: string) => {
setOwner({
username,
repositories: {
monitoringTool: 'MonitoringTool',
database: 'MonitoringTool-DB'
}
});
setSelectedOwner(username);
};

return (
<Select
style={{ width: 200 }}
value={owner?.username}
onChange={handleChange}
options={[
{ value: 'ElJijuna', label: 'ElJijuna' },
{ value: 'ismae147', label: 'ismae147' },
{ value: 'hashtagthis', label: 'hashtagthis' },
{ value: 'renatomendozac', label: 'renatomendozac' },
// Add more options here as needed
]}
/>
);
<Space.Compact style={{ width: '100%' }}>
<Select
style={{ width: 'calc(100% - 32px)' }}
value={selectedOwner}
onChange={handleChange}
optionLabelProp="label"
optionFilterProp="label"
showSearch
options={owners.map(owner => ({
value: owner,
label: owner,
}))}
listHeight={256}
maxTagCount={1}
placement="bottomLeft"
popupMatchSelectWidth={false}
dropdownStyle={{
minWidth: '200px',
maxWidth: '300px'
}}
/>
<Button
icon={<PlusOutlined />}
onClick={() => setIsManagerOpen(true)}
/>
<OwnerManager
open={isManagerOpen}
onClose={() => setIsManagerOpen(false)}
/>
</Space.Compact>);
};
13 changes: 9 additions & 4 deletions src/components/SideBarMenu/SideBarMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useCallback, type FC, type PropsWithChildren, type ReactElement } from 'react';
import { PieChartOutlined } from '@ant-design/icons';
import { HomeOutlined, PieChartOutlined } from '@ant-design/icons';
import { useNavigate, useRouter } from '@tanstack/react-router';
import Menu from 'antd/es/menu/menu';
import { useRepositories } from '../../proxy-queries/useRepositories';
import { Spin } from 'antd';
import { LanguageIcon } from '../LanguageIcon/LanguageIcon';
import { useOwner } from '../../domain/owner/owner.store';
import { useSelectedOwner } from '../../hooks/useSelectedOwner';

export interface SideBarMenuProps extends PropsWithChildren {
collapsed?: boolean;
Expand All @@ -15,8 +15,8 @@ export const SideBarMenu: FC<SideBarMenuProps> = (): ReactElement => {
const navigate = useNavigate();
const router = useRouter();
const currentPath = router.state.location.pathname;
const { owner } = useOwner();
const { data: applications, isPending } = useRepositories({ user: owner?.username ?? '' });
const { owner } = useSelectedOwner();
const { data: applications, isPending } = useRepositories({ user: owner?.login ?? '' });

const handleClick = useCallback(({ key }: { key: string }) => {
navigate({ to: key })
Expand All @@ -29,6 +29,11 @@ export const SideBarMenu: FC<SideBarMenuProps> = (): ReactElement => {
}

return <Menu onClick={handleClick} theme="dark" defaultSelectedKeys={[currentPath]} items={[
{
key: '/',
label: 'Home',
icon: <HomeOutlined />,
},
{
key: '/applications',
icon: <PieChartOutlined />,
Expand Down
Loading