Skip to content

Commit

Permalink
modified: highlight access token button
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanov Anton committed Jul 12, 2024
1 parent dc97f34 commit 7b9f59f
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 48 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Modified
- Notification and Webhook models
- edit form of notifications and webhooks
- highlight access token button
- frontend folders structure

## [1.8.0] - 2024-07-04
### Added
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/application.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {
FeedbackForm,
Repository,
RepositoryForm,
Dropdown,
Flash,
ProfileConfiguration,
} from './components';
import {
Flash,
} from './atoms';

const components = {
Company,
Expand All @@ -21,7 +22,6 @@ const components = {
FeedbackForm,
Repository,
RepositoryForm,
Dropdown,
Flash,
ProfileConfiguration,
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { Chevron } from '../../svg';
import { Chevron } from '../assets';

export const Dropdown = ({ convertChildren = true, title, children }) => {
const [pageState, setPageState] = useState({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { Chevron } from '../../svg';
import { Chevron } from '../assets';

export const Select = ({ items, onSelect, selectedValue }) => {
const [isOpen, setIsOpen] = useState(false);
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/atoms/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './Insights/Insights';
export * from './Insights/RepositoryInsights';
export * from './Modal';
export * from './Checkbox';
export * from './Dropdown';
export * from './Flash';
export * from './Modal';
export * from './Select';
29 changes: 17 additions & 12 deletions app/javascript/components/Company/Company.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useRef } from 'react';

import { Insights } from '../../atoms';
import { Chevron, Delete, Edit, Key } from '../../svg';
import { Insights } from '../../components';
import { Chevron, Delete, Edit, Key } from '../../assets';

import { insightsRequest } from './requests/insightsRequest';

Expand Down Expand Up @@ -78,41 +78,46 @@ export const Company = ({
<div className="pr-4">
<h2 className="sm:flex sm:flex-row sm:items-center">
<div>{title}</div>
{is_private ? (
<span className="badge ml-4">
Private
</span>
) : null}
{unaccessable ? (
<span className="badge mt-4 sm:mt-0 sm:ml-4">
Company has repositories with access error
</span>
) : null}
</h2>
<span onClick={(event) => event.stopPropagation()}>
Repositories count -{' '}
<a href={repositories_url} className="underline text-orange-500">
{repositories_count}
</a>
{repositories_count === 0 ? (
<a
href={repositories_url}
className="badge mt-4 sm:mt-0 sm:ml-4"
className="badge sm:ml-4"
onClick={(event) => event.stopPropagation()}
>
Need to create repository
</a>
) : null}
</h2>
<span onClick={(event) => event.stopPropagation()}>
Repositories count -{' '}
<a href={repositories_url} className="underline text-orange-500">
{repositories_count}
</a>
</span>
</div>
<Chevron rotated={pageState.expanded} />
{edit_links ? (
<div className="absolute top-4 right-4 sm:top-8 sm:right-20 flex items-center">
{is_private ? (
{edit_links.need_access_token ? (
<span className="badge mr-4">
Private
Need to add access token
</span>
) : null}
{edit_links.access_token ? (
<a
href={edit_links.access_token}
onClick={(event) => event.stopPropagation()}
className="mr-2"
className={`mr-2 ${edit_links.need_access_token ? 'p-0.5 bg-orange-300 rounded-lg text-white' : ''}`}
>
<Key />
</a>
Expand Down
5 changes: 1 addition & 4 deletions app/javascript/components/Company/CompanyConfiguration.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React, { useState, useMemo } from 'react';

import { Dropdown } from '../../components';
import { Select } from './Select';

import { Modal } from '../../atoms';
import { Dropdown, Modal, Select } from '../../atoms';
import { apiRequest, csrfToken } from '../../helpers';

const NOTIFICATION_TYPES = {
Expand Down
4 changes: 1 addition & 3 deletions app/javascript/components/Company/CompanyForm.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useState } from 'react';

import { Select } from './Select';

import { Modal } from '../../atoms';
import { Modal, Select } from '../../atoms';
import { apiRequest, csrfToken } from '../../helpers';

export const CompanyForm = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useMemo } from 'react';

import { Arrow } from '../../svg';
import { Arrow } from '../../assets';

const SHORT_INSIGHT_NAMES = {
required_reviews_count: 'Req reviews',
Expand Down
5 changes: 1 addition & 4 deletions app/javascript/components/Profile/ProfileConfiguration.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React, { useState } from 'react';

import { Dropdown } from '../../components';
import { Select } from '../Company/Select';

import { Modal } from '../../atoms';
import { Dropdown, Modal, Select } from '../../atoms';
import { apiRequest, csrfToken, convertDate } from '../../helpers';

const INVITE_ACCESS_TARGETS = {
Expand Down
28 changes: 14 additions & 14 deletions app/javascript/components/Repository/Repository.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useEffect, useState, useRef } from 'react';

import { Insights, RepositoryInsights } from '../../components';
import { convertDate, convertTime } from '../../helpers';
import { Insights, RepositoryInsights } from '../../atoms';
import { Chevron, Delete, Github, Gitlab, Key } from '../../svg';
import { Chevron, Delete, Github, Gitlab, Key } from '../../assets';

import { insightsRequest } from './requests/insightsRequest';
import { repositoryInsightsRequest } from './requests/repositoryInsightsRequest';
Expand Down Expand Up @@ -118,23 +118,14 @@ export const Repository = ({
</div>
{access_token_status === 'valid' && !accessable ? (
<span className="badge mt-4 sm:mt-0 sm:ml-4">
Access token does not include this repository or expired, refresh it
Access token's update is required
</span>
) : null}
{access_token_status === 'invalid' ? (
<span className="badge mt-4 sm:mt-0 sm:ml-4">
Access token is invalid, refresh it
Access token's update is required
</span>
) : null}
{access_token_status === 'empty' && edit_links ? (
<a
href={edit_links.access_token}
className="badge mt-4 sm:mt-0 sm:ml-4"
onClick={(event) => event.stopPropagation()}
>
Need to add access token
</a>
) : null}
</h2>
<p className="flex items center">
<a
Expand All @@ -153,11 +144,20 @@ export const Repository = ({
<Chevron rotated={pageState.expanded} />
{edit_links ? (
<div className="absolute top-4 right-4 sm:top-8 sm:right-20 flex items-center">
{access_token_status === 'empty' && edit_links ? (
<a
href={edit_links.access_token}
className="badge mt-4 sm:mt-0 sm:mr-4"
onClick={(event) => event.stopPropagation()}
>
Need to add access token
</a>
) : null}
{edit_links.access_token ? (
<a
href={edit_links.access_token}
onClick={(event) => event.stopPropagation()}
className="mr-2"
className={`mr-2 ${access_token_status === 'empty' && edit_links ? 'p-0.5 bg-orange-300 rounded-lg text-white' : ''}`}
>
<Key />
</a>
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/components/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export * from './Company/Company';
export * from './Company/CompanyForm';
export * from './Company/CompanyConfiguration';
export * from './Feedback/FeedbackForm';
export * from './Dropdown/Dropdown';
export * from './Insights/Insights';
export * from './Insights/RepositoryInsights';
export * from './Repository/Repository';
export * from './Repository/RepositoryForm';
export * from './Flash/Flash';
export * from './Profile/ProfileConfiguration';
7 changes: 7 additions & 0 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ def user_ids
.pluck('identities.user_id')
end
end

def all_access_tokens
AccessToken.where(tokenable_id: id, tokenable_type: 'Company')
.or(
AccessToken.where(tokenable_id: repositories.select(:id), tokenable_type: 'Repository')
)
end
end
1 change: 1 addition & 0 deletions app/views/controllers/companies/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
is_private: !!company.configuration.private,
main_attribute: company.configuration.main_attribute,
edit_links: allowed_to?(:update?, company) ? {
need_access_token: !company.all_access_tokens.exists?,
access_token: new_company_access_token_path(company.uuid),
configuration: edit_company_configuration_path(company.uuid),
destroy: company_path(company.uuid)
Expand Down

0 comments on commit 7b9f59f

Please sign in to comment.