-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ventilated boxcar none freight * Permissions editor * Bump webpack from 5.93.0 to 5.94.0 --------- Co-authored-by: Scott Anderson <[email protected]>
- Loading branch information
1 parent
2a5d0a0
commit d351ce5
Showing
5 changed files
with
125 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
export interface Permission { | ||
values: boolean[]; | ||
} | ||
|
||
export const permissionLabels = [ | ||
'Build', | ||
'Demolish', | ||
'Industries and Facilities', | ||
'Purchase', | ||
'Switches', | ||
'Vehicles', | ||
'Remove Vegetation', | ||
'Rerail', | ||
] as const satisfies ReadonlyArray<string>; | ||
|
||
export function permissionToString(value?: Permission) { | ||
if (typeof value === 'undefined') return 'undefined'; | ||
const {values} = value; | ||
if (values.every(Boolean)) return 'all'; | ||
if (!values.some(Boolean)) return 'none'; | ||
return values | ||
.map((v, i) => [v, i < permissionLabels.length ? permissionLabels[i] : `Unknown permission ${i}`]) | ||
.filter(([v]) => v) | ||
.map(([, l]) => l) | ||
.join(', '); | ||
} | ||
|
||
export function permissionEqual( | ||
a: Permission | undefined, | ||
b: Permission | undefined, | ||
): boolean { | ||
if (typeof a === 'undefined') return typeof b === 'undefined'; | ||
if (typeof b === 'undefined') return false; | ||
if (a.values.length !== b.values.length) return false; | ||
return a.values.every((v, i) => v === b.values[i]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters