This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-20460] Migrate 'components/permissions_gates/channel_permission_g…
…ate' module and associated tests to TypeScript (#6601) * Migrate channel_permission_gate to TypeScript * Rename test file to TypeScript Co-authored-by: Mattermod <[email protected]>
- Loading branch information
1 parent
99d650f
commit 425cc09
Showing
5 changed files
with
60 additions
and
63 deletions.
There are no files selected for viewing
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
54 changes: 0 additions & 54 deletions
54
components/permissions_gates/channel_permission_gate/channel_permission_gate.jsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
51 changes: 51 additions & 0 deletions
51
components/permissions_gates/channel_permission_gate/channel_permission_gate.tsx
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
|
||
type Props = { | ||
|
||
/** | ||
* Channel to check the permission | ||
*/ | ||
channelId?: string; | ||
|
||
/** | ||
* Team to check the permission | ||
*/ | ||
teamId?: string; | ||
|
||
/** | ||
* Permissions enough to pass the gate (binary OR) | ||
*/ | ||
permissions: string[]; | ||
|
||
/** | ||
* Has permission | ||
*/ | ||
hasPermission: boolean; | ||
|
||
/** | ||
* Invert the permission (used for else) | ||
*/ | ||
invert?: boolean; | ||
|
||
/** | ||
* Content protected by the permissions gate | ||
*/ | ||
children: React.ReactNode; | ||
} | ||
|
||
export default class ChannelPermissionGate extends React.PureComponent<Props> { | ||
render() { | ||
const {hasPermission, children, invert = false} = this.props; | ||
|
||
if (hasPermission && !invert) { | ||
return children; | ||
} | ||
if (!hasPermission && invert) { | ||
return children; | ||
} | ||
return null; | ||
} | ||
} |
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