Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failed to initialize the preset plugins #3894

Merged
merged 1 commit into from May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 24 additions & 12 deletions console/src/views/system/Setup.vue
Expand Up @@ -36,6 +36,27 @@ const {
const siteTitle = ref("");
const loading = ref(false);

const { mutate: pluginInstallMutate } = useMutation({
mutationKey: ["plugin-install"],
mutationFn: async (plugin: Plugin) => {
const { data } = await apiClient.plugin.installPlugin(
{
source: "PRESET",
presetName: plugin.metadata.name as string,
},
{
mute: true,
}
);
return data;
},
retry: 3,
retryDelay: 1000,
onSuccess(data) {
pluginStartMutate(data);
},
});

const { mutate: pluginStartMutate } = useMutation({
mutationKey: ["plugin-start"],
mutationFn: async (plugin: Plugin) => {
Expand All @@ -57,6 +78,7 @@ const { mutate: pluginStartMutate } = useMutation({
);
},
retry: 3,
retryDelay: 1000,
});

const handleSubmit = async () => {
Expand Down Expand Up @@ -104,18 +126,8 @@ const handleSubmit = async () => {
// Install preset plugins
const { data: presetPlugins } = await apiClient.plugin.listPluginPresets();

const installPluginResponses = await Promise.all(
presetPlugins.map((plugin) => {
return apiClient.plugin.installPlugin({
source: "PRESET",
presetName: plugin.metadata.name as string,
});
})
);

for (let i = 0; i < installPluginResponses.length; i++) {
const response = installPluginResponses[i];
pluginStartMutate(response.data);
for (let i = 0; i < presetPlugins.length; i++) {
pluginInstallMutate(presetPlugins[i]);
}
} catch (error) {
console.error("Failed to initialize preset data", error);
Expand Down