Skip to content

Commit

Permalink
#104 added Services model, and disabled all excluded github
Browse files Browse the repository at this point in the history
  • Loading branch information
artzub committed Jun 20, 2023
1 parent c08991c commit 778d185
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 25 deletions.
12 changes: 7 additions & 5 deletions src/components/Header/components/Menu/ServiceSelector/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import GithubIcon from 'mdi-react/GithubIcon';
import GitIcon from 'mdi-react/GitIcon';
import GitlabIcon from 'mdi-react/GitlabIcon';

import { Services } from '@/models/Services';

import { useRouteMatches } from '@/shared/hooks/useRouteMatches';

import Item from './Item';
Expand Down Expand Up @@ -40,21 +42,21 @@ const Placeholder = styled.div`

const servicesMock = [
{
key: 'github',
key: Services.Github,
title: 'GitHub',
icon: <GithubIcon />,
},
{
key: 'gitlab',
key: Services.Gitlab,
title: 'GitLab',
icon: <GitlabIcon />,
// disabled: true,
disabled: true,
},
{
key: 'bitbucket',
key: Services.Bitbucket,
title: 'Bitbucket',
icon: <GitIcon />,
// disabled: true,
disabled: true,
},
];

Expand Down
13 changes: 9 additions & 4 deletions src/components/Settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import GithubIcon from 'mdi-react/GithubIcon';
import GitIcon from 'mdi-react/GitIcon';
import GitlabIcon from 'mdi-react/GitlabIcon';

import { Services } from '@/models/Services';

import NavLink from '@/shared/components/NavLink';

import Collection from './Collection';
Expand All @@ -17,7 +19,7 @@ const sxStyle = {
display: 'flex',
justifyContent: 'center',
};
const getConnectionItem = ({ key, title, icon }) => ({
const getConnectionItem = ({ key, title, icon, ...tail }) => ({
key,
title,
alignItems: 'center',
Expand All @@ -26,6 +28,7 @@ const getConnectionItem = ({ key, title, icon }) => ({
to: `./connection/${key}`,
tabIndex: 0,
primary: title,
...tail,
});

const items = [
Expand All @@ -37,19 +40,21 @@ const items = [
title: 'API Connections',
items: [
getConnectionItem({
key: 'github',
key: Services.Github,
title: 'GitHub',
icon: <GithubIcon />,
}),
getConnectionItem({
key: 'gitlab',
key: Services.Gitlab,
title: 'GitLab',
icon: <GitlabIcon />,
disabled: true,
}),
getConnectionItem({
key: 'bitbucket',
key: Services.Bitbucket,
title: 'Bitbucket',
icon: <GitIcon />,
disabled: true,
}),
],
},
Expand Down
2 changes: 0 additions & 2 deletions src/components/StageController/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { useStateAuthenticated } from './useStateAuthenticated';
const Authenticated = () => {
const { service, profile, repository, branch, commits } = useRouteMatches();

console.log('Authenticated');

useGithubEmojis(service);
useStageProfiles(service, profile);
useStageRepositories(repository);
Expand Down
4 changes: 3 additions & 1 deletion src/components/StageController/useGithubEmojis.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import { Services } from '@/models/Services';

import emojisSlice from '@/redux/modules/emojis';

export const useGithubEmojis = (service) => {
Expand All @@ -11,7 +13,7 @@ export const useGithubEmojis = (service) => {
// fetch list of emojis
useEffect(
() => {
if (service !== 'github' || Object.values(emojis).length) {
if (service !== Services.Github || Object.values(emojis).length) {
return undefined;
}

Expand Down
8 changes: 0 additions & 8 deletions src/components/StageController/useStateAuthenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ export const useStateAuthenticated = (service) => {
needRefresh.current += 1;
}

console.log(
'useStateAuthenticated',
prevPathname.current,
pathname,
needRefresh.current,
);

prevPathname.current = pathname;

const redirectToConnection = useEventCallback(() => {
Expand All @@ -50,7 +43,6 @@ export const useStateAuthenticated = (service) => {

useEffect(
() => {
console.log('request', service, needRefresh.current);
isAuthenticated.current = false;
dispatch(profilesSlice.actions.clear());
dispatch(profilesSlice.actions.fetchAuthenticated(null, 'authenticated'));
Expand Down
5 changes: 5 additions & 0 deletions src/models/Services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const Services = {
Github: 'github',
Gitlab: 'gitlab',
Bitbucket: 'bitbucket',
};
5 changes: 4 additions & 1 deletion src/shared/hooks/useRouteMatches.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { useRef } from 'react';
import { useMatch } from 'react-router-dom';

import { Services } from '@/models/Services';

const servicePath = '/:service';
const profilePath = `${servicePath}/:profile`;
const repositoryPath = `${profilePath}/:repository`;
const branchPath = `${repositoryPath}/:branch`;
const commitsPath = `${branchPath}/:commits`;

const allowedServices = ['github', 'gitlab', 'bitbucket'];
// const allowedServices = Object.values(Services);
const allowedServices = [Services.Github];

export const useRouteMatches = () => {
const { params: { service } = {} } = useMatch({ path: servicePath, end: false }) || {};
Expand Down
12 changes: 8 additions & 4 deletions src/themes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,27 @@ const GlobalStyle = createGlobalStyle`
text-rendering: optimizeLegibility;
font-family: 'JetBrains Mono', monospace;
}
button:not(#id_fake_for_hack) {
outline: 0;
}
.hovered {
cursor: pointer;
}
.draggable {
cursor: grab;
}
.dragging {
cursor: grabbing;
}
[disabled] {
pointer-events: none;
}
//body {
// font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
// 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
Expand Down

0 comments on commit 778d185

Please sign in to comment.