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

Auto populate Org name for post bounty modal #13

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ We truly ❤️ pull requests! If you wish to help, you can learn more about how

Join our community on [Forum/Chat](https://people.sphinx.chat) to connect with other users and get support.

Feel free to explore the potential of **sphinx-tribes** and contribute to its vibrant ecosystem! 🌟

Feel free to explore the potential of **sphinx-tribes** and contribute to its vibrant ecosystem! 🌟
126 changes: 126 additions & 0 deletions deploy/staging/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
version: "2"

services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.2.1
# Enables the web UI and tells Traefik to listen to docker
# command: --configFile=/home/ec2-user/sphinx-deploy/traefik.yaml
ports:
# The HTTP port
- 80:80
# The Web UI (enabled by --api.insecure=true)
- 8080:8080
# entrypoints
- 443:443
- 8883:8883
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- /home/ec2-user/sphinx-deploy/traefik.yaml:/etc/traefik/traefik.yaml
- /home/ec2-user/letsencrypt:/letsencrypt
environment:
- AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- AWS_REGION=$AWS_REGION
logging:
options:
max-size: 10m
ulimits:
nproc: 65535
nofile:
soft: 1000000
hard: 1000000

auth:
image: sphinx-auth
depends_on:
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.auth.rule=Host(`auth-test.sphinx.chat`)"
- "traefik.http.services.auth.loadbalancer.server.port=9090"
- "traefik.http.routers.auth.tls=true"
- "traefik.http.routers.auth.tls.certresolver=myresolver"
- "traefik.http.routers.auth.entrypoints=websecure"
restart: on-failure
environment:
- JWT_KEY=$JWT_KEY
- CLIENT_KEYS=$CLIENT_KEYS
- OAUTH_TIMEOUT=$OAUTH_TIMEOUT
- HOST=auth-test.sphinx.chat

tribes:
image: sphinx-tribes
depends_on:
- auth
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.tribes.rule=Host(`api.tribes-test.sphinx.chat`) || Host(`api.people-test.sphinx.chat`) || Host(`api.community-test.sphinx.chat`)"
- "traefik.http.services.tribes.loadbalancer.server.port=5002"
- "traefik.http.routers.tribes.tls=true"
- "traefik.http.routers.tribes.tls.certresolver=myresolver"
- "traefik.http.routers.tribes.entrypoints=websecure"
restart: on-failure
environment:
- DATABASE_URL=$DATABASE_URL
- PODCAST_INDEX_SECRET=$PODCAST_INDEX_SECRET
- PODCAST_INDEX_KEY=$PODCAST_INDEX_KEY
- YOUTUBE_KEY=$YOUTUBE_KEY
- GITHUB_TOKEN=$GITHUB_TOKEN
- LN_SERVER_BASE_URL=https://people-test.sphinx.chat
- LN_JWT_KEY=$LN_JWT_KEY
- RELAY_URL=$RELAY_URL
- RELAY_AUTH_KEY=$RELAY_AUTH_KEY
- RELAY_URL_BACKUP=$RELAY_URL_BACKUP
- RELAY_AUTH_KEY_BACKUP=$RELAY_AUTH_KEY_BACKUP
- HOST=people-test.sphinx.chat
- REDIS_URL=$REDIS_URL
- ADMIN_PUBKEYS=$ADMINS
- ADMINS=$ADMINS
- AWS_SECRET_ACCESS=$AWS_SECRET_ACCESS_KEY
- AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- AWS_REGION=us-east-1
- S3_BUCKET_NAME=sphinx-tribes
- S3_FOLDER_NAME=metrics
- S3_URL=https://sphinx-tribes.s3.amazonaws.com
ulimits:
nproc: 65535
nofile:
soft: 1000000
hard: 1000000

tribes-frontend:
image: sphinxlightning/sphinx-tribes-frontend:latest
depends_on:
- tribes
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.tribes-frontend.rule=Host(`tribes-test.sphinx.chat`) || Host(`people-test.sphinx.chat`) || Host(`community-test.sphinx.chat`)"
- "traefik.http.services.tribes-frontend.loadbalancer.server.port=80"
- "traefik.http.routers.tribes-frontend.tls=true"
- "traefik.http.routers.tribes-frontend.tls.certresolver=myresolver"
- "traefik.http.routers.tribes-frontend.entrypoints=websecure"
restart: on-failure

mqtt:
image: sphinx-mqtt
depends_on:
- auth
- reverse-proxy
labels:
- "traefik.enable=true"
- "traefik.tcp.routers.mqtt.rule=HostSNI(`tribes-test.sphinx.chat`)"
- "traefik.tcp.services.mqtt.loadbalancer.server.port=1883"
- "traefik.tcp.routers.mqtt.tls=true"
- "traefik.tcp.routers.mqtt.tls.certresolver=myresolver"
- "traefik.tcp.routers.mqtt.entrypoints=mqttsecure"
- "traefik.tcp.routers.mqtt.service=mqtt"
restart: on-failure
ulimits:
nproc: 65535
nofile:
soft: 1000000
hard: 1000000
79 changes: 62 additions & 17 deletions src/people/main/FocusView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { cloneDeep } from 'lodash';
import { observer } from 'mobx-react-lite';
import { FocusViewProps } from 'people/interfaces';
import { EuiGlobalToastList } from '@elastic/eui';
import { Organization } from 'store/main';
import { Box } from '@mui/system';
import { useStores } from '../../store';
import Form from '../../components/form/bounty';
Expand All @@ -17,11 +16,7 @@ import {
import WantedSummary from '../widgetViews/summaries/WantedSummary';
import { useIsMobile } from '../../hooks';
import { dynamicSchemasByType } from '../../components/form/schema';
import {
convertLocaleToNumber,
extractRepoAndIssueFromIssueUrl,
toCapitalize
} from '../../helpers';
import { convertLocaleToNumber, extractRepoAndIssueFromIssueUrl } from '../../helpers';
import { B, BWrap } from './style';

// selected bounty popup window
Expand Down Expand Up @@ -60,12 +55,50 @@ function FocusedView(props: FocusViewProps) {

const isTorSave = canEdit && main.isTorSave();

const userOrganizations = main.dropDownOrganizations.length
? main.dropDownOrganizations.map((org: Organization) => ({
label: toCapitalize(org.name),
value: org.uuid
}))
: [];
//this code block can be used to get the real org values
// const [userOrganizations,setUserOrganizations] = useState<any>({});
// const getOrg =async()=>{
// const response = await main.getOrganizations()
// const mappedResponse = response.map((org: Organization) => ({
// label: org.name,
// value: org.uuid
// }))
// setUserOrganizations(mappedResponse)
// }
// getOrg()
const urlParts = window.location.href.split('/bounties/');
const uuid = urlParts.length > 1 ? urlParts[1] : null;
const [orgName, setOrgName] = useState<any>([]);
const getOrganization = async () => {
if (!uuid) {
console.error('No UUID found in the URL');
return;
}

try {
const response = await main.getUserOrganizationByUuid(uuid);
console.log(response, 'res');

if (response && response.uuid && response.name) {
// Creating an array with an object containing label and value
const orgDetails = [
{
label: response.name,
value: response.uuid
}
];
setOrgName(orgDetails);
} else {
console.error('Response does not have the expected structure');
}
} catch (error) {
console.error('Error fetching organization:', error);
}
};

useEffect(() => {
getOrganization();
});

function isNotHttps(url: string | undefined) {
if (main.isTorSave() || url?.startsWith('http://')) {
Expand Down Expand Up @@ -192,6 +225,9 @@ function FocusedView(props: FocusViewProps) {

// body.description = description;
newBody.title = newBody.one_sentence_summary;

// save repo to cookies for autofill in form
ui.setLastGithubRepo(newBody.ticket_url);
}
} catch (e) {
throw githubError;
Expand Down Expand Up @@ -263,8 +299,20 @@ function FocusedView(props: FocusViewProps) {
props?.ReCallBounties();
}

// set user organizations
if (config?.schema?.[0]?.['defaultSchema']?.[0]?.['options']) {
config.schema[0]['defaultSchema'][0]['options'] = orgName;
}

let initialValues: any = {};

let altInitialValue = {};
if (window.location.href.includes('/org')) {
altInitialValue = {
org_uuid: uuid
};
}

const personInfo = canEdit ? ui.meInfo : person;

// set initials here
Expand Down Expand Up @@ -310,6 +358,8 @@ function FocusedView(props: FocusViewProps) {
initialValues[s.name] = wanted[s.name];
});
}
} else {
initialValues = altInitialValue;
}
}

Expand Down Expand Up @@ -347,11 +397,6 @@ function FocusedView(props: FocusViewProps) {
}
}

// set user organizations
if (config?.schema?.[0]?.['defaultSchema']?.[0]?.['options']) {
config.schema[0]['defaultSchema'][0]['options'] = userOrganizations;
}

return (
<div
style={{
Expand Down
Loading