Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Add "keyshade workspace list-invitations" command #554

Open
Tracked by #549
rajdip-b opened this issue Nov 22, 2024 · 8 comments
Open
Tracked by #549

CLI: Add "keyshade workspace list-invitations" command #554

rajdip-b opened this issue Nov 22, 2024 · 8 comments
Assignees
Labels
difficulty: 3 good first issue Good for newcomers pending-dependency Stuck due to a required dependency priority: urgent type: feature Release drafter tag for tagging PRs related to adding new features

Comments

@rajdip-b
Copy link
Member

Description

Add a command to fetch all the workspace invitations of a user.

Solution

  • Add a command named list-invitations in here
  • Add the command implementation in a file named list-invitations.workspace.ts and store it in here

Additional context

Depends on:

@rajdip-b rajdip-b added good first issue Good for newcomers type: feature Release drafter tag for tagging PRs related to adding new features priority: urgent difficulty: 3 labels Nov 22, 2024
@rajdip-b rajdip-b added the pending-dependency Stuck due to a required dependency label Nov 22, 2024
@Souvik9205
Copy link
Contributor

/attempt

Copy link

github-actions bot commented Dec 8, 2024

Assigned the issue to @Souvik9205!

@kriptonian1
Copy link
Contributor

@Souvik9205 how is the progress going

@Souvik9205
Copy link
Contributor

@kriptonian1 I am facing some weird issues running it on my device, please assign it to another as it is urgent..,sorry for that

@muntaxir4
Copy link
Contributor

@kriptonian1 I am facing some weird issues running it on my device, please assign it to another as it is urgent..,sorry for that

Can you share the issue you are facing?

@rajdip-b
Copy link
Member Author

@Souvik9205 hey man, sorry to hear that. If you can share the issue you are facing, we would be able to help you out. Optionally, we might also create a github discussion so that anyone else can look up the thread in case they are facing the same issue!

@Souvik9205
Copy link
Contributor

@rajdip-b hello, I guess it was my device's issue. While I tried to perform some commands like maybe cloning the repo, it was deleting all of the files. And I couldn’t resolve the problem, that's why I asked if it's urgent you can assign it to other ... The error was something like-

$ git clone https://github.com/Souvik9205/keyshade.git
Cloning into 'keyshade'...
remote: Enumerating objects: 8080, done.
remote: Counting objects: 100% (1186/1186), done.
remote: Compressing objects: 100% (465/465), done.
remote: Total 8080 (delta 925), reused 722 (delta 721), pack-reused 6894 (from 2)
Receiving objects: 100% (8080/8080), 16.32 MiB | 2.90 MiB/s, done.
Resolving deltas: 100% (4739/4739), done.
error: invalid path 't updateSelf = useCallback(async () => {'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

However, after your response, I tried again with my new OS setup, and it worked perfectly....

@Souvik9205
Copy link
Contributor

I done with the issue, but as you know , issue #553 is not merged yet, I don't have access to the API controller to use, i created a sample export class like-

import { APIClient } from '@api-client/core/client'
export default class WorkspaceInvitationController {
  private apiClient: APIClient

  constructor(private readonly backendUrl: string) {
    this.apiClient = new APIClient(this.backendUrl)
  }

  async getWorkspaceInvitations(request: any): Promise<any> {
    return null
  }
}

And used it on controller-instance.ts but the issue is how the Invitations will be displayed?
here is what I currently did( inspired by list.workspace.ts )-

import BaseCommand from '@/commands/base.command'
import { Logger } from '@/util/logger'
import ControllerInstance from '@/util/controller-instance'
import {
  type CommandActionData,
  type CommandOption
} from '@/types/command/command.types'
import { PAGINATION_OPTION } from '@/util/pagination-options'

export default class ListInvitations extends BaseCommand {
  getName(): string {
    return 'list'
  }

  getDescription(): string {
    return 'Fetches all the invitations to workspaces'
  }

  getOptions(): CommandOption[] {
    return PAGINATION_OPTION
  }

  async action({ options }: CommandActionData): Promise<void> {
    Logger.info('Fetching all invitations...')

    const { success, data, error } =
      await ControllerInstance.getInstance().workspaceInvitationController.getWorkspaceInvitations(
        {
          ...options
        },
        this.headers
      )

    if (success) {
      const invitations = data.items
      if (invitations.length > 0) {
        data.items.forEach((invitation: any) => {
          Logger.info(`- ${invitation.name} (${invitation.slug})`)
        })
      } else {
        Logger.info('No invitations found')
      }
    } else {
      Logger.error(`Failed fetching invitations: ${error.message}`)
    }
  }
}

I will be waiting for your response before sending PR...thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 3 good first issue Good for newcomers pending-dependency Stuck due to a required dependency priority: urgent type: feature Release drafter tag for tagging PRs related to adding new features
Projects
None yet
Development

No branches or pull requests

4 participants