Skip to content

Commit

Permalink
Enable settings page for non-admins
Browse files Browse the repository at this point in the history
Non-admins need to be able to update their telemetry opt-in preferences
  • Loading branch information
swissspidy committed Sep 10, 2020
1 parent 3dd015c commit ef06bf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
4 changes: 1 addition & 3 deletions assets/src/dashboard/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ const AppContent = () => {
state: { currentPath },
} = useRouteHistory();

const { capabilities: { canManageSettings } = {} } = useConfig();
const enableSettingsView =
useFeature('enableSettingsView') && canManageSettings;
const enableSettingsView = useFeature('enableSettingsView');

useEffect(() => {
const dynamicPageTitle = ROUTE_TITLES[currentPath] || ROUTE_TITLES.DEFAULT;
Expand Down
28 changes: 16 additions & 12 deletions assets/src/dashboard/app/views/editorSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function EditorSettings() {
);

const {
capabilities: { canUploadFiles } = {},
capabilities: { canUploadFiles, canManageSettings } = {},
maxUpload,
maxUploadFormatted,
} = useConfig();
Expand All @@ -110,7 +110,9 @@ function EditorSettings() {
*/

useEffect(() => {
fetchSettings();
if ( canManageSettings ) {
fetchSettings();
}
}, [fetchSettings]);

useEffect(() => {
Expand Down Expand Up @@ -263,18 +265,20 @@ function EditorSettings() {
</Layout.Squishable>
<Layout.Scrollable>
<Main>
<GoogleAnalyticsSettings
{ canManageSettings && <GoogleAnalyticsSettings
handleUpdate={handleUpdateGoogleAnalyticsId}
googleAnalyticsId={googleAnalyticsId}
/>
<PublisherLogoSettings
handleAddLogos={handleAddLogos}
handleRemoveLogo={handleRemoveLogo}
publisherLogos={orderedPublisherLogos}
canUploadFiles={canUploadFiles}
isLoading={isMediaLoading}
uploadError={mediaError}
/>
/> }
{ canManageSettings &&
<PublisherLogoSettings
handleAddLogos={ handleAddLogos }
handleRemoveLogo={ handleRemoveLogo }
publisherLogos={ orderedPublisherLogos }
canUploadFiles={ canUploadFiles }
isLoading={ isMediaLoading }
uploadError={ mediaError }
/>
}
<TelemetrySettings
disabled={disabled}
onCheckboxSelected={toggleWebStoriesTrackingOptIn}
Expand Down
9 changes: 2 additions & 7 deletions assets/src/dashboard/components/pageStructure/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,12 @@ export const LeftRailContainer = styled.nav.attrs({

export function LeftRail() {
const { state } = useRouteHistory();
const {
newStoryURL,
version,
capabilities: { canManageSettings } = {},
} = useConfig();
const { newStoryURL, version } = useConfig();
const leftRailRef = useRef(null);
const upperContentRef = useRef(null);

const enableInProgressViews = useFeature('enableInProgressViews');
const enableSettingsViews =
useFeature('enableSettingsView') && canManageSettings;
const enableSettingsViews = useFeature('enableSettingsView');

const {
state: { sideBarVisible },
Expand Down

0 comments on commit ef06bf4

Please sign in to comment.