Skip to content

Commit

Permalink
revert: available check
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Jun 23, 2024
1 parent 5627d69 commit 04baafc
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 234 deletions.
67 changes: 29 additions & 38 deletions src/window/Config/pages/Service/Collection/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { useConfig, deleteKey } from '../../../../../hooks';
import ServiceItem from './ServiceItem';
import SelectModal from './SelectModal';
import ConfigModal from './ConfigModal';
import * as builtinCollectionServices from '../../../../../services/collection';
import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance';

export default function Collection(props) {
const { pluginList } = props;
Expand Down Expand Up @@ -71,42 +69,35 @@ export default function Collection(props) {
{...provided.droppableProps}
>
{collectionServiceInstanceList !== null &&
collectionServiceInstanceList
.filter((instanceKey) => {
return whetherAvailableService(instanceKey, {
[ServiceSourceType.BUILDIN]: builtinCollectionServices,
[ServiceSourceType.PLUGIN]: pluginList,
});
})
.map((x, i) => {
return (
<Draggable
key={x}
draggableId={x}
index={i}
>
{(provided) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<ServiceItem
{...provided.dragHandleProps}
serviceInstanceKey={x}
key={x}
pluginList={pluginList}
deleteServiceInstance={deleteServiceInstance}
setCurrentConfigKey={setCurrentConfigKey}
onConfigOpen={onConfigOpen}
/>
<Spacer y={2} />
</div>
);
}}
</Draggable>
);
})}
collectionServiceInstanceList.map((x, i) => {
return (
<Draggable
key={x}
draggableId={x}
index={i}
>
{(provided) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<ServiceItem
{...provided.dragHandleProps}
serviceInstanceKey={x}
key={x}
pluginList={pluginList}
deleteServiceInstance={deleteServiceInstance}
setCurrentConfigKey={setCurrentConfigKey}
onConfigOpen={onConfigOpen}
/>
<Spacer y={2} />
</div>
);
}}
</Draggable>
);
})}
</div>
)}
</Droppable>
Expand Down
67 changes: 29 additions & 38 deletions src/window/Config/pages/Service/Recognize/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { useConfig, deleteKey } from '../../../../../hooks';
import ServiceItem from './ServiceItem';
import SelectModal from './SelectModal';
import ConfigModal from './ConfigModal';
import * as builtinRecognizeServices from '../../../../../services/recognize';
import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance';

export default function Recognize(props) {
const { pluginList } = props;
Expand Down Expand Up @@ -83,42 +81,35 @@ export default function Recognize(props) {
{...provided.droppableProps}
>
{recognizeServiceInstanceList !== null &&
recognizeServiceInstanceList
.filter((instanceKey) => {
return whetherAvailableService(instanceKey, {
[ServiceSourceType.BUILDIN]: builtinRecognizeServices,
[ServiceSourceType.PLUGIN]: pluginList,
});
})
.map((x, i) => {
return (
<Draggable
key={x}
draggableId={x}
index={i}
>
{(provided) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<ServiceItem
{...provided.dragHandleProps}
serviceInstanceKey={x}
key={x}
pluginList={pluginList}
deleteServiceInstance={deleteServiceInstance}
setCurrentConfigKey={setCurrentConfigKey}
onConfigOpen={onConfigOpen}
/>
<Spacer y={2} />
</div>
);
}}
</Draggable>
);
})}
recognizeServiceInstanceList.map((x, i) => {
return (
<Draggable
key={x}
draggableId={x}
index={i}
>
{(provided) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<ServiceItem
{...provided.dragHandleProps}
serviceInstanceKey={x}
key={x}
pluginList={pluginList}
deleteServiceInstance={deleteServiceInstance}
setCurrentConfigKey={setCurrentConfigKey}
onConfigOpen={onConfigOpen}
/>
<Spacer y={2} />
</div>
);
}}
</Draggable>
);
})}
</div>
)}
</Droppable>
Expand Down
68 changes: 29 additions & 39 deletions src/window/Config/pages/Service/Translate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import ServiceItem from './ServiceItem';
import SelectModal from './SelectModal';
import ConfigModal from './ConfigModal';

import * as builtinTranslateServices from '../../../../../services/translate';
import { ServiceSourceType, whetherAvailableService } from '../../../../../utils/service_instance';

export default function Translate(props) {
const { pluginList } = props;
const {
Expand Down Expand Up @@ -86,42 +83,35 @@ export default function Translate(props) {
{...provided.droppableProps}
>
{translateServiceInstanceList !== null &&
translateServiceInstanceList
.filter((instanceKey) => {
return whetherAvailableService(instanceKey, {
[ServiceSourceType.BUILDIN]: builtinTranslateServices,
[ServiceSourceType.PLUGIN]: pluginList,
});
})
.map((x, i) => {
return (
<Draggable
key={x}
draggableId={x}
index={i}
>
{(provided) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<ServiceItem
{...provided.dragHandleProps}
key={x}
serviceInstanceKey={x}
pluginList={pluginList}
deleteServiceInstance={deleteServiceInstance}
setCurrentConfigKey={setCurrentConfigKey}
onConfigOpen={onConfigOpen}
/>
<Spacer y={2} />
</div>
);
}}
</Draggable>
);
})}
translateServiceInstanceList.map((x, i) => {
return (
<Draggable
key={x}
draggableId={x}
index={i}
>
{(provided) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<ServiceItem
{...provided.dragHandleProps}
key={x}
serviceInstanceKey={x}
pluginList={pluginList}
deleteServiceInstance={deleteServiceInstance}
setCurrentConfigKey={setCurrentConfigKey}
onConfigOpen={onConfigOpen}
/>
<Spacer y={2} />
</div>
);
}}
</Draggable>
);
})}
</div>
)}
</Droppable>
Expand Down
Loading

0 comments on commit 04baafc

Please sign in to comment.