2022-11-02 17:57:25 +01:00
|
|
|
import { FormBuilder, FormsModule, ReactiveFormsModule } from "@angular/forms";
|
|
|
|
import { action } from "@storybook/addon-actions";
|
|
|
|
import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
|
|
|
|
|
|
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
[AC-1011] Admin Console / Billing code ownership (#4973)
* refactor: move SCIM component to admin-console, refs EC-1011
* refactor: move scimProviderType to admin-console, refs EC-1011
* refactor: move scim-config.api to admin-console, refs EC-1011
* refactor: create models folder and nest existing api contents, refs EC-1011
* refactor: move scim-config to admin-console models, refs EC-1011
* refactor: move billing.component to billing, refs EC-1011
* refactor: remove nested app folder from new billing structure, refs EC-1011
* refactor: move organizations/billing to billing, refs EC-1011
* refactor: move add-credit and adjust-payment to billing/settings, refs EC-1011
* refactor: billing history/sync to billing, refs EC-1011
* refactor: move org plans, payment/method to billing/settings, refs EC-1011
* fix: update legacy file paths for payment-method and tax-info, refs EC-1011
* fix: update imports for scim component, refs EC-1011
* refactor: move subscription and tax-info into billing, refs EC-1011
* refactor: move user-subscription to billing, refs EC-1011
* refactor: move images/cards to billing and update base path, refs EC-1011
* refactor: move payment-method, plan subscription, and plan to billing, refs EC-1011
* refactor: move transaction-type to billing, refs EC-1011
* refactor: move billing-sync-config to billing, refs EC-1011
* refactor: move billing-sync and bit-pay-invoice request to billing, refs EC-1011
* refactor: move org subscription and tax info update requests to billing, refs EC-1011
* fix: broken paths to billing, refs EC-1011
* refactor: move payment request to billing, refs EC-1011
* fix: update remaining imports for payment-request, refs EC-1011
* refactor: move tax-info-update to billing, refs EC-1011
* refactor: move billing-payment, billing-history, and billing responses to billing, refs EC-1011
* refactor: move organization-subscription-responset to billing, refs EC-1011
* refactor: move payment and plan responses to billing, refs EC-1011
* refactor: move subscription response to billing ,refs EC-1011
* refactor: move tax info and rate responses to billing, refs EC-1011
* fix: update remaining path to base response for tax-rate response, refs EC-1011
* refactor: (browser) move organization-service to admin-console, refs EC-1011
* refactor: (browser) move organizaiton-service to admin-console, refs EC-1011
* refactor: (cli) move share command to admin-console, refs EC-1011
* refactor: move organization-collect request model to admin-console, refs EC-1011
* refactor: (web) move organization, collection/user responses to admin-console, refs EC-1011
* refactor: (cli) move selection-read-only to admin-console, refs EC-1011
* refactor: (desktop) move organization-filter to admin-console, refs EC-1011
* refactor: (web) move organization-switcher to admin-console, refs EC-1011
* refactor: (web) move access-selector to admin-console, refs EC-1011
* refactor: (web) move create folder to admin-console, refs EC-1011
* refactor: (web) move org guards folder to admin-console, refs EC-1011
* refactor: (web) move org layout to admin-console, refs EC-1011
* refactor: move manage collections to admin console, refs EC-1011
* refactor: (web) move collection-dialog to admin-console, refs EC-1011
* refactor: (web) move entity users/events and events component to admin-console, refs EC-1011
* refactor: (web) move groups/group-add-edit to admin-console, refs EC-1011
* refactor: (web) move manage, org-manage module, and user-confirm to admin-console, refs EC-1011
* refactor: (web) move people to admin-console, refs EC-1011
* refactor: (web) move reset-password to admin-console, refs EC-1011
* refactor: (web) move organization-routing and module to admin-console, refs EC-1011
* refactor: move admin-console and billing within app scope, refs EC-1011
* fix: update leftover merge conflicts, refs EC-1011
* refactor: (web) member-dialog to admin-console, refs EC-1011
* refactor: (web) move policies to admin-console, refs EC-1011
* refactor: (web) move reporting to admin-console, refs EC-1011
* refactor: (web) move settings to admin-console, refs EC-1011
* refactor: (web) move sponsorships to admin-console, refs EC-1011
* refactor: (web) move tools to admin-console, refs EC-1011
* refactor: (web) move users to admin-console, refs EC-1011
* refactor: (web) move collections to admin-console, refs EC-1011
* refactor: (web) move create-organization to admin-console, refs EC-1011
* refactor: (web) move licensed components to admin-console, refs EC-1011
* refactor: (web) move bit organization modules to admin-console, refs EC-1011
* fix: update leftover import statements for organizations.module, refs EC-1011
* refactor: (web) move personal vault and max timeout to admin-console, refs EC-1011
* refactor: (web) move providers to admin-console, refs EC-1011
* refactor: (libs) move organization service to admin-console, refs EC-1011
* refactor: (libs) move profile org/provider responses and other misc org responses to admin-console, refs EC-1011
* refactor: (libs) move provider request and selectionion-read-only request to admin-console, refs EC-1011
* fix: update missed import path for provider-user-update request, refs EC-1011
* refactor: (libs) move abstractions to admin-console, refs EC-1011
* refactor: (libs) move org/provider enums to admin-console, refs EC-1011
* fix: update downstream import statements from libs changes, refs EC-1011
* refactor: (libs) move data files to admin-console, refs EC-1011
* refactor: (libs) move domain to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* fix: update downstream import changes from libs, refs EC-1011
* refactor: move leftover provider files to admin-console, refs EC-1011
* refactor: (browser) move group policy environment to admin-console, refs EC-1011
* fix: (browser) update downstream import statements, refs EC-1011
* fix: (desktop) update downstream libs moves, refs EC-1011
* fix: (cli) update downstream import changes from libs, refs EC-1011
* refactor: move org-auth related files to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* refactor: move persmissions to admin-console, refs EC-1011
* refactor: move sponsored families to admin-console and fix libs changes, refs EC-1011
* refactor: move collections to admin-console, refs EC-1011
* refactor: move spec file back to spec scope, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: udpate downstream import changes due to libs, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: update downstream imports from libs changes, refs EC-1011
* fix: update path malformation in jslib-services.module, refs EC-1011
* fix: lint errors from improper casing, refs AC-1011
* fix: update downstream filename changes, refs AC-1011
* fix: (cli) update downstream filename changes, refs AC-1011
* fix: (desktop) update downstream filename changes, refs AC-1011
* fix: (browser) update downstream filename changes, refs AC-1011
* fix: lint errors, refs AC-1011
* fix: prettier, refs AC-1011
* fix: lint fixes for import order, refs AC-1011
* fix: update import path for provider user type, refs AC-1011
* fix: update new codes import paths for admin console structure, refs AC-1011
* fix: lint/prettier, refs AC-1011
* fix: update layout stories path, refs AC-1011
* fix: update comoponents card icons base variable in styles, refs AC-1011
* fix: update provider service path in permissions guard spec, refs AC-1011
* fix: update provider permission guard path, refs AC-1011
* fix: remove unecessary TODO for shared index export statement, refs AC-1011
* refactor: move browser-organization service and cli organization-user response out of admin-console, refs AC-1011
* refactor: move web/browser/desktop collections component to vault domain, refs AC-1011
* refactor: move organization.module out of admin-console scope, refs AC-1011
* fix: prettier, refs AC-1011
* refactor: move organizations-api-key.request out of admin-console scope, refs AC-1011
2023-03-22 16:03:50 +01:00
|
|
|
import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums/organization-user-status-type";
|
|
|
|
import { OrganizationUserType } from "@bitwarden/common/admin-console/enums/organization-user-type";
|
2022-11-02 17:57:25 +01:00
|
|
|
import {
|
|
|
|
AvatarModule,
|
|
|
|
BadgeModule,
|
|
|
|
ButtonModule,
|
2022-12-21 14:36:36 +01:00
|
|
|
DialogModule,
|
2022-11-02 17:57:25 +01:00
|
|
|
FormFieldModule,
|
|
|
|
IconButtonModule,
|
|
|
|
TableModule,
|
|
|
|
TabsModule,
|
|
|
|
} from "@bitwarden/components";
|
|
|
|
|
[AC-1011] Admin Console / Billing code ownership (#4973)
* refactor: move SCIM component to admin-console, refs EC-1011
* refactor: move scimProviderType to admin-console, refs EC-1011
* refactor: move scim-config.api to admin-console, refs EC-1011
* refactor: create models folder and nest existing api contents, refs EC-1011
* refactor: move scim-config to admin-console models, refs EC-1011
* refactor: move billing.component to billing, refs EC-1011
* refactor: remove nested app folder from new billing structure, refs EC-1011
* refactor: move organizations/billing to billing, refs EC-1011
* refactor: move add-credit and adjust-payment to billing/settings, refs EC-1011
* refactor: billing history/sync to billing, refs EC-1011
* refactor: move org plans, payment/method to billing/settings, refs EC-1011
* fix: update legacy file paths for payment-method and tax-info, refs EC-1011
* fix: update imports for scim component, refs EC-1011
* refactor: move subscription and tax-info into billing, refs EC-1011
* refactor: move user-subscription to billing, refs EC-1011
* refactor: move images/cards to billing and update base path, refs EC-1011
* refactor: move payment-method, plan subscription, and plan to billing, refs EC-1011
* refactor: move transaction-type to billing, refs EC-1011
* refactor: move billing-sync-config to billing, refs EC-1011
* refactor: move billing-sync and bit-pay-invoice request to billing, refs EC-1011
* refactor: move org subscription and tax info update requests to billing, refs EC-1011
* fix: broken paths to billing, refs EC-1011
* refactor: move payment request to billing, refs EC-1011
* fix: update remaining imports for payment-request, refs EC-1011
* refactor: move tax-info-update to billing, refs EC-1011
* refactor: move billing-payment, billing-history, and billing responses to billing, refs EC-1011
* refactor: move organization-subscription-responset to billing, refs EC-1011
* refactor: move payment and plan responses to billing, refs EC-1011
* refactor: move subscription response to billing ,refs EC-1011
* refactor: move tax info and rate responses to billing, refs EC-1011
* fix: update remaining path to base response for tax-rate response, refs EC-1011
* refactor: (browser) move organization-service to admin-console, refs EC-1011
* refactor: (browser) move organizaiton-service to admin-console, refs EC-1011
* refactor: (cli) move share command to admin-console, refs EC-1011
* refactor: move organization-collect request model to admin-console, refs EC-1011
* refactor: (web) move organization, collection/user responses to admin-console, refs EC-1011
* refactor: (cli) move selection-read-only to admin-console, refs EC-1011
* refactor: (desktop) move organization-filter to admin-console, refs EC-1011
* refactor: (web) move organization-switcher to admin-console, refs EC-1011
* refactor: (web) move access-selector to admin-console, refs EC-1011
* refactor: (web) move create folder to admin-console, refs EC-1011
* refactor: (web) move org guards folder to admin-console, refs EC-1011
* refactor: (web) move org layout to admin-console, refs EC-1011
* refactor: move manage collections to admin console, refs EC-1011
* refactor: (web) move collection-dialog to admin-console, refs EC-1011
* refactor: (web) move entity users/events and events component to admin-console, refs EC-1011
* refactor: (web) move groups/group-add-edit to admin-console, refs EC-1011
* refactor: (web) move manage, org-manage module, and user-confirm to admin-console, refs EC-1011
* refactor: (web) move people to admin-console, refs EC-1011
* refactor: (web) move reset-password to admin-console, refs EC-1011
* refactor: (web) move organization-routing and module to admin-console, refs EC-1011
* refactor: move admin-console and billing within app scope, refs EC-1011
* fix: update leftover merge conflicts, refs EC-1011
* refactor: (web) member-dialog to admin-console, refs EC-1011
* refactor: (web) move policies to admin-console, refs EC-1011
* refactor: (web) move reporting to admin-console, refs EC-1011
* refactor: (web) move settings to admin-console, refs EC-1011
* refactor: (web) move sponsorships to admin-console, refs EC-1011
* refactor: (web) move tools to admin-console, refs EC-1011
* refactor: (web) move users to admin-console, refs EC-1011
* refactor: (web) move collections to admin-console, refs EC-1011
* refactor: (web) move create-organization to admin-console, refs EC-1011
* refactor: (web) move licensed components to admin-console, refs EC-1011
* refactor: (web) move bit organization modules to admin-console, refs EC-1011
* fix: update leftover import statements for organizations.module, refs EC-1011
* refactor: (web) move personal vault and max timeout to admin-console, refs EC-1011
* refactor: (web) move providers to admin-console, refs EC-1011
* refactor: (libs) move organization service to admin-console, refs EC-1011
* refactor: (libs) move profile org/provider responses and other misc org responses to admin-console, refs EC-1011
* refactor: (libs) move provider request and selectionion-read-only request to admin-console, refs EC-1011
* fix: update missed import path for provider-user-update request, refs EC-1011
* refactor: (libs) move abstractions to admin-console, refs EC-1011
* refactor: (libs) move org/provider enums to admin-console, refs EC-1011
* fix: update downstream import statements from libs changes, refs EC-1011
* refactor: (libs) move data files to admin-console, refs EC-1011
* refactor: (libs) move domain to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* fix: update downstream import changes from libs, refs EC-1011
* refactor: move leftover provider files to admin-console, refs EC-1011
* refactor: (browser) move group policy environment to admin-console, refs EC-1011
* fix: (browser) update downstream import statements, refs EC-1011
* fix: (desktop) update downstream libs moves, refs EC-1011
* fix: (cli) update downstream import changes from libs, refs EC-1011
* refactor: move org-auth related files to admin-console, refs EC-1011
* refactor: (libs) move request objects to admin-console, refs EC-1011
* refactor: move persmissions to admin-console, refs EC-1011
* refactor: move sponsored families to admin-console and fix libs changes, refs EC-1011
* refactor: move collections to admin-console, refs EC-1011
* refactor: move spec file back to spec scope, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: udpate downstream import changes due to libs, refs EC-1011
* fix: update downstream imports due to libs changes, refs EC-1011
* fix: update downstream imports from libs changes, refs EC-1011
* fix: update path malformation in jslib-services.module, refs EC-1011
* fix: lint errors from improper casing, refs AC-1011
* fix: update downstream filename changes, refs AC-1011
* fix: (cli) update downstream filename changes, refs AC-1011
* fix: (desktop) update downstream filename changes, refs AC-1011
* fix: (browser) update downstream filename changes, refs AC-1011
* fix: lint errors, refs AC-1011
* fix: prettier, refs AC-1011
* fix: lint fixes for import order, refs AC-1011
* fix: update import path for provider user type, refs AC-1011
* fix: update new codes import paths for admin console structure, refs AC-1011
* fix: lint/prettier, refs AC-1011
* fix: update layout stories path, refs AC-1011
* fix: update comoponents card icons base variable in styles, refs AC-1011
* fix: update provider service path in permissions guard spec, refs AC-1011
* fix: update provider permission guard path, refs AC-1011
* fix: remove unecessary TODO for shared index export statement, refs AC-1011
* refactor: move browser-organization service and cli organization-user response out of admin-console, refs AC-1011
* refactor: move web/browser/desktop collections component to vault domain, refs AC-1011
* refactor: move organization.module out of admin-console scope, refs AC-1011
* fix: prettier, refs AC-1011
* refactor: move organizations-api-key.request out of admin-console scope, refs AC-1011
2023-03-22 16:03:50 +01:00
|
|
|
import { PreloadedEnglishI18nModule } from "../../../../../tests/preloaded-english-i18n.module";
|
2022-11-02 17:57:25 +01:00
|
|
|
|
|
|
|
import { AccessSelectorComponent } from "./access-selector.component";
|
|
|
|
import { AccessItemType, AccessItemView, CollectionPermission } from "./access-selector.models";
|
|
|
|
import { UserTypePipe } from "./user-type.pipe";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: "Web/Organizations/Access Selector",
|
|
|
|
decorators: [
|
|
|
|
moduleMetadata({
|
|
|
|
declarations: [AccessSelectorComponent, UserTypePipe],
|
|
|
|
imports: [
|
2022-12-21 14:36:36 +01:00
|
|
|
DialogModule,
|
2022-11-02 17:57:25 +01:00
|
|
|
ButtonModule,
|
|
|
|
FormFieldModule,
|
|
|
|
AvatarModule,
|
|
|
|
BadgeModule,
|
|
|
|
ReactiveFormsModule,
|
|
|
|
FormsModule,
|
|
|
|
TabsModule,
|
|
|
|
TableModule,
|
|
|
|
PreloadedEnglishI18nModule,
|
|
|
|
JslibModule,
|
|
|
|
IconButtonModule,
|
|
|
|
],
|
|
|
|
providers: [],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
parameters: {},
|
|
|
|
argTypes: {
|
|
|
|
formObj: { table: { disable: true } },
|
|
|
|
},
|
|
|
|
} as Meta;
|
|
|
|
|
|
|
|
const actionsData = {
|
|
|
|
onValueChanged: action("onValueChanged"),
|
|
|
|
onSubmit: action("onSubmit"),
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Factory to help build semi-realistic looking items
|
|
|
|
* @param n - The number of items to build
|
|
|
|
* @param type - Which type to build
|
|
|
|
*/
|
|
|
|
const itemsFactory = (n: number, type: AccessItemType) => {
|
|
|
|
return [...Array(n)].map((_: unknown, id: number) => {
|
|
|
|
const item: AccessItemView = {
|
|
|
|
id: id.toString(),
|
|
|
|
type: type,
|
|
|
|
} as AccessItemView;
|
|
|
|
|
|
|
|
switch (item.type) {
|
|
|
|
case AccessItemType.Collection:
|
|
|
|
item.labelName = item.listName = `Collection ${id}`;
|
|
|
|
item.id = item.id + "c";
|
|
|
|
item.parentGrouping = "Collection Parent Group " + ((id % 2) + 1);
|
|
|
|
break;
|
|
|
|
case AccessItemType.Group:
|
|
|
|
item.labelName = item.listName = `Group ${id}`;
|
|
|
|
item.id = item.id + "g";
|
|
|
|
break;
|
|
|
|
case AccessItemType.Member:
|
|
|
|
item.id = item.id + "m";
|
|
|
|
item.email = `member${id}@email.com`;
|
|
|
|
item.status = id % 3 == 0 ? 0 : 2;
|
|
|
|
item.labelName = item.status == 2 ? `Member ${id}` : item.email;
|
|
|
|
item.listName = item.status == 2 ? `${item.labelName} (${item.email})` : item.email;
|
|
|
|
item.role = id % 5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const sampleMembers = itemsFactory(10, AccessItemType.Member);
|
|
|
|
const sampleGroups = itemsFactory(6, AccessItemType.Group);
|
|
|
|
|
|
|
|
const StandaloneAccessSelectorTemplate: Story<AccessSelectorComponent> = (
|
|
|
|
args: AccessSelectorComponent
|
|
|
|
) => ({
|
|
|
|
props: {
|
|
|
|
items: [],
|
|
|
|
valueChanged: actionsData.onValueChanged,
|
|
|
|
initialValue: [],
|
|
|
|
...args,
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<bit-access-selector
|
|
|
|
(ngModelChange)="valueChanged($event)"
|
|
|
|
[ngModel]="initialValue"
|
|
|
|
[items]="items"
|
|
|
|
[disabled]="disabled"
|
|
|
|
[columnHeader]="columnHeader"
|
|
|
|
[showGroupColumn]="showGroupColumn"
|
|
|
|
[selectorLabelText]="selectorLabelText"
|
|
|
|
[selectorHelpText]="selectorHelpText"
|
|
|
|
[emptySelectionText]="emptySelectionText"
|
|
|
|
[permissionMode]="permissionMode"
|
|
|
|
[showMemberRoles]="showMemberRoles"
|
|
|
|
></bit-access-selector>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2022-12-21 14:36:36 +01:00
|
|
|
const DialogAccessSelectorTemplate: Story<AccessSelectorComponent> = (
|
|
|
|
args: AccessSelectorComponent
|
|
|
|
) => ({
|
|
|
|
props: {
|
|
|
|
items: [],
|
|
|
|
valueChanged: actionsData.onValueChanged,
|
|
|
|
initialValue: [],
|
|
|
|
...args,
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<bit-dialog [dialogSize]="dialogSize" [disablePadding]="disablePadding">
|
|
|
|
<span bitDialogTitle>Access selector</span>
|
|
|
|
<span bitDialogContent>
|
|
|
|
<bit-access-selector
|
|
|
|
(ngModelChange)="valueChanged($event)"
|
|
|
|
[ngModel]="initialValue"
|
|
|
|
[items]="items"
|
|
|
|
[disabled]="disabled"
|
|
|
|
[columnHeader]="columnHeader"
|
|
|
|
[showGroupColumn]="showGroupColumn"
|
|
|
|
[selectorLabelText]="selectorLabelText"
|
|
|
|
[selectorHelpText]="selectorHelpText"
|
|
|
|
[emptySelectionText]="emptySelectionText"
|
|
|
|
[permissionMode]="permissionMode"
|
|
|
|
[showMemberRoles]="showMemberRoles"
|
|
|
|
></bit-access-selector>
|
|
|
|
</span>
|
|
|
|
<div bitDialogFooter class="tw-flex tw-items-center tw-flex-row tw-gap-2">
|
|
|
|
<button bitButton buttonType="primary">Save</button>
|
|
|
|
<button bitButton buttonType="secondary">Cancel</button>
|
|
|
|
<button
|
|
|
|
class="tw-ml-auto"
|
|
|
|
bitIconButton="bwi-trash"
|
|
|
|
buttonType="danger"
|
|
|
|
size="default"
|
|
|
|
title="Delete"
|
|
|
|
aria-label="Delete"></button>
|
|
|
|
</div>
|
|
|
|
</bit-dialog>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
const dialogAccessItems = itemsFactory(10, AccessItemType.Collection);
|
|
|
|
|
2022-11-02 17:57:25 +01:00
|
|
|
const memberCollectionAccessItems = itemsFactory(3, AccessItemType.Collection).concat([
|
|
|
|
{
|
|
|
|
id: "c1-group1",
|
|
|
|
type: AccessItemType.Collection,
|
|
|
|
labelName: "Collection 1",
|
|
|
|
listName: "Collection 1",
|
|
|
|
viaGroupName: "Group 1",
|
|
|
|
readonlyPermission: CollectionPermission.View,
|
|
|
|
readonly: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "c1-group2",
|
|
|
|
type: AccessItemType.Collection,
|
|
|
|
labelName: "Collection 1",
|
|
|
|
listName: "Collection 1",
|
|
|
|
viaGroupName: "Group 2",
|
|
|
|
readonlyPermission: CollectionPermission.ViewExceptPass,
|
|
|
|
readonly: true,
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
2022-12-21 14:36:36 +01:00
|
|
|
export const Dialog = DialogAccessSelectorTemplate.bind({});
|
|
|
|
Dialog.args = {
|
|
|
|
permissionMode: "edit",
|
|
|
|
showMemberRoles: false,
|
|
|
|
showGroupColumn: true,
|
|
|
|
columnHeader: "Collection",
|
|
|
|
selectorLabelText: "Select Collections",
|
|
|
|
selectorHelpText: "Some helper text describing what this does",
|
|
|
|
emptySelectionText: "No collections added",
|
|
|
|
disabled: false,
|
|
|
|
initialValue: [],
|
|
|
|
items: dialogAccessItems,
|
|
|
|
};
|
|
|
|
Dialog.story = {
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
storyDescription: `
|
|
|
|
Example of an access selector for modifying the collections a member has access to inside of a dialog.
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-11-02 17:57:25 +01:00
|
|
|
export const MemberCollectionAccess = StandaloneAccessSelectorTemplate.bind({});
|
|
|
|
MemberCollectionAccess.args = {
|
|
|
|
permissionMode: "edit",
|
|
|
|
showMemberRoles: false,
|
|
|
|
showGroupColumn: true,
|
|
|
|
columnHeader: "Collection",
|
|
|
|
selectorLabelText: "Select Collections",
|
|
|
|
selectorHelpText: "Some helper text describing what this does",
|
|
|
|
emptySelectionText: "No collections added",
|
|
|
|
disabled: false,
|
|
|
|
initialValue: [],
|
|
|
|
items: memberCollectionAccessItems,
|
|
|
|
};
|
|
|
|
MemberCollectionAccess.story = {
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
storyDescription: `
|
|
|
|
Example of an access selector for modifying the collections a member has access to.
|
|
|
|
Includes examples of a readonly group and member that cannot be edited.
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const MemberGroupAccess = StandaloneAccessSelectorTemplate.bind({});
|
|
|
|
MemberGroupAccess.args = {
|
|
|
|
permissionMode: "readonly",
|
|
|
|
showMemberRoles: false,
|
|
|
|
columnHeader: "Groups",
|
|
|
|
selectorLabelText: "Select Groups",
|
|
|
|
selectorHelpText: "Some helper text describing what this does",
|
|
|
|
emptySelectionText: "No groups added",
|
|
|
|
disabled: false,
|
|
|
|
initialValue: [{ id: "3g" }, { id: "0g" }],
|
|
|
|
items: itemsFactory(4, AccessItemType.Group).concat([
|
|
|
|
{
|
|
|
|
id: "admin",
|
|
|
|
type: AccessItemType.Group,
|
|
|
|
listName: "Admin Group",
|
|
|
|
labelName: "Admin Group",
|
|
|
|
accessAllItems: true,
|
|
|
|
},
|
|
|
|
]),
|
|
|
|
};
|
|
|
|
MemberGroupAccess.story = {
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
storyDescription: `
|
|
|
|
Example of an access selector for selecting which groups an individual member belongs too.
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const GroupMembersAccess = StandaloneAccessSelectorTemplate.bind({});
|
|
|
|
GroupMembersAccess.args = {
|
|
|
|
permissionMode: "hidden",
|
|
|
|
showMemberRoles: true,
|
|
|
|
columnHeader: "Members",
|
|
|
|
selectorLabelText: "Select Members",
|
|
|
|
selectorHelpText: "Some helper text describing what this does",
|
|
|
|
emptySelectionText: "No members added",
|
|
|
|
disabled: false,
|
|
|
|
initialValue: [{ id: "2m" }, { id: "0m" }],
|
|
|
|
items: sampleMembers,
|
|
|
|
};
|
|
|
|
GroupMembersAccess.story = {
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
storyDescription: `
|
|
|
|
Example of an access selector for selecting which members belong to an specific group.
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const CollectionAccess = StandaloneAccessSelectorTemplate.bind({});
|
|
|
|
CollectionAccess.args = {
|
|
|
|
permissionMode: "edit",
|
|
|
|
showMemberRoles: false,
|
|
|
|
columnHeader: "Groups/Members",
|
|
|
|
selectorLabelText: "Select groups and members",
|
|
|
|
selectorHelpText:
|
|
|
|
"Permissions set for a member will replace permissions set by that member's group",
|
|
|
|
emptySelectionText: "No members or groups added",
|
|
|
|
disabled: false,
|
|
|
|
initialValue: [
|
|
|
|
{ id: "3g", permission: CollectionPermission.EditExceptPass },
|
|
|
|
{ id: "0m", permission: CollectionPermission.View },
|
|
|
|
],
|
|
|
|
items: sampleGroups.concat(sampleMembers).concat([
|
|
|
|
{
|
|
|
|
id: "admin-group",
|
|
|
|
type: AccessItemType.Group,
|
|
|
|
listName: "Admin Group",
|
|
|
|
labelName: "Admin Group",
|
|
|
|
accessAllItems: true,
|
|
|
|
readonly: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "admin-member",
|
|
|
|
type: AccessItemType.Member,
|
|
|
|
listName: "Admin Member (admin@email.com)",
|
|
|
|
labelName: "Admin Member",
|
|
|
|
status: OrganizationUserStatusType.Confirmed,
|
|
|
|
role: OrganizationUserType.Admin,
|
|
|
|
email: "admin@email.com",
|
|
|
|
accessAllItems: true,
|
|
|
|
readonly: true,
|
|
|
|
},
|
|
|
|
]),
|
|
|
|
};
|
|
|
|
GroupMembersAccess.story = {
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
storyDescription: `
|
|
|
|
Example of an access selector for selecting which members/groups have access to a specific collection.
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const fb = new FormBuilder();
|
|
|
|
|
|
|
|
const ReactiveFormAccessSelectorTemplate: Story<AccessSelectorComponent> = (
|
|
|
|
args: AccessSelectorComponent
|
|
|
|
) => ({
|
|
|
|
props: {
|
|
|
|
items: [],
|
|
|
|
onSubmit: actionsData.onSubmit,
|
|
|
|
...args,
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<form [formGroup]="formObj" (ngSubmit)="onSubmit(formObj.controls.formItems.value)">
|
|
|
|
<bit-access-selector
|
|
|
|
formControlName="formItems"
|
|
|
|
[items]="items"
|
|
|
|
[columnHeader]="columnHeader"
|
|
|
|
[selectorLabelText]="selectorLabelText"
|
|
|
|
[selectorHelpText]="selectorHelpText"
|
|
|
|
[emptySelectionText]="emptySelectionText"
|
|
|
|
[permissionMode]="permissionMode"
|
|
|
|
[showMemberRoles]="showMemberRoles"
|
|
|
|
></bit-access-selector>
|
|
|
|
<button type="submit" bitButton buttonType="primary" class="tw-mt-5">Submit</button>
|
|
|
|
</form>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const ReactiveForm = ReactiveFormAccessSelectorTemplate.bind({});
|
|
|
|
ReactiveForm.args = {
|
|
|
|
formObj: fb.group({ formItems: [[{ id: "1g" }]] }),
|
|
|
|
permissionMode: "edit",
|
|
|
|
showMemberRoles: false,
|
|
|
|
columnHeader: "Groups/Members",
|
|
|
|
selectorLabelText: "Select groups and members",
|
|
|
|
selectorHelpText:
|
|
|
|
"Permissions set for a member will replace permissions set by that member's group",
|
|
|
|
emptySelectionText: "No members or groups added",
|
|
|
|
items: sampleGroups.concat(sampleMembers),
|
|
|
|
};
|