Implement removing fetched plugins

This commit is contained in:
Tyler Hallada 2022-08-19 19:00:10 -04:00
parent 9f86fe1571
commit cd61c29a96
3 changed files with 35 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import {
disableAllFetchedPlugins, disableAllFetchedPlugins,
enableAllFetchedPlugins, enableAllFetchedPlugins,
toggleFetchedPlugin, toggleFetchedPlugin,
removeFetchedPlugin,
} from "../slices/plugins"; } from "../slices/plugins";
import styles from "../styles/FetchedPluginList.module.css"; import styles from "../styles/FetchedPluginList.module.css";
@ -45,7 +46,11 @@ const FetchedPluginsList: React.FC<Props> = ({ selectedCell }) => {
}`} }`}
> >
{plugins.map((plugin) => ( {plugins.map((plugin) => (
<li key={plugin.hash} title={plugin.plugins[0].file_name}> <li
key={plugin.hash}
title={plugin.plugins[0].file_name}
className={styles["plugin-row"]}
>
<input <input
id={plugin.hash} id={plugin.hash}
type="checkbox" type="checkbox"
@ -58,6 +63,12 @@ const FetchedPluginsList: React.FC<Props> = ({ selectedCell }) => {
<a>{plugin.plugins[0].file_name}</a> <a>{plugin.plugins[0].file_name}</a>
</Link> </Link>
</label> </label>
<button
onClick={() => dispatch(removeFetchedPlugin(plugin.hash))}
className={styles["plugin-remove"]}
>
&#10006;
</button>
</li> </li>
))} ))}
</ol> </ol>

View File

@ -122,6 +122,10 @@ export const pluginsSlice = createSlice({
...state, ...state,
fetchedPlugins: [...state.fetchedPlugins.filter(plugin => plugin.hash !== action.payload.hash), action.payload], fetchedPlugins: [...state.fetchedPlugins.filter(plugin => plugin.hash !== action.payload.hash), action.payload],
}), }),
removeFetchedPlugin: (state: PluginsState, action: PayloadAction<string>) => ({
...state,
fetchedPlugins: state.fetchedPlugins.filter(plugin => plugin.hash !== action.payload),
}),
setParsedPlugins: (state: PluginsState, action: PayloadAction<PluginFile[]>) => ({ setParsedPlugins: (state: PluginsState, action: PayloadAction<PluginFile[]>) => ({
...state, ...state,
parsedPlugins: action.payload, parsedPlugins: action.payload,
@ -179,6 +183,7 @@ export const {
addFetchedPlugin, addFetchedPlugin,
updateParsedPlugin, updateParsedPlugin,
updateFetchedPlugin, updateFetchedPlugin,
removeFetchedPlugin,
setParsedPlugins, setParsedPlugins,
setFetchedPlugins, setFetchedPlugins,
setPending, setPending,

View File

@ -14,12 +14,28 @@
margin-bottom: 12px; margin-bottom: 12px;
} }
.plugin-error { .plugin-row {
color: #ff0000; display: flex;
align-items: center;
} }
.plugin-label { .plugin-label {
margin-left: 8px; margin-left: 8px;
margin-right: 4px;
overflow: hidden;
text-overflow: ellipsis;
}
.plugin-remove {
margin-left: auto;
padding: 2px 8px;
background: none;
border: none;
font-size: 14px;
}
.plugin-remove:hover {
color: crimson;
} }
.loading { .loading {