Skip to content

Commit

Permalink
[EC-73] chore: move component to shared org module
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Oct 19, 2022
1 parent f4da901 commit 5df22df
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@
</select>
</bit-form-field>
</bit-tab>
<bit-tab label="{{ 'access' | i18n }}">Not implemented</bit-tab>
<bit-tab label="{{ 'access' | i18n }}">
<bit-access-selector
permissionMode="edit"
[columnHeader]="'groupsAndMembersColumnHeader' | i18n"
[selectorLabelText]="'selectGroupsAndMembers' | i18n"
[selectorHelpText]="'userPermissionOverrideHelper' | i18n"
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
></bit-access-selector>
</bit-tab>
</bit-tab-group>
</div>
<div bitDialogFooter class="tw-flex tw-flex-row tw-gap-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ export interface CollectionEditDialogParams {
organizationId: string;
}

export enum CollectionEditDialogResultType {
export enum CollectionDialogResultType {
Saved = "saved",
Canceled = "canceled",
Deleted = "deleted",
}

export interface CollectionEditDialogResult {
type: CollectionEditDialogResultType;
export interface CollectionDialogResult {
type: CollectionDialogResultType;
}

@Component({
selector: "app-collection-dialog",
templateUrl: "collection-dialog.component.html",
})
export class CollectionEditDialogComponent implements OnInit, OnDestroy {
export class CollectionDialogComponent implements OnInit, OnDestroy {
private destroy$ = new Subject<void>();

collection?: CollectionView;
Expand Down Expand Up @@ -85,7 +85,7 @@ export class CollectionEditDialogComponent implements OnInit, OnDestroy {
}

async cancel() {
this.close({ type: CollectionEditDialogResultType.Canceled });
this.close({ type: CollectionDialogResultType.Canceled });
}

async submit() {
Expand All @@ -107,7 +107,7 @@ export class CollectionEditDialogComponent implements OnInit, OnDestroy {

await this.collectionService.save(collectionView);

this.close({ type: CollectionEditDialogResultType.Saved });
this.close({ type: CollectionDialogResultType.Saved });
}

async remove() {
Expand All @@ -125,15 +125,15 @@ export class CollectionEditDialogComponent implements OnInit, OnDestroy {

await this.collectionService.remove(this.params.organizationId, this.params.collectionId);

this.close({ type: CollectionEditDialogResultType.Deleted });
this.close({ type: CollectionDialogResultType.Deleted });
}

ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}

private close(result: CollectionEditDialogResult) {
private close(result: CollectionDialogResult) {
this.dialogRef.close(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NgModule } from "@angular/core";

import { SharedModule } from "../../../shared";

import { CollectionDialogComponent } from "./collection-dialog.component";

@NgModule({
imports: [SharedModule],
declarations: [CollectionDialogComponent],
exports: [CollectionDialogComponent],
})
export class CollectionDialogModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {
import { PreloadedEnglishI18nModule } from "../../../tests/preloaded-english-i18n.module";

import {
CollectionEditDialogComponent,
CollectionDialogComponent,
CollectionEditDialogParams,
} from "./collection-dialog.components";
} from "./collection-dialog.component";

interface ProviderData {
collectionId: string;
Expand All @@ -32,7 +32,7 @@ interface ProviderData {

export default {
title: "Web/Collections/Edit dialog",
component: CollectionEditDialogComponent,
component: CollectionDialogComponent,
decorators: [
moduleMetadata({
imports: [
Expand All @@ -55,8 +55,8 @@ collections = collections.concat(
collections.map((c, i) => createCollection(`${c.name}/Sub-collection ${i}`))
);

const NewCollectionTemplate: Story<CollectionEditDialogComponent> = (
args: CollectionEditDialogComponent
const NewCollectionTemplate: Story<CollectionDialogComponent> = (
args: CollectionDialogComponent
) => ({
moduleMetadata: {
providers: providers({ collectionId: undefined, organizationId, collections }),
Expand All @@ -66,8 +66,8 @@ const NewCollectionTemplate: Story<CollectionEditDialogComponent> = (

export const NewCollection = NewCollectionTemplate.bind({});

const ExistingCollectionTemplate: Story<CollectionEditDialogComponent> = (
args: CollectionEditDialogComponent
const ExistingCollectionTemplate: Story<CollectionDialogComponent> = (
args: CollectionDialogComponent
) => ({
moduleMetadata: {
providers: providers({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./collection-dialog.component";
export * from "./collection-dialog.module";
19 changes: 10 additions & 9 deletions apps/web/src/app/organizations/manage/collections.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import { ListResponse } from "@bitwarden/common/models/response/listResponse";
import { CollectionView } from "@bitwarden/common/models/view/collectionView";
import { DialogService } from "@bitwarden/components";

import { CollectionAddEditComponent } from "./collection-add-edit.component";
import {
CollectionEditDialogComponent,
CollectionEditDialogResult,
CollectionEditDialogResultType,
} from "./collection-dialog/collection-dialog.components";
CollectionDialogComponent,
CollectionDialogResult,
CollectionDialogResultType,
} from "../components/collection-dialog";

import { CollectionAddEditComponent } from "./collection-add-edit.component";
import { EntityUsersComponent } from "./entity-users.component";

@Component({
Expand Down Expand Up @@ -134,14 +135,14 @@ export class CollectionsComponent implements OnInit {
return;
}

const dialog = this.dialogService.open(CollectionEditDialogComponent, {
const dialog = this.dialogService.open(CollectionDialogComponent, {
data: { collectionId: collection?.id, organizationId: this.organizationId },
});

const result = (await lastValueFrom(dialog.closed)) as CollectionEditDialogResult | undefined;
const result = (await lastValueFrom(dialog.closed)) as CollectionDialogResult | undefined;
if (
result?.type === CollectionEditDialogResultType.Saved ||
result?.type === CollectionEditDialogResultType.Deleted
result?.type === CollectionDialogResultType.Saved ||
result?.type === CollectionDialogResultType.Deleted
) {
this.load();
}
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/app/organizations/organization.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { NgModule } from "@angular/core";
import { SharedModule } from "../shared";

import { AccessSelectorModule } from "./components/access-selector";
import { CollectionDialogModule } from "./components/collection-dialog";
import { OrganizationsRoutingModule } from "./organization-routing.module";

@NgModule({
imports: [SharedModule, AccessSelectorModule, OrganizationsRoutingModule],
imports: [SharedModule, AccessSelectorModule, CollectionDialogModule, OrganizationsRoutingModule],
})
export class OrganizationModule {}
2 changes: 0 additions & 2 deletions apps/web/src/app/shared/loose-components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { BulkRemoveComponent as OrgBulkRemoveComponent } from "../organizations/
import { BulkRestoreRevokeComponent as OrgBulkRestoreRevokeComponent } from "../organizations/manage/bulk/bulk-restore-revoke.component";
import { BulkStatusComponent as OrgBulkStatusComponent } from "../organizations/manage/bulk/bulk-status.component";
import { CollectionAddEditComponent as OrgCollectionAddEditComponent } from "../organizations/manage/collection-add-edit.component";
import { CollectionEditDialogComponent as OrgCollectionEditDialogComponent } from "../organizations/manage/collection-dialog/collection-dialog.components";
import { CollectionsComponent as OrgManageCollectionsComponent } from "../organizations/manage/collections.component";
import { EntityEventsComponent as OrgEntityEventsComponent } from "../organizations/manage/entity-events.component";
import { EventsComponent as OrgEventsComponent } from "../organizations/manage/events.component";
Expand Down Expand Up @@ -187,7 +186,6 @@ import { SharedModule } from ".";
OrgBulkRestoreRevokeComponent,
OrgBulkRemoveComponent,
OrgBulkStatusComponent,
OrgCollectionEditDialogComponent,
OrgCollectionAddEditComponent,
OrgCollectionsComponent,
OrgEntityEventsComponent,
Expand Down

0 comments on commit 5df22df

Please sign in to comment.