Skip to content

Commit

Permalink
Fix missing badges in policies
Browse files Browse the repository at this point in the history
  • Loading branch information
lupusA committed Sep 23, 2023
1 parent 6c2a2d4 commit 6f8df9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
40 changes: 12 additions & 28 deletions src/PoliciesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,36 +120,20 @@ export class PoliciesTable extends Component {
});
}

policySummary(p) {
policySummary(policies) {
let bits = [];
function isEmpty(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key))
return false;
}

return true;
}

let bits = [];
if (!isEmpty(p.policy.retention)) {
bits.push(<><Badge bg="success">retention</Badge>{' '}</>);
}
if (!isEmpty(p.policy.files)) {
bits.push(<><Badge bg="primary">files</Badge>{' '}</>);
}
if (!isEmpty(p.policy.errorHandling)) {
bits.push(<><Badge bg="danger">errors</Badge>{' '}</>);
}
if (!isEmpty(p.policy.compression)) {
bits.push(<><Badge bg="secondary">compression</Badge>{' '}</>);
}
if (!isEmpty(p.policy.scheduling)) {
bits.push(<><Badge bg="warning">scheduling</Badge>{' '}</>);
}
if (!isEmpty(p.policy.upload)) {
bits.push(<><Badge bg="info">upload</Badge>{' '}</>);
for (let pol in policies.policy) {
if (!isEmpty(policies.policy[pol])) {
bits.push(<><Badge className="policy-badge">{pol}</Badge></>);
}
}

return bits;
}

Expand Down Expand Up @@ -213,16 +197,16 @@ export class PoliciesTable extends Component {
break;
};

policies.sort((l,r) => {
const hc = compare(l.target.host,r.target.host);
policies.sort((l, r) => {
const hc = compare(l.target.host, r.target.host);
if (hc) {
return hc;
}
const uc = compare(l.target.userName,r.target.userName);
const uc = compare(l.target.userName, r.target.userName);
if (uc) {
return uc;
}
return compare(l.target.path,r.target.path);
return compare(l.target.path, r.target.path);
});


Expand Down Expand Up @@ -273,8 +257,8 @@ export class PoliciesTable extends Component {
{(this.state.selectedOwner === localPolicies || this.state.selectedOwner === this.state.localSourceName || this.state.selectedOwner === applicablePolicies) ? <>
<Col>
<DirectorySelector autoFocus onDirectorySelected={p => this.setState({ policyPath: p })}
placeholder="enter directory to find or set policy"
name="policyPath" value={this.state.policyPath} onChange={this.handleChange} />
placeholder="enter directory to find or set policy"
name="policyPath" value={this.state.policyPath} onChange={this.handleChange} />
</Col>
<Col xs="auto">
<Button disabled={!this.state.policyPath} size="sm" type="submit" onClick={this.editPolicyForPath}>Set Policy</Button>
Expand Down
7 changes: 7 additions & 0 deletions src/css/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ div.tab-body {
margin: 2px;
}

.policy-badge {
margin-block-start: 5px;
margin-right: 5px;
background-color: var(--color-primary) !important;
color: var(--text-color) !important;
}

.page-title {
margin-left: 10px;
font-weight: bold;
Expand Down

0 comments on commit 6f8df9a

Please sign in to comment.