Skip to content

Commit

Permalink
feat: subscriptions table body
Browse files Browse the repository at this point in the history
feat: edit store label block and modal
feat: edit store label modal
  • Loading branch information
wwills2 committed Feb 21, 2024
1 parent 060c7e3 commit 6859a81
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 80 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@
"electron:package:linux": "npm run clean && npm run build && electron-builder -l -c.extraMetadata.main=build/main.js"
},
"dependencies": {
"@reduxjs/toolkit": "^2.1.0",
"@reduxjs/toolkit": "^2.2.1",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@types/styled-components": "^5.1.34",
"chia-dat-seeder": "^1.0.1",
"chia-datalayer": "^2.0.13",
"chia-datalayer": "^2.0.14",
"chia-datalayer-fs-deploy": "^1.0.15",
"chia-root-resolver": "^1.0.0",
"chia-wallet": "^1.0.18",
"chia-web2-gateway": "^1.0.10",
"components": "^0.1.0",
"express": "^4.18.2",
"fast-folder-size": "^2.2.0",
"flowbite": "^2.2.1",
"flowbite": "^2.3.0",
"flowbite-react": "^0.7.2",
"flowbite-typography": "^1.0.3",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "^6.6.2",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.0",
"react-router-dom": "^6.22.1",
"react-webview": "^0.1.0",
"redux-persist": "^6.0.0",
"styled-components": "^6.1.8",
"uuid": "^9.0.1",
"xterm": "^5.3.0"
},
"devDependencies": {
"@types/react": "^18.2.55",
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^6.21.0",
Expand All @@ -61,15 +61,15 @@
"autoprefixer": "^10.4.17",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"electron": "^28.2.2",
"electron-builder": "^24.9.1",
"electron": "^28.2.3",
"electron-builder": "^24.12.0",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3",
"vite": "^5.1.0",
"vite": "^5.1.3",
"wait-on": "^7.2.0"
},
"build": {
Expand Down
40 changes: 0 additions & 40 deletions src/renderer/components/blocks/layout/SelectedStoreIdCard.tsx

This file was deleted.

53 changes: 53 additions & 0 deletions src/renderer/components/blocks/layout/SetStoreLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { useMemo } from 'react';
import { Label, TextInput } from 'flowbite-react';
import { FormattedMessage } from 'react-intl';
import { useSelector, useDispatch } from 'react-redux';
import { setStoreLabel } from '@/store/slices/userOptions';

interface SelectedStoreIdCardProps {
storeId: string;
}

const SetStoreLabel: React.FC<SelectedStoreIdCardProps> = ({
storeId,
}: SelectedStoreIdCardProps) => {
const dispatch = useDispatch();
const userOptionsStore = useSelector((state: any) => state.userOptions);

const label = useMemo(() => {
return userOptionsStore.storeLabels?.[storeId];
}, [storeId, userOptionsStore.storeLabels]);

const handleStoreLabelChange = (event) => {
dispatch(setStoreLabel({ storeId, label: event.target.value }));
};

return (
<div className={'space-y-6 flex-col'}>
<div className={'flex'}>
<p className="text-base leading-relaxed text-gray-500 dark:text-gray-400">
<FormattedMessage id="store-id"/>: {storeId}
</p>
</div>
<div className={"flex"}>
<div style={{
display: "flex",
flexDirection: 'column',
justifyContent: 'center',
inlineSize: 'min-content',
whiteSpace: 'nowrap'
}}>
<Label htmlFor="store-id">
<FormattedMessage id={"store-label"}/>
</Label>
</div>
<div style={{width: "100%", marginLeft: '10px', marginRight: '10px'}}>
<TextInput onChange={handleStoreLabelChange} value={label || ''}/>
</div>
</div>
</div>
);
};

export {SetStoreLabel};
65 changes: 65 additions & 0 deletions src/renderer/components/blocks/layout/StoreId.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, {useMemo} from "react";
import {Button, Tooltip} from "flowbite-react";
import {FormattedMessage} from "react-intl";
import {useSelector} from "react-redux";

interface StoreIdProps {
storeId: string;
setStoreIdToEdit?: (storeId: string) => void;
}

const StoreId: React.FC<StoreIdProps> = ({storeId, setStoreIdToEdit}) => {

const userOptions = useSelector((state: any) => state.userOptions);

const storeLabel = useMemo(() => {
return userOptions.storeLabels?.[storeId];
}, [storeId, userOptions.storeLabels]);

const IDWithEditTooltip: React.FC = () => {
return (
<Tooltip
arrow={false}
style={'light'}
animation="duration-500"
content={
<div className={'flex'}>
{
setStoreIdToEdit &&
<>
<Button onClick={() => setStoreIdToEdit(storeId)}>
<FormattedMessage id={"set-store-label"}/>
</Button>
</>
}
<div style={{
marginLeft: '10px',
display: "flex",
flexDirection: 'column',
justifyContent: 'center',
}}
>
<p>
{storeLabel && <div>{storeId}</div>}
</p>
</div>
</div>
}
>
{storeLabel || storeId}
</Tooltip>
);
}

return (
<>
{
(setStoreIdToEdit || storeLabel)
? <IDWithEditTooltip/>
: <div style={{width: '100%', display: 'flex'}}>{storeId}</div>
}
</>
);
}

export {StoreId}
5 changes: 3 additions & 2 deletions src/renderer/components/blocks/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './LeftNav';
export * from './Template';
export * from './WebView';
export * from './SelectedStoreIdCard';
export * from './XTerm';
export * from './SetStoreLabel';
export * from './XTerm';
export * from './StoreId'
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {Modal} from "flowbite-react";
import React, {useEffect, useState} from "react";
import {FormattedMessage} from "react-intl";
import {SetStoreLabel} from "@/components";

interface SetStoreLabelModalProps {
storeId: string;
setStoreId: (storeId: string) => void;
}

const SetStoreLabelModal: React.FC<SetStoreLabelModalProps> = ({storeId, setStoreId }) => {

const [showModal, setOpenModal] = useState(false);

useEffect(() => {
if (storeId) {
setOpenModal(true);
}else{
setOpenModal(false);
}
}, [storeId]);

return (
<Modal show={showModal} onClose={() => setStoreId('')} size="3xl">
<Modal.Header>
<FormattedMessage id="set-store-label"/>
</Modal.Header>
<Modal.Body>
<SetStoreLabel storeId={storeId}/>
</Modal.Body>
</Modal>
);
}

export {SetStoreLabelModal}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './SetStoreLabelModal';
11 changes: 8 additions & 3 deletions src/renderer/components/blocks/tables/OwnedStoresTable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import React, {useEffect, useState} from 'react';
import { Button, Card, Table, TableBody } from 'flowbite-react';
import { FormattedMessage } from 'react-intl';
import { useGetOwnedStoresQuery } from '@/api/ipc/datalayer';
import {useGetOwnedStoresQuery} from '@/api/ipc/datalayer';
import { LoadingSpinnerCard, Spacer } from '@/components';
import { useSelector } from 'react-redux';
import {Link} from "react-router-dom";
Expand All @@ -15,7 +15,12 @@ const OwnedStoresTable: React.FC<OwnedStoreSelectionTableProps> = (
{setTableContentsLoaded}: OwnedStoreSelectionTableProps
) => {
const userOptions = useSelector((state: any) => state.userOptions);
const { data, isLoading, error, refetch } = useGetOwnedStoresQuery({});
const {
data,
isLoading,
error,
refetch,
} = useGetOwnedStoresQuery({});

const [numStores, setNumStores] = useState<number>(0);

Expand Down
Loading

0 comments on commit 6859a81

Please sign in to comment.