-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added default visibility command provider.
- Loading branch information
Showing
7 changed files
with
141 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { WidgetContext } from "@paperbits/common/editing"; | ||
import { IContextCommand } from "@paperbits/common/ui"; | ||
import { IVisibilityContextCommandProvider } from "./visibilityContextCommandProvider"; | ||
|
||
/** | ||
* Default visibility command provider. Returns null, which means that no visibility command will be displayed. | ||
*/ | ||
export class DefaultVisibilityCommandProvider implements IVisibilityContextCommandProvider { | ||
public create(context: WidgetContext): IContextCommand { | ||
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
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 |
---|---|---|
@@ -1,34 +1,14 @@ | ||
import { WidgetContext } from "@paperbits/common/editing"; | ||
import { IContextCommand } from "@paperbits/common/ui/IContextCommandSet"; | ||
import { IComponent } from "@paperbits/common/ui/IComponent"; | ||
import { SecurityModelEditor } from "./securityModelEditor"; | ||
import { IContextCommand } from "@paperbits/common/ui"; | ||
|
||
export interface IVisibilityCommandProvider { | ||
/** | ||
* Provider for visibility context command. Using widget context, it determines whether visibility command | ||
* should be displayed for the given widget. | ||
*/ | ||
export interface IVisibilityContextCommandProvider { | ||
/** | ||
* Creates a visibility command for the given widget context. | ||
* @param context Widget context. | ||
*/ | ||
create(context: WidgetContext): IContextCommand; | ||
} | ||
|
||
export function createStandardVisibilityCommand(callback: IContextCommand["callback"], overrides?: Partial<Exclude<IContextCommand, "callback">>): IContextCommand { | ||
return { | ||
controlType: "toolbox-button", | ||
tooltip: "Change access", | ||
iconClass: "paperbits-icon paperbits-a-security", | ||
position: "top right", | ||
color: "#607d8b", | ||
...overrides, | ||
callback, | ||
}; | ||
} | ||
|
||
export function createSecurityModelEditorComponent(context: WidgetContext, componentSelector: string): IComponent { | ||
const securityModelEditorParams: SecurityModelEditor = { | ||
securityModel: context.binding.model.security, | ||
onChange: (securityModel): void => { | ||
context.binding.model.security = securityModel; | ||
context.binding.applyChanges(context.model); | ||
}, | ||
}; | ||
return { | ||
name: componentSelector, | ||
params: securityModelEditorParams, | ||
}; | ||
} | ||
} |