Skip to content

Commit

Permalink
Merge pull request #496 from stakwork/feat/change_org_apis
Browse files Browse the repository at this point in the history
Renamed all organizations APIs to workspaces
  • Loading branch information
elraphty authored Apr 15, 2024
2 parents 4919a5d + adfc39a commit 98bac39
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
28 changes: 14 additions & 14 deletions src/store/__test__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Main store', () => {

sinon.assert.calledWith(
fetchStub,
`${TribesURL}/organizations`,
`${TribesURL}/workspaces`,
sinon.match({
method: 'POST',
headers: expectedHeaders,
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('Main store', () => {

sinon.assert.calledWith(
fetchStub,
`${TribesURL}/organizations`,
`${TribesURL}/workspaces`,
sinon.match({
method: 'POST',
headers: expectedHeaders,
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('Main store', () => {

sinon.assert.calledWith(
fetchStub,
`${TribesURL}/organizations`,
`${TribesURL}/workspaces`,
sinon.match({
method: 'POST',
headers: expectedHeaders,
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('Main store', () => {

sinon.assert.calledWith(
fetchStub,
`${TribesURL}/organizations`,
`${TribesURL}/workspaces`,
sinon.match({
method: 'POST',
headers: expectedHeaders,
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('Main store', () => {

sinon.assert.calledWith(
fetchStub,
`${TribesURL}/organizations/users/${mockApiResponseData[2]}`,
`${TribesURL}/workspaces/users/${mockApiResponseData[2]}`,
sinon.match({
method: 'POST',
headers: expectedHeaders,
Expand All @@ -282,7 +282,7 @@ describe('Main store', () => {

fetchStub.resolves(Promise.resolve(mockApiResponse));

const endpoint = `${TribesURL}/organizations/users/${mockApiResponseData[2].orgUUID}`;
const endpoint = `${TribesURL}/workspaces/users/${mockApiResponseData[2].orgUUID}`;

const users = await mainStore.getWorkspaceUsers(mockApiResponseData[2].orgUUID);

Expand Down Expand Up @@ -376,7 +376,7 @@ describe('Main store', () => {

sinon.assert.calledWithMatch(
fetchStub,
`${TribesURL}/organizations/user/${userId}`,
`${TribesURL}/workspaces/user/${userId}`,
sinon.match({
method: 'GET',
mode: 'cors',
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('Main store', () => {

sinon.assert.calledWithMatch(
fetchStub,
`${TribesURL}/organizations/${uuid}`,
`${TribesURL}/workspaces/${uuid}`,
sinon.match({
method: 'GET',
mode: 'cors',
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('Main store', () => {

sinon.assert.calledWithMatch(
fetchStub,
`${TribesURL}/organizations/foruser/${mockApiResponseData[0].uuid}`,
`${TribesURL}/workspaces/foruser/${mockApiResponseData[0].uuid}`,
sinon.match({
method: 'GET',
mode: 'cors',
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('Main store', () => {

sinon.assert.calledWithMatch(
fetchStub,
`${TribesURL}/organizations/users/${mockApiResponseData[2].orgUUID}/count`,
`${TribesURL}/workspaces/users/${mockApiResponseData[2].orgUUID}/count`,
sinon.match({
method: 'GET',
mode: 'cors'
Expand Down Expand Up @@ -529,7 +529,7 @@ describe('Main store', () => {

sinon.assert.calledWithMatch(
fetchStub,
`${TribesURL}/organizations/users/${orgUserUUID}`,
`${TribesURL}/workspaces/users/${orgUserUUID}`,
sinon.match({
method: 'DELETE',
mode: 'cors',
Expand Down Expand Up @@ -901,7 +901,7 @@ describe('Main store', () => {

it('should fetch and store workspace bounties successfully, user signed out', async () => {
uiStore.setMeInfo(emptyMeInfo);
const allBountiesUrl = `http://${getHost()}/organizations/bounties/1111`;
const allBountiesUrl = `http://${getHost()}/workspaces/bounties/1111`;
fetchStub.withArgs(allBountiesUrl, sinon.match.any).returns(
Promise.resolve({
status: 200,
Expand All @@ -926,7 +926,7 @@ describe('Main store', () => {

it('should reset exisiting workspace bounty if reset flag is passed, user signed out', async () => {
uiStore.setMeInfo(emptyMeInfo);
const allBountiesUrl = `http://${getHost()}/organizations/bounties/1111`;
const allBountiesUrl = `http://${getHost()}/workspaces/bounties/1111`;
const mockBounty = { ...mockBounties[0] };
mockBounty.bounty.id = 2;
fetchStub.withArgs(allBountiesUrl, sinon.match.any).returns(
Expand Down Expand Up @@ -957,7 +957,7 @@ describe('Main store', () => {

it('should add to exisiting bounty if reset flag is not passed, user signed out', async () => {
uiStore.setMeInfo(emptyMeInfo);
const allBountiesUrl = `http://${getHost()}/organizations/bounties/1111`;
const allBountiesUrl = `http://${getHost()}/workspaces/bounties/1111`;
const mockBounty = { ...mockBounties[0] };
mockBounty.bounty.id = 2;
fetchStub.withArgs(allBountiesUrl, sinon.match.any).returns(
Expand Down
44 changes: 22 additions & 22 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ export class MainStore {

// if we don't pass the params, we should use previous params for invalidate query
const query2 = this.appendQueryParams(
`organizations/bounties/${uuid}`,
`workspaces/bounties/${uuid}`,
queryLimit,
params ? queryParams : this.getWantedsWorkspacePrevParams
);
Expand Down Expand Up @@ -1200,7 +1200,7 @@ export class MainStore {
async getWorkspaceBounties(uuid: string, queryParams?: any): Promise<PersonBounty[]> {
queryParams = { ...queryParams, search: uiStore.searchText };
try {
const ps2 = await api.get(`organizations/bounties/${uuid}`);
const ps2 = await api.get(`workspaces/bounties/${uuid}`);
const ps3: any[] = [];

if (ps2 && ps2.length) {
Expand Down Expand Up @@ -1267,7 +1267,7 @@ export class MainStore {

// if we don't pass the params, we should use previous params for invalidate query
const query2 = this.appendQueryParams(
`organizations/bounties/${uuid}`,
`workspaces/bounties/${uuid}`,
orgQuerLimit,
params ? queryParams : this.getWantedsWorkspacePrevParams
);
Expand Down Expand Up @@ -2208,7 +2208,7 @@ export class MainStore {
const info = uiStore;
if (!info.selectedPerson && !uiStore.meInfo?.id) return [];

const r: any = await fetch(`${TribesURL}/organizations/user/${id}`, {
const r: any = await fetch(`${TribesURL}/workspaces/user/${id}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2230,7 +2230,7 @@ export class MainStore {
const info = uiStore;
if (!info.selectedPerson && !uiStore.meInfo?.id) return [];

const r: any = await fetch(`${TribesURL}/organizations/user/dropdown/${id}`, {
const r: any = await fetch(`${TribesURL}/workspaces/user/dropdown/${id}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2249,7 +2249,7 @@ export class MainStore {

async getUserWorkspaceByUuid(uuid: string): Promise<Workspace | undefined> {
try {
const r: any = await fetch(`${TribesURL}/organizations/${uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/${uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2269,7 +2269,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations`, {
const r: any = await fetch(`${TribesURL}/workspaces`, {
method: 'POST',
mode: 'cors',
body: JSON.stringify({
Expand Down Expand Up @@ -2307,7 +2307,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations`, {
const r: any = await fetch(`${TribesURL}/workspaces`, {
method: 'POST',

mode: 'cors',
Expand All @@ -2329,7 +2329,7 @@ export class MainStore {

async getWorkspaceUsersCount(uuid: string): Promise<number> {
try {
const r: any = await fetch(`${TribesURL}/organizations/users/${uuid}/count`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/${uuid}/count`, {
method: 'GET',
mode: 'cors'
});
Expand All @@ -2343,7 +2343,7 @@ export class MainStore {

async getWorkspaceUsers(uuid: string): Promise<Person[]> {
try {
const r: any = await fetch(`${TribesURL}/organizations/users/${uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/${uuid}`, {
method: 'GET',
mode: 'cors'
});
Expand All @@ -2359,7 +2359,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return undefined;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/foruser/${uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/foruser/${uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2380,7 +2380,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/users/${body.org_uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/${body.org_uuid}`, {
method: 'POST',
mode: 'cors',
body: JSON.stringify({
Expand All @@ -2403,7 +2403,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/users/${uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/${uuid}`, {
method: 'DELETE',
mode: 'cors',
body: JSON.stringify({
Expand Down Expand Up @@ -2433,7 +2433,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return [];
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/bounty/roles`, {
const r: any = await fetch(`${TribesURL}/workspaces/bounty/roles`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2456,7 +2456,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return [];
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/users/role/${uuid}/${user}`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/role/${uuid}/${user}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2476,7 +2476,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/users/role/${uuid}/${user}`, {
const r: any = await fetch(`${TribesURL}/workspaces/users/role/${uuid}/${user}`, {
method: 'POST',
mode: 'cors',
body: JSON.stringify(body),
Expand Down Expand Up @@ -2537,7 +2537,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return null;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/budget/${uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/budget/${uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand Down Expand Up @@ -2579,7 +2579,7 @@ export class MainStore {
if (!uiStore.meInfo) return [];
const info = uiStore.meInfo;
const r: any = await fetch(
`${TribesURL}/organizations/payments/${uuid}?page=${page}&limit=${limit}`,
`${TribesURL}/workspaces/payments/${uuid}?page=${page}&limit=${limit}`,
{
method: 'GET',
mode: 'cors',
Expand All @@ -2602,7 +2602,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return [];
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/budget/history/${uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/budget/history/${uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand Down Expand Up @@ -2713,7 +2713,7 @@ export class MainStore {
if (!uiStore.meInfo) return undefined;
const info = uiStore.meInfo;

const r: any = await fetch(`${TribesURL}/organizations/poll/invoices/${org_uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/poll/invoices/${org_uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2731,7 +2731,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return 0;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/invoices/count/${org_uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/invoices/count/${org_uuid}`, {
method: 'GET',
mode: 'cors',
headers: {
Expand All @@ -2750,7 +2750,7 @@ export class MainStore {
try {
if (!uiStore.meInfo) return 0;
const info = uiStore.meInfo;
const r: any = await fetch(`${TribesURL}/organizations/delete/${org_uuid}`, {
const r: any = await fetch(`${TribesURL}/workspaces/delete/${org_uuid}`, {
method: 'DELETE',
mode: 'cors',
headers: {
Expand Down

0 comments on commit 98bac39

Please sign in to comment.