Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
[AFP-2121] Configure Permissions Message (#82)
Browse files Browse the repository at this point in the history
* add field in config to configure permissions message on queue and history tabs

* revert changes to docker compose

* remove permission import, change permission check back to 'read'

* revert changes to docker compose

* add default permissions message in Config.ts

Co-authored-by: Brian Do <[email protected]>
  • Loading branch information
2 people authored and itsjackgardner committed Aug 31, 2020
1 parent 992c49d commit 900e414
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ jobs:
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
- v1-dependencies-
- run: yarn
- save_cache:
paths:
Expand Down
4 changes: 4 additions & 0 deletions src/lib/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const getConfig = (): Config | null => {
configValid = false;
}

if (!config.permissionsMessage) {
config.permissionsMessage = 'Contact an admin for permission to view this information';
}

if (!configValid) {
throw new Error('Config is invalid');
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ export class Runner {
bitbucketBaseUrl: `https://bitbucket.org/${this.config.repoConfig.repoOwner}/${
this.config.repoConfig.repoName
}`,
permissionsMessage: this.config.permissionsMessage,
};
};
}
1 change: 1 addition & 0 deletions src/static/current-state/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const App: React.FunctionComponent = () => (
loggedInUser={loggedInUser}
paused={data.pauseState !== null}
bannerMessageState={data.bannerMessageState}
permissionsMessage={data.permissionsMessage}
/>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/static/current-state/components/tabs/HistoryTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Section } from '../Section';
export type HistoryTabProps = {
bitbucketBaseUrl: string;
loggedInUser: ISessionUser;
permissionsMessage: string;
};

type HistoryState = {
Expand Down Expand Up @@ -64,7 +65,7 @@ export class HistoryTab extends React.Component<HistoryTabProps, HistoryState> {
<TabContent>
<EmptyState>
{this.props.loggedInUser.permission === 'read'
? 'Contact an admin for permission to view this information'
? this.props.permissionsMessage
: 'Empty...'}
</EmptyState>
</TabContent>
Expand Down
7 changes: 3 additions & 4 deletions src/static/current-state/components/tabs/QueueTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ export type QueueTabProps = {
bitbucketBaseUrl: string;
loggedInUser: ISessionUser;
queue: IStatusUpdate[];
permissionsMessage: string;
};

export const QueueTab: React.FunctionComponent<QueueTabProps> = props => {
const { bitbucketBaseUrl, loggedInUser, queue } = props;
const { bitbucketBaseUrl, loggedInUser, queue, permissionsMessage } = props;
return (
<div>
<QueueItemsList
Expand All @@ -20,9 +21,7 @@ export const QueueTab: React.FunctionComponent<QueueTabProps> = props => {
renderEmpty={() => (
<TabContent>
<EmptyState>
{loggedInUser.permission === 'read'
? 'Contact an admin for permission to view this information'
: 'Queue is empty...'}
{loggedInUser.permission === 'read' ? permissionsMessage : 'Queue is empty...'}
</EmptyState>
</TabContent>
)}
Expand Down
24 changes: 21 additions & 3 deletions src/static/current-state/components/tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export type TabsProps = {
loggedInUser: ISessionUser;
paused: boolean;
bannerMessageState: IMessageState | null;
permissionsMessage: string;
};

type TabsState = {
Expand Down Expand Up @@ -112,7 +113,15 @@ export class Tabs extends React.Component<TabsProps, TabsState> {

render() {
const { selected } = this.state;
const { users, bitbucketBaseUrl, queue, loggedInUser, paused, bannerMessageState } = this.props;
const {
users,
bitbucketBaseUrl,
queue,
loggedInUser,
paused,
bannerMessageState,
permissionsMessage,
} = this.props;

return (
<Section important last>
Expand All @@ -126,10 +135,19 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
/>
) : null}
{selected === 1 ? (
<QueueTab bitbucketBaseUrl={bitbucketBaseUrl} loggedInUser={loggedInUser} queue={queue} />
<QueueTab
bitbucketBaseUrl={bitbucketBaseUrl}
loggedInUser={loggedInUser}
queue={queue}
permissionsMessage={permissionsMessage}
/>
) : null}
{selected === 2 ? (
<HistoryTab bitbucketBaseUrl={bitbucketBaseUrl} loggedInUser={loggedInUser} />
<HistoryTab
bitbucketBaseUrl={bitbucketBaseUrl}
loggedInUser={loggedInUser}
permissionsMessage={permissionsMessage}
/>
) : null}
</Section>
);
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type Config = {
prSettings: PullRequestSettings;
deployment: DeploymentConfig;
maxConcurrentBuilds?: number;
permissionsMessage: string;
sequelize?: any;
easterEgg?: any;
};
Expand All @@ -87,4 +88,5 @@ export type RunnerState = {
users: UserState[];
bannerMessageState: IMessageState | null;
bitbucketBaseUrl: string;
permissionsMessage: string;
};

0 comments on commit 900e414

Please sign in to comment.