Skip to content

Commit

Permalink
filter items
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Jan 14, 2025
1 parent ec1ef9d commit 96098ac
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/models/addon-operation-invocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export enum InvocationStatus {
export enum ItemType {
Folder = 'FOLDER',
File = 'FILE',
Collection = 'COLLECTION',
Document = 'DOCUMENT',
}

export type OperationResult = ListItemsResult | Item;
Expand Down
2 changes: 0 additions & 2 deletions app/models/authorized-citation-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export default class AuthorizedCitationAccountModel extends AuthorizedAccountMod
ConnectedCitationOperationNames.ListRootCollections;
// rename 'itemId' key to 'collectionId'
delete Object.assign(operationKwargs, { ['collectionId']: operationKwargs['itemId'] })['itemId'];
// gravyvalet doesn't like 'itemType' as a parameter
delete operationKwargs.itemType;
const newInvocation = this.store.createRecord('addon-operation-invocation', {
operationName,
operationKwargs,
Expand Down
2 changes: 0 additions & 2 deletions app/models/configured-citation-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export default class ConfiguredCitationAddonModel extends ConfiguredAddonModel {
ConnectedCitationOperationNames.ListRootCollections;
// rename 'itemId' key to 'collectionId'
delete Object.assign(operationKwargs, { ['collectionId']: operationKwargs['itemId'] })['itemId'];
// gravyvalet doesn't like 'itemType' as a parameter
delete operationKwargs.itemType;
const newInvocation = this.store.createRecord('addon-operation-invocation', {
operationName,
operationKwargs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import { TaskInstance } from 'ember-concurrency';

import { Item, ItemType } from 'ember-osf-web/models/addon-operation-invocation';
import AuthorizedAccountModel from 'ember-osf-web/models/authorized-account';
import AuthorizedCitationAccountModel from 'ember-osf-web/models/authorized-citation-account';
import AuthorizedComputingAccountModel from 'ember-osf-web/models/authorized-computing-account';
import AuthorizedStorageAccountModel from 'ember-osf-web/models/authorized-storage-account';
import ConfiguredAddonModel from 'ember-osf-web/models/configured-addon';
import ConfiguredCitationAddonModel from 'ember-osf-web/models/configured-citation-addon';
import ConfiguredComputingAddonModel from 'ember-osf-web/models/configured-computing-addon';
import ConfiguredStorageAddonModel from 'ember-osf-web/models/configured-storage-addon';


interface Args {
Expand All @@ -21,9 +25,27 @@ export default class ConfiguredAddonEdit extends Component<Args> {
@tracked selectedFolder = this.args.configuredAddon?.rootFolder;
@tracked currentItems: Item[] = [];

defaultKwargs = {
itemType: ItemType.Folder,
};
defaultKwargs: any = {};

constructor(owner: unknown, args: Args) {
super(owner, args);
if (this.args.configuredAddon) {
if (this.args.configuredAddon instanceof ConfiguredStorageAddonModel) {
this.defaultKwargs['itemType'] = ItemType.Folder;
}
if (this.args.configuredAddon instanceof ConfiguredCitationAddonModel) {
this.defaultKwargs['filterItems'] = ItemType.Collection;
}
}
if (this.args.authorizedAccount) {
if (this.args.authorizedAccount instanceof AuthorizedStorageAccountModel) {
this.defaultKwargs['itemType'] = ItemType.Folder;
}
if (this.args.authorizedAccount instanceof AuthorizedCitationAccountModel) {
this.defaultKwargs['filterItems'] = ItemType.Collection;
}
}
}

get hasRootFolder() {
return !(
Expand Down

0 comments on commit 96098ac

Please sign in to comment.