Skip to content

Commit

Permalink
chore: Remove now unused ts-expect-error comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 24, 2024
1 parent 6b01106 commit 7e9af41
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/settings/AdminGroupSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class AdminGroupSelect extends Component<AdminGroupSelectProps> {
}
})

/* @ts-expect-error Typescript error due to async react component */
return <Select
onChange={ this.updateDelegatedAdminGroups.bind(this) }
isDisabled={getCurrentUser() ? !getCurrentUser()!.isAdmin : true}
Expand Down
8 changes: 1 addition & 7 deletions src/settings/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,12 @@ export class App extends Component<{}, AppState> implements OC.Plugin<OC.Search.
<p><em>{ t('groupfolders', 'Nextcloud allows you to delegate the administration of group folders to non-admin users.') }</em></p>
<p><em>{ t('groupfolders', 'Specify below the groups that will be allowed to manage group folders and use its API/REST.') }</em></p>
<p className="end-description-delegation"><em>{ t('groupfolders', 'They will have access to all group folders.') }</em></p>
{/* @ts-expect-error Typescript error due to async react component */}
<AdminGroupSelect
groups={this.state.groups}
allGroups={this.state.groups}
delegatedAdminGroups={this.state.delegatedAdminGroups} />
<p><em>{ t('groupfolders', 'Specify below the groups that will be allowed to manage group folders and use its API/REST only.') }</em></p>
<p className="end-description-delegation"><em>{ t('groupfolders', 'They will only have access to group folders for which they have advanced permissions.') }</em></p>
{/* @ts-expect-error Typescript error due to async react component */}
<SubAdminGroupSelect
groups={this.state.groups}
allGroups={this.state.groups}
Expand Down Expand Up @@ -239,15 +237,14 @@ export class App extends Component<{}, AppState> implements OC.Plugin<OC.Search.
if (!a.acl && b.acl) {
return -this.state.sortOrder
}
return 0
}
return 0
})
.map(folder => {
const id = folder.id
return <tr key={id}>
<td className="mountpoint">
{this.state.editingMountPoint === id
/* @ts-expect-error Typescript error due to async react component */
? <SubmitInput
autoFocus={true}
onSubmitValue={this.renameFolder.bind(this, folder)}
Expand Down Expand Up @@ -283,7 +280,6 @@ export class App extends Component<{}, AppState> implements OC.Plugin<OC.Search.
/>
</td>
<td className="quota">
{/* @ts-expect-error Typescript error due to async react component */}
<QuotaSelect options={defaultQuotaOptions}
value={folder.quota}
size={folder.size}
Expand Down Expand Up @@ -346,7 +342,6 @@ export class App extends Component<{}, AppState> implements OC.Plugin<OC.Search.
<th/>
</tr>
</thead>
{/* @ts-expect-error Typescript error due to async react component */}
<FlipMove typeName='tbody' enterAnimation="accordionVertical" leaveAnimation="accordionVertical">
{rows}
<tr>
Expand Down Expand Up @@ -398,7 +393,6 @@ function ManageAclSelect({ onChange, onSearch, folder }: ManageAclSelectProps) {
return item.type === 'user' ? t('groupfolders', 'User') : t('groupfolders', 'Group')
}

/* @ts-expect-error Typescript error due to async react component */
return <AsyncSelect
loadOptions={handleSearch}
isMulti
Expand Down
29 changes: 14 additions & 15 deletions src/settings/FolderGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Circle, Group } from './Api'
import { loadState } from '@nextcloud/initial-state'

function hasPermissions(value: number, check: number): boolean {
return (value & check) === check;
return (value & check) === check
}

export interface FolderGroupsProps {
Expand All @@ -33,17 +33,17 @@ export function FolderGroups({groups, allGroups = [], allCircles = [], onAddGrou
const displayNames = Object.keys(groups).map(groupId => {
return allCircles.find(circle => circle.singleId === groupId)?.displayName
|| allGroups.find(group => group.gid === groupId)?.displayName
|| groupId;
});
|| groupId
})

if (edit) {
const setPermissions = (change: number, groupId: string): void => {
const newPermissions = groups[groupId] ^ change;
onSetPermissions(groupId, newPermissions);
const newPermissions = groups[groupId] ^ change
onSetPermissions(groupId, newPermissions)
};

const rows = Object.keys(groups).map((groupId, index) => {
const permissions = groups[groupId];
const permissions = groups[groupId]
return <tr key={groupId}>
<td>{displayNames[index]}</td>
<td className="permissions">
Expand All @@ -65,8 +65,8 @@ export function FolderGroups({groups, allGroups = [], allCircles = [], onAddGrou
<a onClick={removeGroup.bind(this, groupId)} className="close-btn"></a>
</td>
</tr>
});
})


return <table className="group-edit"
onClick={event => event.stopPropagation()}>
Expand Down Expand Up @@ -98,7 +98,7 @@ export function FolderGroups({groups, allGroups = [], allCircles = [], onAddGrou
<a className="icon icon-rename" onClick={showEdit}/>
</span>
}

return <a className="action-rename" onClick={showEdit}>
{displayNames.join(', ')}
</a>
Expand All @@ -120,27 +120,26 @@ function AdminGroupSelect({allGroups, allCircles, onChange}: CircleGroupSelectPr
if (allGroups.length === 0 && allCircles.length === 0) {
return <div className="no-options-available">
<p>{emptyGroups}</p>
</div>;
</div>
}
const groups = allGroups.map(group => {
return {
value: group.gid,
label: group.displayName
};
});
}
})
const circles = allCircles.map(circle => {
return {
value: circle.singleId,
label: t('groupfolders', '{displayName} (team)', {...circle})
};
});
}
})
const options = [...groups, ...circles]

const placeholder = isCirclesEnabled
? t('groupfolders', 'Add group or team')
: t('groupfolders', 'Add group')

/* @ts-expect-error Typescript error due to async react component */
return <Select
onChange={option => {
onChange && option && onChange(option.value)
Expand Down
4 changes: 2 additions & 2 deletions src/settings/Nextcloud.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ declare module 'NC' {
totalitems: number;
itemsperpage: number;
}
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/settings/QuotaSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class QuotaSelect extends Component<QuotaSelectProps, QuotaSelectState> {
return Math.min((this.props.size / this.props.value) * 100, 100);
} else {
const usedInGB = this.props.size / (10 * Math.pow(2, 30));
//asymptotic curve approaching 50% at 10GB to visualize used stace with infinite quota
// asymptotic curve approaching 50% at 10GB to visualize used stace with infinite quota
return 95 * (1 - (1 / (usedInGB + 1)));
}
}
Expand Down
1 change: 0 additions & 1 deletion src/settings/SubAdminGroupSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class SubAdminGroupSelect extends Component<SubAdminGroupSelectProps> {
}
})

/* @ts-expect-error Typescript error due to async react component */
return <Select
onChange={ this.updateDelegatedSubAdminGroups.bind(this) }
isDisabled={getCurrentUser() ? !getCurrentUser()!.isAdmin : true}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "src/**/*.tsx"],
"compilerOptions": {
"lib": [
"dom",
Expand Down

0 comments on commit 7e9af41

Please sign in to comment.