Skip to content

Commit

Permalink
PR fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaskabc authored and ledsoft committed Aug 12, 2024
1 parent e8e378c commit f5624d1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/component/asset/RemoveAssetDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const RemoveAssetDialog: React.FC<RemoveAssetDialogProps> = (props) => {
label: props.asset.getLabel(),
})}
confirmKey="remove"
confirmColor="outline-danger"
>
<Label>
{formatMessage("asset.remove.dialog.text", {
Expand Down
8 changes: 5 additions & 3 deletions src/component/misc/ConfirmCancelDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ConfirmCancelDialog: React.FC<ConfirmCancelDialogProps> = (props) => {
<ButtonToolbar className="float-right">
<Button
id={`${props.id}-submit`}
color={props.confirmColor || "primary"}
color={props.confirmColor}
size="sm"
disabled={props.confirmDisabled}
onClick={props.onConfirm}
Expand All @@ -53,7 +53,7 @@ const ConfirmCancelDialog: React.FC<ConfirmCancelDialogProps> = (props) => {
</Button>
<Button
id={`${props.id}-cancel`}
color={props.cancelColor || "outline-dark"}
color={props.cancelColor}
size="sm"
onClick={props.onClose}
>
Expand All @@ -66,8 +66,10 @@ const ConfirmCancelDialog: React.FC<ConfirmCancelDialogProps> = (props) => {
};

ConfirmCancelDialog.defaultProps = {
cancelKey: "cancel",
confirmColor: "primary",
confirmDisabled: false,
cancelKey: "cancel",
cancelColor: "outline-dark",
};

export default ConfirmCancelDialog;
8 changes: 5 additions & 3 deletions src/component/vocabulary/RemoveVocabularyDialog.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#remove-vocabulary-dialog {
.modal-header {
background-color: var(--danger);
}
.modal-body {
ul {
padding: 0;
Expand All @@ -11,6 +8,11 @@
padding: 5px 0 5px 10px;
border-bottom: 1px solid lightgray;
}
details {
.row:hover {
background-color: rgba(0, 126, 255, 0.1);
}
}
}
}

Expand Down
50 changes: 24 additions & 26 deletions src/component/vocabulary/RemoveVocabularyDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useI18n } from "../hook/useI18n";
import Utils from "../../util/Utils";
import ConfirmCancelDialog from "../misc/ConfirmCancelDialog";
import { Label } from "reactstrap";
import { Col, Label, Row } from "reactstrap";
import Vocabulary from "../../model/Vocabulary";
import PromiseTrackingMask from "../misc/PromiseTrackingMask";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -82,10 +82,6 @@ const RemoveVocabularyDialog: React.FC<RemoveVocabularyDialogProps> = (
return () => controller.abort();
}, [props.vocabulary, props.show, dispatch]);

const cancel = () => {
props.onCancel();
};

const submit = () => {
if (validateInput() !== ValidationResult.VALID && !canRemoveSilently) {
return;
Expand All @@ -100,28 +96,28 @@ const RemoveVocabularyDialog: React.FC<RemoveVocabularyDialogProps> = (
) =>
statements.map((statement, index) => {
return (
<li key={keyBase + index}>
<span id={keyBase + index + "object"}>
<LinkComponent iri={statement.object.iri} />
</span>
<br />
<span id={keyBase + index + "relation"}>
<AssetLabel iri={statement.relation.iri} shrinkFullIri={true} />
<CopyIriIcon url={statement.relation.iri} />
</span>
<br />
<span id={keyBase + index + "subject"}>
<AssetLabel iri={statement.subject.iri} shrinkFullIri={true} />
<CopyIriIcon url={statement.subject.iri} />
</span>
</li>
<Row key={keyBase + index + "row"}>
<Col md={4} xs={12}>
<span id={keyBase + index + "object"}>
<LinkComponent iri={statement.object.iri} />
</span>
</Col>
<Col md={4} xs={12}>
<span id={keyBase + index + "relation"}>
<AssetLabel iri={statement.relation.iri} shrinkFullIri={true} />
<CopyIriIcon url={statement.relation.iri} />
</span>
</Col>
<Col md={4} xs={12}>
<span id={keyBase + index + "subject"}>
<AssetLabel iri={statement.subject.iri} shrinkFullIri={true} />
<CopyIriIcon url={statement.subject.iri} />
</span>
</Col>
</Row>
);
});

const onInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setconfirmationVocabularyName(e.currentTarget.value);
};

const isConfirmDisabled =
!canRemoveSilently &&
(!canRemove ||
Expand Down Expand Up @@ -157,7 +153,9 @@ const RemoveVocabularyDialog: React.FC<RemoveVocabularyDialogProps> = (
<CustomInput
label={i18n("vocabulary.remove.dialog.input.label")}
value={confirmationVocabularyName}
onChange={onInputChange}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setconfirmationVocabularyName(e.currentTarget.value)
}
validation={validateInput()}
/>
</If>
Expand Down Expand Up @@ -219,7 +217,7 @@ const RemoveVocabularyDialog: React.FC<RemoveVocabularyDialogProps> = (
<ConfirmCancelDialog
show={props.show}
id="remove-vocabulary-dialog"
onClose={cancel}
onClose={() => props.onCancel()}
onConfirm={submit}
confirmColor={"outline-danger"}
confirmDisabled={isConfirmDisabled}
Expand Down
1 change: 1 addition & 0 deletions src/component/vocabulary/VocabularySummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class VocabularySummary extends EditableComponent<
}
if (prevProps.vocabulary.iri !== vocabulary.iri) {
this.onCloseEdit();
this.onCloseRemove();
this.setState({
language: resolveInitialLanguage(
vocabulary,
Expand Down
4 changes: 2 additions & 2 deletions src/i18n/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ const cs = {
"vocabulary.select-vocabulary": "Vyberte slovník",

"vocabulary.remove.dialog.text.nonEmpty":
"Opravdu chcete odstranit <b>neprázdný</b> slovník?",
"Opravdu chcete odstranit <b>neprázdný</b> slovník?",
"vocabulary.remove.dialog.text.empty":
"Opravdu chcete odstranit <b>prázdný</b> slovník?",
"Opravdu chcete odstranit <b>prázdný</b> slovník?",
"vocabulary.remove.dialog.text.termCount":
"Jeho odstraněním dojde k trvalému smazání {count, plural, one {<b>1</b> pojmu} other {<b>#</b> pojmů}}, dokumentu a všech souvisejících souborů.",
"vocabulary.remove.dialog.text.permanent": "Tato akce je nevratná!",
Expand Down

0 comments on commit f5624d1

Please sign in to comment.