Skip to content

Commit

Permalink
Correct Stop button
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Feb 17, 2025
1 parent 98f98b1 commit a07a752
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/Layout/TasksSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Wrapper = styled.div`

const onClearTasks = (tasks, remove) => {
tasks.forEach(task => {
if (task.current_stage == task.total_stages && task.progress === 100) {
if (task.current_stage == task.total_stages && task.progress === 100 || task.progress < 0) {
remove(task.id);
}
});
Expand Down Expand Up @@ -60,7 +60,7 @@ const TasksSidebar = ({ visible, tasks, toggle, remove, set, err }) => {
{(tasks && tasks.length && (
<Button
onClick={() => onClearTasks(tasks, remove)}
disabled={!tasks.some(task => task.current_stage == task.total_stages && task.progress === 100)}
disabled={!tasks.some(task => task.current_stage == task.total_stages && task.progress === 100 || task.progress < 0)}
className="lingvo-button-violet-dashed"
>
{getTranslation("Clear completed")}
Expand Down
2 changes: 2 additions & 0 deletions src/api/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,8 @@ export const stringsToTranslate = [
"Started dictionary update. Please check out tasks for details.",
"Statistics",
"Stop",
"Stopped manually",
"Stopping",
"Storage",
"Sub string",
"Subject",
Expand Down
9 changes: 0 additions & 9 deletions src/components/CognateAnalysisModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3273,15 +3273,6 @@ class CognateAnalysisModal extends React.Component {
{ lang_mode === "none" ? this.browse_files_render() : this.language_render(lang_mode === "multi") }

<Modal.Actions>
{ (mode === "neuro_suggestions" || mode === "multi_neuro_suggestions") && computing && (
<Button
content={this.context("Stop")}
onClick={() => {
this.setState({ computing: false });
}}
className="lingvo-button-red"
/>
)}
<Button
content={
computing ? (
Expand Down
37 changes: 33 additions & 4 deletions src/components/TaskList/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from "react";
import React, { useContext, useState } from "react";
import { connect } from "react-redux";
import { Button, List, Progress } from "semantic-ui-react";
import { Button, List, Progress, Icon } from "semantic-ui-react";
import PropTypes from "prop-types";
import { branch, compose, lifecycle, renderComponent } from "recompose";
import { bindActionCreators } from "redux";
Expand Down Expand Up @@ -54,6 +54,10 @@ function Task(props) {
stopNeuroCognateAnalysis
} = props;

const getTranslation = useContext(TranslationContext);

const [ stopping, setStopping ] = useState(false);

const links = result_link_list.map(link => (
<div key={link} className="lingvo-task__link">
<a href={link} key={link}>
Expand All @@ -70,7 +74,7 @@ function Task(props) {
className="lingvo-task__delete"
onClick={() => {
// For special tasks
if (/\bneuro\b/i.test(task_family) && progress < 100) {
if (/\bneuro\b/i.test(task_family) && progress >= 0 && progress < 100) {
stopNeuroCognateAnalysis({
variables: {
stamp: id
Expand All @@ -91,17 +95,42 @@ function Task(props) {
className={
progress && progress === 100
? "lingvo-task__progress lingvo-task__progress_success"
: progress < 0
? "lingvo-task__progress lingvo-task__progress_failed"
: "lingvo-task__progress"
}
/>
<div
className={
progress && progress === 100 ? "lingvo-task__label lingvo-task__label_success" : "lingvo-task__label"
progress && progress === 100
? "lingvo-task__label lingvo-task__label_success"
: progress < 0
? "lingvo-task__label lingvo-task__label_failed"
: "lingvo-task__label"
}
>
{`(${current_stage}/${total_stages}) ${status}`}
</div>
{links}
{ /\bneuro\b/i.test(task_family) && progress >= 0 && progress < 100 && (
<Button
content={stopping
? <span>{getTranslation("Stopping")}... <Icon name="spinner" loading /></span>
: getTranslation("Stop")
}
disabled={stopping}
onClick={() => {
setStopping(true);
stopNeuroCognateAnalysis({
variables: {
stamp: id
}
});
}}
className="lingvo-button-red"
style={{ margin: "0 auto", display: "block", marginTop: "1em" }}
/>
)}
</div>
</div>

Expand Down
16 changes: 16 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,18 @@ body {
color: #57b894 !important;
}
}

&_failed {
background: #ffe3dd !important;

& .bar {
background: #db4e4e !important;
}

& .label {
color: #db4e4e !important;
}
}
}

&__label {
Expand All @@ -1654,6 +1666,10 @@ body {
&_success {
color: #57b894 !important;
}

&_failed {
color: #db4e4e !important;
}
}

&__link {
Expand Down

0 comments on commit a07a752

Please sign in to comment.