Skip to content

Commit 3d6ad17

Browse files
fix: remove dead ternary in dataSource memo of ScopeConfigSelect
1 parent 8491aca commit 3d6ad17

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

  • config-ui/src/plugins/components/scope-config-select

config-ui/src/plugins/components/scope-config-select/index.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ export const ScopeConfigSelect = ({ plugin, connectionId, scopeConfigId, onCance
3939
const [open, setOpen] = useState(false);
4040
const [showAll, setShowAll] = useState(false);
4141

42-
const { ready, data } = useRefreshData(() => showAll ? API.scopeConfig.listAll(plugin) : API.scopeConfig.list(plugin, connectionId),[version, showAll],);
43-
44-
const dataSource = useMemo(() => {
45-
const filtered = showAll ? data : data;
46-
return filtered ? (scopeConfigId ? [{ id: 'None', name: 'No Scope Config' }].concat(filtered) : filtered) : [];
47-
}, [data, scopeConfigId, showAll]);
42+
const { ready, data } = useRefreshData(
43+
() => showAll ? API.scopeConfig.listAll(plugin) : API.scopeConfig.list(plugin, connectionId),
44+
[version, showAll],
45+
);
4846

47+
const dataSource = useMemo(
48+
() => (data ? (scopeConfigId ? [{ id: 'None', name: 'No Scope Config' }].concat(data) : data) : []),
49+
[data, scopeConfigId, showAll],
50+
);
51+
4952
const defaultName = useMemo(() => `shared-config-<${(data ?? []).length}>`, [data]);
5053

5154
useEffect(() => {
@@ -70,15 +73,15 @@ export const ScopeConfigSelect = ({ plugin, connectionId, scopeConfigId, onCance
7073
<Flex vertical gap="middle">
7174
<Flex style={{ marginTop: 20 }} gap="small" align="center">
7275
<Button type="primary" icon={<PlusOutlined />} onClick={handleShowDialog}>
73-
Add New Scope Config
76+
Add New Scope Config
7477
</Button>
7578
<Button
76-
type={showAll ? 'primary' : 'default'}
77-
onClick={() => setShowAll((v) => !v)}
78-
>
79-
{showAll ? 'Showing: All Connections' : 'This Connection Only'}
80-
</Button>
81-
</Flex>
79+
type={showAll ? 'primary' : 'default'}
80+
onClick={() => setShowAll((v) => !v)}
81+
>
82+
{showAll ? 'Showing: All Connections' : 'This Connection Only'}
83+
</Button>
84+
</Flex>
8285
<Table
8386
rowKey="id"
8487
size="small"

0 commit comments

Comments
 (0)