This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6922 from matrix-org/travis/hide-buttons-customis…
…ation Add customisation point for visibility of invites and room creation
- Loading branch information
Showing
11 changed files
with
146 additions
and
43 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright 2021 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Dev note: this customisation point is heavily inspired by UIFeature flags, though | ||
// with an intention of being used for more complex switching on whether or not a feature | ||
// should be shown. | ||
|
||
// Populate this class with the details of your customisations when copying it. | ||
|
||
import { UIComponent } from "../settings/UIFeature"; | ||
|
||
/** | ||
* Determines whether or not the active MatrixClient user should be able to use | ||
* the given UI component. If shown, the user might still not be able to use the | ||
* component depending on their contextual permissions. For example, invite options | ||
* might be shown to the user but they won't have permission to invite users to | ||
* the current room: the button will appear disabled. | ||
* @param {UIComponent} component The component to check visibility for. | ||
* @returns {boolean} True (default) if the user is able to see the component, false | ||
* otherwise. | ||
*/ | ||
function shouldShowComponent(component: UIComponent): boolean { | ||
return true; // default to visible | ||
} | ||
|
||
// This interface summarises all available customisation points and also marks | ||
// them all as optional. This allows customisers to only define and export the | ||
// customisations they need while still maintaining type safety. | ||
export interface IComponentVisibilityCustomisations { | ||
shouldShowComponent?: typeof shouldShowComponent; | ||
} | ||
|
||
// A real customisation module will define and export one or more of the | ||
// customisation points that make up the interface above. | ||
export const ComponentVisibilityCustomisations: IComponentVisibilityCustomisations = { | ||
// while we don't specify the functions here, their defaults are described | ||
// in their pseudo-implementations above. | ||
}; |
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,22 @@ | ||
/* | ||
Copyright 2021 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { UIComponent } from "../../settings/UIFeature"; | ||
import { ComponentVisibilityCustomisations } from "../ComponentVisibility"; | ||
|
||
export function shouldShowComponent(component: UIComponent): boolean { | ||
return ComponentVisibilityCustomisations.shouldShowComponent?.(component) ?? true; | ||
} |
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